Forum Discussion

mrbalky's avatar
mrbalky
New Contributor
8 years ago

Tagged API methods vanish when using $ref parameters

I'm trying to use $ref parameters YAML to represent a common body for multiple PUT/POST request documentation, but when I do, the API calls vanish alltogether, along with all other API calls with the same tag.

 

Using the following sample editor, when I click over to  Interactive API Docs, the Blah API tag will appear, but the Foo API tag does not.  If I remove the $ref from line 22, the Foo tag will appear in the interactive docs.

 

As far as I can tell, the syntax is correct, and I get the "valid {...}" message at the top of the API page.

 

I can duplicate the body definition (and am currently doing this), but it would obviously be more convenient to be able to use the common reference.

 

What am I doing wrong here?

 

Thanks

4 Replies

  • Hi mrbalky,

     

    It looks like your API definition is using a `get` method to send a body parameter--that's not allowed in a GET, you will have to use `put`, `post`, or `delete`.  I'm guessing you really want a `post` operation, which should work just fine like this:

     

    paths:
      '/api-public/v1/foo/{asdf}':
        post:
          tags:
            - Foo
          summary: "Do foo"
          description: Foo foo foo foo
          parameters:
            - name: asdf
              in: path
              type: string
              required: true
            - $ref: '#/parameters/qwerty'
          responses:
            '200':
              description: yeah

     Please post back if you still have issues!

    • mrbalky's avatar
      mrbalky
      New Contributor

      D'oh! Yep, you're right.  POST is what I wanted.

       

      Still have the problem, though.  Here's without the $ref to '#/parameters/qwerty'

       

      And here's with the $ref:

       

       

      Thanks,

      Charlie 

      • RonRatovsky's avatar
        RonRatovsky
        Moderator

        Hi!

         

        I believe there's indeed an issue with rendering referenced body parameter, regardless of the HTTP method and we'll need to look into resolving that. For now, the workaround would be to not reference such parameters and repeat them for each operation. We'll of course update you when a solution in the rendering is available.