Dorthu / openapi3

A Python3 OpenAPI 3 Spec Parser
BSD 3-Clause "New" or "Revised" License
118 stars 47 forks source link

Support OpenAPI 3.1.0 extended Reference objects #93

Closed Dorthu closed 1 year ago

Dorthu commented 1 year ago

Closes #61

In OpenAPI 3.1.0, the Reference Object gained two new attributes, summary and description. These attributes are optional, and #61 indicated that they were preventing this library from parsing specs where they were present.

Based on the standard, these fields are ignored unless the referenced type has a like-named field; in that case only, the value in the Reference Object's fields are used in place of that values in the like-named fields of the object it references. For example, in this partial spec:

paths:
  /example:
    $ref: '#/components/pathItems/example'
    summary: Override
components:
  pathItems:
    example:
      summary: Original

The value of paths./example.summary should be Override, not the referenced object's value of Original.

Along the way, I discovered that I didn't have support of pathItems or referencing the Path type either, and implementing this override behavior required some fancy proxying of referenced objects to ensure that the original values were not overridden.

The tests pass, and I did some manual testing as well, but I will be seeking review of this change, and will be making it a major release as well.