Forum Discussion

Stephan123's avatar
Stephan123
New Contributor
4 years ago
Solved

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

  • HKosova's avatar
    HKosova
    4 years ago

    Should be

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

3 Replies

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    Hi Stephan,

     

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

    /bla/foo

    /bla/foo/bar

    • Stephan123's avatar
      Stephan123
      New Contributor

      Thanks for the quick response.

      On the fly, is this way correct ?

       

      ----- snip ---

      ...

       

      paths:

        /bla/foo

        /bla/foo/bar

           post:

       

      ...

      --- snip ---

       

      Your sincerly

       

      Stephan

      • HKosova's avatar
        HKosova
        SmartBear Alumni (Retired)

        Should be

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