DEFRA / sroc-service-team

Guides, info and issue management for the Charging Module Team
Other
0 stars 1 forks source link

Fix invalid value for customer files 'required' #105

Closed Cruikshanks closed 2 years ago

Cruikshanks commented 2 years ago

In Document list customer files endpoint we added details about our new customer file endpoint which includes an optional path parameter. Hapi is fine with this and in our opinion, it looks much cleaner. However, Swagger doesn't support optional path parameters

In OpenAPI, a path parameter is defined using in: path. The parameter name must be the same as specified in the path. Also remember to add required: true, because path parameters are always required.

https://swagger.io/docs/specification/describing-parameters/#path-parameters

So, required: false is an invalid attribute for a path param in Swagger and SwaggerHub highlights it as an error. The only workaround is to drop the required and document the fact it's optional ☹️