How to define an optional parameter in path using swagger

Given that path parameter must be required according to the OpenAPI/Swagger spec, you can consider adding 2 separate endpoints with the following paths:

  • /get/{param1}/{param2} when param2 is provided
  • /get/{param1}/ when param2 is not provided

Leave a Comment