Does Swagger 2.0 support matrix parameters of JAX-RS specification?
JAX-RS specification have Matrix-Parameter support.
I have some matrix parameter present in my application such as /map/color;lat=50;long=20;scale=32000
.
I want to derive Swagger for matrix parameters. I use http://editor.swagger.io; but I could not got any help in the editor. Can anyone help me?
Does Swagger 2.0 support matrix parameters?
Other links ralted to matrix param:
OpenAPI/Swagger 2.0 does not support matrix parameters, but they are supported in OpenAPI 3.0.
Using OpenAPI 3.0, your example:
/map/color;lat=50;long=20;scale=32000
can be defined as:
openapi: 3.0.1
...
paths:
/map/color{params}:
get:
parameters:
- in: path
name: params
required: true
# Named matrix parameters are defined as object properties
schema:
type: object
properties:
lat:
type: integer
example: 50
long:
type: integer
example: 20
scale:
type: integer
example: 32000
# Serialize this object as ;prop1=value2;prop2=value2 etc
style: matrix
explode: true
This is supported in Swagger UI 3.15.0+ and Swagger Editor 3.5.6+. In the parameter editor, enter the parameter names and values in the JSON object format, e.g.:
{
"lat": 50,
"long": 20,
"scale": 32000
}
"Try it out" will send these parameters as matrix parameters in the URL:
For those using Java annotations, @MatrixParam
is supported in swagger-core 2.0. @MatrixParam
corresponds to OpenAPI 3.0's path parameters with style: matrix
(as in the example above).
Swagger 2.0 spec does not mention anything about JAX-RS Matrix parameter.
Also looking at the swagger-jaxrs implementation, you can see that @MatrixParam
is ignored in the class responsible for scanning JAX-RS parameter annotations.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With