How to get list of all keys defined in the routing e.g path, defaults, options etc and how can we add new custom key? route_with_two_nodes:
  path: '/foo/{node1}/{node2}'
  defaults:
    _controller: '\Drupal\example\Controller\ExampleController::foo'
  options:
    parameters:
      node1:
        type: entity:node
      node2:
        type: entity:node


I need to get list of all keys path, defaults, options etc, where is it defined in Drupal Core ? so that if I need to add custom key and extend it
Add a route enhancer:

Example how _form gets replaced by _controller:

Drupal\Core\Routing\Enhancer\FormRouteEnhancer:

&lt;?php

namespace Drupal\Core\Routing\Enhancer;

use Drupal\Core\Routing\EnhancerInterface;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Route;

/**
 * Enhancer to add a wrapping controller for _form routes.
 */
class FormRouteEnhancer implements EnhancerInterface {

  /**
   * Returns whether the enhancer runs on the current route.
   *
   * @param \Drupal\Core\Routing\Enhancer\Route $route
   *   The current route.
   *
   * @return bool
   */
  protected function applies(Route $route) {
    return $route-&gt;hasDefault('_form') &amp;&amp; !$route-&gt;hasDefault('_controller');
  }

  /**
   * {@inheritdoc}
   */
  public function enhance(array $defaults, Request $request) {
    $route = $defaults[RouteObjectInterface::ROUTE_OBJECT];
    if (!$this-&gt;applies($route)) {
      return $defaults;
    }

    $defaults['_controller'] = 'controller.form:getContentResult';
    return $defaults;
  }

}