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

fix and test for issue 1758 #1760

Merged
merged 5 commits into from
Jul 8, 2022
Merged

fix and test for issue 1758 #1760

merged 5 commits into from
Jul 8, 2022

Conversation

gracekarina
Copy link
Contributor

@gracekarina gracekarina commented Jun 25, 2022

Fix and test for issue #1758.

Adds a validation message for parameters and headers when ref field in internal references are not being pointed at the right components tag.

@gracekarina
Copy link
Contributor Author

gracekarina commented Jun 29, 2022

@ponelat @frantuma I addressed the comments, and also did the validation in deserializer of examples, and securitySchemes, but not 100% sure it applies here.
If you have a sample of a ref example being use, and securitySchemes using the ref #/components/... please let me know, I haven't find any.
Thanks

@ponelat
Copy link
Member

ponelat commented Jun 29, 2022

@gracekarina securitySchemas aren't referenced using $ref, instead they're referenced via the security: [] fields in operations and globally.

Here is an example of using $ref to point to an example. Not that they're not for schemas, but for response/requestBodies, i.e., examples, see: https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#exampleObject

openapi: 3.0.3
info:
  title: $ref of an "Example".
  version: 1.0.0
paths:
  /foo:
    get:
      description: ok
      responses:
        '200':
          description: ok
          content:
            application/json:
              schema:
                type: object
              examples:
                one:
                  $ref: '#/components/examples/Ex'
              
components:
  examples:
    Ex:
      summary: The value one.
      value: 
        one: '1'

Copy link
Member

@frantuma frantuma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gracekarina couple of minor comments, when addressed please merge

@@ -958,6 +958,9 @@ public PathItem getPathItem(ObjectNode obj, String location, ParseResult result)
} else {
pathItem.set$ref(ref.textValue());
}
if(ref.textValue().startsWith("#/components") && !(ref.textValue().startsWith("#/components/pathItems"))) {
result.warning(location, "$ref target "+ref.textValue() +" is not of expected type");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would detail what is the expected type, like "$ref target "+ref.textValue() +" is not of expected type pathItem");. Same applies to similar code below

}else {
parameter.set$ref(ref.textValue());
}
if(ref.textValue().startsWith("#/components") && !(ref.textValue().startsWith("#/components/parameters")||ref.textValue().startsWith("#/components/headers"))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cdoe style, would replace meters")||ref.textVal with meters") || ref.textVal

@@ -2115,6 +2127,10 @@ public Header getHeader(ObjectNode headerNode, String location, ParseResult resu
} else {
header.set$ref(ref.textValue());
}
if(ref.textValue().startsWith("#/components") && !(ref.textValue().startsWith("#/components/parameters")||ref.textValue().startsWith("#/components/headers"))) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cdoe style, would replace meters")||ref.textVal with meters") || ref.textVal

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

Successfully merging this pull request may close these issues.

3 participants