mount a swagger statics page.

    app: the aiohttp app object
    target_route: the path to mount the statics page.
    swagger_json_route: the path where the swagger json definitions is
                        expected to be.
480764
def add_swagger_api_route(app, target_route, swagger_json_route):
    
    static_root = get_swagger_static_root()
    swagger_body = generate_swagger_html(
        STATIC_ROOT, swagger_json_route
    ).encode("utf-8")

    async def swagger_ui(request):
        return web.Response(body=swagger_body, content_type="text/html")

    app.router.add_route("GET", target_route, swagger_ui)
    app.router.add_static(STATIC_ROOT, static_root)
140792
public void route(HttpMethods meth, String path, API api, GwCode code) throws Exception {
		String version = "1.0";
		// Get Correct API Class from Mapper
		Class<?> respCls = facade.mapper().getClass(api); 
		if(respCls==null) throw new Exception("Unknown class associated with " + api.getClass().getName() + ' ' + api.name());
		// setup Application API HTML ContentTypes for JSON and Route
		String application = applicationJSON(respCls, version);
		//route(env,meth,path,code,application,"application/json;version="+version,"*/*");

		// setup Application API HTML ContentTypes for XML and Route
		application = applicationXML(respCls, version);
		//route(env,meth,path,code.clone(facade_1_0_XML,false),application,"text/xml;version="+version);
		
		// Add other Supported APIs here as created
	}
713849
def app_routes(app):
    
    _routes = []
    for rule in app.url_map.iter_rules():
        _routes.append({
            'path': rule.rule,
            'name': rule.endpoint,
            'methods': list(rule.methods)
        })
    return jsonify({'routes': _routes})
