vmware / vmware-openapi-generator

VMware-openapi-generator tool generates open-api documents from vapi metamodel format.
Other
23 stars 19 forks source link

Swagger generation includes query parameters in the request mapping path #34

Closed kunal-pmj closed 1 year ago

kunal-pmj commented 5 years ago

The swagger specifications generated from this tool are not Swagger 2.0 compliant. There are few APIs whose Query Parameters are appended to the Request Mapping URL. As per Swagger 2.0 and 3.0 specifications Parameters can be of following types and they should be defined in the Parameters section of operations for every path or at the path.

path parameters, such as /users/{id} query parameters, such as /users?role=admin header parameters, such as X-MyHeader: Value cookie parameters, which are passed in the Cookie header, such as Cookie: debug=0; csrftoken=BUSe35dohU3O1MZvDCU

kunal-pmj commented 5 years ago

One such example would be following REST API. "/com/vmware/cis/tagging/tag/id:{category_id}?~action=list-tags-for-category": { "post": { To make it Swagger 2.0 complaint. The query parameter should be removed from request mapping path and moved to the the parameter section. { "name": "~action", "in": "query", "description": "~action=list-tags-for-category", "required": true, "type": "string", "enum": [ "list-tags-for-category" ] } This way the the parameter can be made required with only one possible value

karaatanassov commented 1 year ago

This is artifact of the underlying APIs there is no option in the generator to change that reality.

Swagger 2.0 actually defined the path as URI template. As per URI template RFC the path templates can contain query parameter expansions including fixed expansions.

https://www.rfc-editor.org/rfc/rfc6570#section-3.2.9

The problem is more with OpenAPI 3 schema as that does not define way for such fixed query parameters

https://github.com/OAI/OpenAPI-Specification/issues/164

Anyway there is little choice in this project to do anything about these issues.