Forum Discussion

Stephan123's avatar
Stephan123
New Contributor
5 years ago

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
    5 years ago

    Should be

    paths:
      /bla/foo:
        post:
          ...
      /bla/foo/bar:
        post:
          ...
  • 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:
              ...