Complete example for register_rest_route
-
I have troubles finding the a way to add certain elements as described in the OpenAPi specification to the swagger API documentation.
For example, I would like to define a summary and a description to the API methods, but can’t find out how.
Also I need to add geojson as an additional response content type. I tried to add it directly to the args parameter of register_rest_route, but without success:
`register_rest_route( ‘xrcb/v1’, ‘/radios/(?P<id>\d+)’, array(
‘methods’ => ‘GET’,
‘summary’ => ‘Find radio by ID.’,
‘description’ => ‘Returns a single radio.’,
‘produces’ => ‘application/vnd.geo+json’,
‘callback’ => ‘xrcbapi_radios_api_endpoint’,
‘args’ => array(
‘id’ => array(
‘description’ => esc_html__( ‘ID of radio to return’, ‘xrcb’ ),
‘type’ => ‘integer’,
‘prop_format’ => ‘int64’,
‘validate_callback’ => function($param, $request, $key) {
return is_numeric( $param );
}
),
),
));`A complete example of register_rest_route would be great.
- The topic ‘Complete example for register_rest_route’ is closed to new replies.