cancel
Showing results for 
Search instead for 
Did you mean: 

Swagger path with optional parm

SOLVED
Highlighted
New Contributor

Swagger path with optional parm

Hello,

 

i'm a beginner in swagger editor.

I will write a simple application.

In my application there is a route.

For example: /bla/foo

I need in the path a optional param for example: /bla/foo/bar

'bar' is the optional param.

Can i define a optional param ?

 

Your sincerly

 

Stephan

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Moderator

Re: Swagger path with optional parm

Should be

paths:
  /bla/foo:
    post:
      ...
  /bla/foo/bar:
    post:
      ...

Helen Kosova
SmartBear Documentation Team Lead
________________________

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

3 REPLIES 3
Highlighted
Moderator

Re: Swagger path with optional parm

Hi Stephan,

 

Path parameters cannot be optional. You need to define two separate paths:

/bla/foo

/bla/foo/bar


Helen Kosova
SmartBear Documentation Team Lead
________________________

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
New Contributor

Re: Swagger path with optional parm

Thanks for the quick response.

On the fly, is this way correct ?

 

----- snip ---

...

 

paths:

  /bla/foo

  /bla/foo/bar

     post:

 

...

--- snip ---

 

Your sincerly

 

Stephan

Highlighted
Moderator

Re: Swagger path with optional parm

Should be

paths:
  /bla/foo:
    post:
      ...
  /bla/foo/bar:
    post:
      ...

Helen Kosova
SmartBear Documentation Team Lead
________________________

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors
Top Kudoed Posts