How to define an optional parameter in path using swagger

后端 未结 5 1954
名媛妹妹
名媛妹妹 2020-12-29 00:51

There is a function in my REST web service working with GET method and it has two optional parameters.

I tried to define it in Swagger but I encountered an error, <

5条回答
  •  情书的邮戳
    2020-12-29 01:38

    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

提交回复
热议问题