29942
function urlToRoutesFilePath (state, endpoint) {
  const [, scope] = endpoint.documentationUrl.match(/\/v3\/([^/#]+)((\/[^/#]+)*)/)
  return joinPath(
    __dirname,
    '..',
    'routes',
    state.folderName,
    kebabCase(scope),
    `${endpoint.idName}.json`
  )
}
818145
def target_show(self, id, **kwargs):
        ""
        api_path = "/api/v2/targets/{id}.json"
        api_path = api_path.format(id=id)
        return self.call(api_path, **kwargs)
1250667
def register_swaggerui_app(app, swagger_uri, api_url, page_title='Swagger UI', favicon_url=None, config=None, uri_prefix=""):

    """"""

    templates_folder = 'templates'
    static_folder = 'dist'

    default_config = {
        'client_realm': 'null',
        'client_id': 'null',
        'client_secret': 'null',
        'app_name': 'null',
        'docExpansion': "none",
        'jsonEditor': False,
        'defaultModelRendering': 'schema',
        'showRequestHeaders': False,
        'supportedSubmitMethods': ['get', 'post', 'put', 'delete', 'patch'],
    }

    if config:
        default_config.update(config)

    default_context = {
        'page_title': page_title,
        'favicon_url': favicon_url,
        'base_url': uri_prefix + swagger_uri,
        'api_url': api_url,
        'app_name': default_config.pop('app_name'),
        'client_realm': default_config.pop('client_realm'),
        'client_id': default_config.pop('client_id'),
        'client_secret': default_config.pop('client_secret'),
        # Rest are just serialized into json string
        # for inclusion in the .js file
        'config_json': json.dumps(default_config)
    }

    app.add_sink(
        StaticSinkAdapter(static_folder),
        r'%s/(?P<filepath>.*)\Z' % swagger_uri,
    )

    app.add_route(
        swagger_uri,
        SwaggerUiResource(templates_folder, default_context)
    )
914894
def create_swagger_json_handler(app, **kwargs):
    

    spec = get_swagger_spec(app).swagger_definition(**kwargs)
    encoded_spec = json.dumps(spec).encode("UTF-8")

    async def swagger(request):
        return web.Response(
            # we allow CORS, so this can be requested at swagger.io
            headers={
                "Access-Control-Allow-Origin": "*"
            },
            body=encoded_spec,
            content_type="application/json",
        )

    return swagger
881079
def static_url(path, absolute=False):
    

    if os.sep != '/':
        path = '/'.join(path.split(os.sep))

    return flask.url_for('static', filename=path, _external=absolute)
1327814
def remap_link_target(path, absolute=False):
    
    if path.startswith('@'):
        # static resource
        return static_url(path[1:], absolute=absolute)

    if absolute:
        # absolute-ify whatever the URL is
        return urllib.parse.urljoin(flask.request.url, path)

    return path
1273996
def _route(self):
        '''  '''
        self._app.route('/',
                        method='GET',
                        callback=self._get_logger_list)
        self._app.route('/stats',
                        method='GET',
                        callback=self._fetch_handler_stats)
        self._app.route('/<name>/start',
                        method='POST',
                        callback=self._add_logger_by_name)
        self._app.route('/<name>/stop',
                        method='DELETE',
                        callback=self._stop_logger_by_name)
        self._app.route('/<name>/config',
                        method='GET',
                        callback=self._get_logger_conf)
        self._app.route('/<name>/rotate',
                        method='POST',
                        callback=self._rotate_capturer_log)
1241684
def route(verb, path, options = {}, &block)
      no_swagger = options[:no_swagger]
      options.delete(:no_swagger)
      if (verb == 'HEAD') || no_swagger
        super(verb, path, options, &block)
      else
        request_processor = create_request_processor(verb.downcase, path, options)
        super(verb, path, options) do |*params|
          response = catch(:halt) do
            request_processor.run(self, params, &block)
          end
          if settings.result_validation
            begin
              # Inspired from Sinatra#invoke
              if (Fixnum === response) or (String === response)
                response = [response]
              end
              if (Array === response) and (Fixnum === response.first)
                response_for_validation = response.dup
                response_status = response_for_validation.shift
                response_body = response_for_validation.pop
                response_headers = (response_for_validation.pop || {}).merge(self.response.header)
                response_content_type = response_headers['Content-Type']
                request_processor.validate_response(response_body, response_content_type, response_status)
              elsif response.respond_to? :each
                request_processor.validate_response(response.first.dup, self.response.header['Content-Type'], 200)
              end
            rescue Sinatra::SwaggerExposer::SwaggerInvalidException => e
              content_type :json
              throw :halt, [400, {:code => 400, :message => e.message}.to_json]
            end
          end
          throw :halt, response
        end
      end
    end
770753
def route_request(self, request_json, metadata=None):

        '''  '''
        request = Request(request_json)
        request.metadata = metadata
        # add reprompt handler or some such for default?
        handler_fn = self._handlers[self._default] # Set default handling for noisy requests

        if not request.is_intent() and (request.request_type() in self._handlers):
            '''  Route request to a non intent handler '''
            handler_fn = self._handlers[request.request_type()]

        elif request.is_intent() and request.intent_name() in self._handlers['IntentRequest']:
            ''' Route to right intent handler '''
            handler_fn = self._handlers['IntentRequest'][request.intent_name()]

        response = handler_fn(request)
        response.set_session(request.session)
        return response.to_json()
898736
function routeSerializer(route) {
	if (route && route.path) {
		return {
			path: route.path,
			methods: route.methods,
			method: route.method
		};
	}
	return route;
}
1119549
def add_route(app_or_blueprint, fn, context=default_context):
    
    transmute_func = TransmuteFunction(
        fn,
        args_not_from_request=["request"]
    )
    handler = create_handler(transmute_func, context=context)
    get_swagger_spec(app_or_blueprint).add_func(transmute_func, context)
    for p in transmute_func.paths:
        sanic_path = _convert_to_sanic_path(p)
        app_or_blueprint.add_route(handler, sanic_path, methods=list(transmute_func.methods))
640416
function defineRoute (server, opts) {

    server.route({
        method: 'GET',
        path: '/bomb',
        handler: handler,
        config: {
            jsonp: 'callback',
            validate: {
                query: {
                    count: Hapi.types.Number()
                },
                payload: false
            }
        }
    });

    function handler (req) {
        var count = (req.query.count || opts.defaultBombCount);
        var res = {};
        res[opts.plural] = _.sample(opts.things, count);
        req.reply(res);
    }

}
1202592
def run(cls, routes, *args, **kwargs): # pragma: no cover
    

    app = init(cls, routes, *args, **kwargs)

    HOST = os.getenv('HOST', '0.0.0.0')
    PORT = int(os.getenv('PORT', 8000))

    aiohttp.web.run_app(app, port=PORT, host=HOST)
266805
def postmap(self, path, valuemap=None, query=None):
        
        code, data, ctype = self.post(path, valuemap, query)
        if ctype != 'application/json':
            self.log.error("Expecting JSON from POST of '%s', got '%s'", self.lastpath, ctype)
            raise HttpError(code=400, content_type='text/plain', content='Remote returned invalid content type: '+ctype)
        try:
            result = json.loads(data)
        except Exception as e:                                                                  # pragma: no cover
            self.log.error("Could not load JSON content from POST %r -- %s", self.lastpath, e)
            raise HttpError(code=400, content_type='text/plain', content='Could not load JSON content')
        return result