manchenkoff / openapi3-parser

OpenAPI 3 parser to use a specification inside of the code in your projects
https://pypi.org/project/openapi3-parser/
MIT License
61 stars 33 forks source link

[Feature] Provide the reference value for properties that use a Ref #48

Closed yoyossef closed 1 year ago

yoyossef commented 1 year ago

Hello,

One thing that the library does well is the resolution of the references, but one thing that we lose is that we cannot find the original reference of a property anymore.

For example (this property is a reference to some schema in the document):

accessTokenRequest:
          $ref: '#/components/schemas/AccessTokenReq'

Is represented like this:

 Property(name='accessTokenRequest', schema=Object(type=<DataType.OBJECT: 'object'>, title=None, enum=[], example=None, description='Contains information related to the access token request', default=None, nullable=False, read_only=False, write_only=False, deprecated=False, extensions={}, max_properties=None, min_properties=None, required=['grant_type', 'nfInstanceId', 'scope'], properties=[Property(name='grant_type', schema=String(type=<DataType.STRING: 'string'>, title=None, enum=['client_credentials'], example=None, description=None, default=None, nullable=False, read_only=False, write_only=False, deprecated=False, extensions={}, max_length=None, min_length=None, pattern=None, format=None)),

And this is great but we miss the variable describing what schema this property is referring to and this is limiting me in the script I am writing.

Simply having another variable in the object like ref='#/components/schemas/AccessTokenReq', would help me a lot.

Thanks.

manchenkoff commented 1 year ago

Hey @yoyossef, unfortunately, this resolver is a part of one of the package dependencies, and there is no control over it in my code. It comes from package prance and I'm going to replace/rewrite this part in my library since the specification which I use already doesn't contain refs, but it will take more time than just adding this variable into parsed specification.

Here is the issue in case you want to track the progress - #35

manchenkoff commented 1 year ago

Closed, duplicates #35