kevindew / openapi3_parser

Open API 3 Parser/Validator for Ruby
MIT License
90 stars 12 forks source link

Possible issue with circular references in Components/Schema #5

Closed mikebell closed 4 years ago

mikebell commented 6 years ago

I'm trying to access the Pets schema from the following document - https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml

But I'm not entirely sure it's working correctly. If I access the node_data on the schema object it doesn't pull in any of the data from the referenced Pet schema object.

Is there a special way of accessing this data?

kevindew commented 6 years ago

Hey - I've tried opening that file here and I've found there was a bug with the x-head header. I've sorted that now though and just putting out a new release.

I wasn't able to hit the problem you seem to be mentioning though. Would you be able to post a code sample.

My attempt was:

irb(main):018:0> d = Openapi3Parser.load_url("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml")
=> Openapi3Parser::Document(openapi_version: 3.0, root_source: Openapi3Parser::Source(input: https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml))
irb(main):019:0> d.components.schemas["Pets"].items.node_data
=> {"required"=>Openapi3Parser::Node::Array(#/components/schemas/Pets/items/%24ref/required), "properties"=>Openapi3Parser::Node::Map(#/components/schemas/Pets/items/%24ref/properties), "title"=>nil, "multipleOf"=>nil, "maximum"=>nil, "exclusiveMaximum"=>false, "minimum"=>nil, "exclusiveMinimum"=>false, "maxLength"=>nil, "minLength"=>0, "pattern"=>nil, "maxItems"=>nil, "minItems"=>0, "uniqueItems"=>false, "maxProperties"=>nil, "minProperties"=>0, "enum"=>nil, "type"=>nil, "allOf"=>nil, "oneOf"=>nil, "anyOf"=>nil, "not"=>nil, "items"=>nil, "additionalProperties"=>false, "description"=>nil, "format"=>nil, "default"=>nil, "nullable"=>false, "discriminator"=>nil, "readOnly"=>false, "writeOnly"=>false, "xml"=>nil, "externalDocs"=>nil, "example"=>nil, "deprecated"=>false}
irb(main):020:0> d.components.schemas["Pets"].items.required.to_a
=> ["id", "name"]
kevindew commented 4 years ago

I'm going to consider this resolved now. Thanks for raising the issue, and do feel free to re-open if this is still a concern.