Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter referencing in PathItemObject.parameters. #105

Closed
mopaul opened this issue Jan 21, 2017 · 7 comments
Closed

Parameter referencing in PathItemObject.parameters. #105

mopaul opened this issue Jan 21, 2017 · 7 comments

Comments

@mopaul
Copy link

mopaul commented Jan 21, 2017

My swagger definition defines a bunch of query parameters in the root.parameters which I then reference from the pathItem.parameters section. When I try to access the operation parameters using app.op.parameters, it looks like only the 1st parameter referenced in pathItem.parameters is associated with the path's Operation object.

If I understand the swagger definition, pathItems.parameters are applicable to all the operations in the path.

Am I missing something?

Referencing a parameter from operation.parameters works as expected.

@mission-liao
Copy link
Member

It should work when each $ref points to one parameter definition under root.parameters. I just add a test case for it, could you check if this is what you expected?
test-spec
test-case

If this is not what you described, could you help to provide a sample swagger.json/yaml and code?

@mopaul
Copy link
Author

mopaul commented Jan 23, 2017

I meant referencing a parameter in the path.parameter section. Something like this.

"paths":{
      "/a":{
         "get":{
            "parameters":[
               {
                  "name":"p2",
                  "in":"body",
                  "schema":{
                     "$ref":"#/definitions/d1"
                  }
               }
            ],
            "responses":{
               "default":{
                  "$ref":"#/responses/r1"
               }
            }
         },
         "parameters": [
            {
               "$ref":"#/parameters/p1"
            },
            {
               "$ref":"#/parameters/p2"
            }
         ]
      }
   }

The parameters p1 and p2 are being referenced from the path.parameters and not operation.parameters. I can only see p2 and p1_d associated with the operation but (if I understand the swagger spec correctly), p2, p1_d and p2_d are all valid parameters.

Let me know if you want me to send a PR with a test case.

@mission-liao
Copy link
Member

The case you described is new to me, and yes, it's spec compliant. Any PR with test case is welcome, thanks.

@mopaul
Copy link
Author

mopaul commented Jan 24, 2017

PR 106 has the test case.

@mission-liao
Copy link
Member

OK, thanks. I'll work on this part tomorrow evening.

mission-liao added a commit that referenced this issue Jan 25, 2017
#105

- should always use “final” property when a field is either “some
object” or “reference object”
- another bug found during fixing this issue: update ‘parameters’ in
for loop
mission-liao added a commit that referenced this issue Jan 25, 2017
- #105 Parameter
referencing in PathItemObject.parameters.
@mission-liao
Copy link
Member

this bug is fixed in v0.8.26, please feel free to reopen it when it's still failed.

@mopaul
Copy link
Author

mopaul commented Jan 26, 2017

Fix verified. Thanks for your quick responses.

mission-liao added a commit to pyopenapi/pyopenapi that referenced this issue Aug 12, 2017
pyopenapi/pyswagger#105

- should always use “final” property when a field is either “some
object” or “reference object”
- another bug found during fixing this issue: update ‘parameters’ in
for loop
mission-liao added a commit to pyopenapi/pyopenapi that referenced this issue Aug 12, 2017
- pyopenapi/pyswagger#105 Parameter
referencing in PathItemObject.parameters.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants