Skip to content

Conversation

@reuvenharrison
Copy link
Contributor

@reuvenharrison reuvenharrison commented Aug 25, 2024

This PR adds the ability to correlate OpenAPI components with the location in the originating YAML spec.
Here's a summary of the changes required to achieve this:

  1. Modify yaml.v3 to add line and column numbers of each YAML element to the unmarshaled interfaces (see https://github.com/oasdiff/yaml3)
  2. Modify invopop/yaml with a new function: UnmarshalWithOrigin (see https://github.com/oasdiff/yaml)
  3. Modify this repo to add an Origin struct to OpenAPI components. This requires changes to the UnmarshalJSON functions and, in some cases, replacing native types, like map[string]string, by dedicated types that include the original native type and an Origin member.

This PR addresses issue #986

Follow up tasks to be addressed by future PRs:

  • Add origin to more elements, namely Components and some types that are unmarshalled with unmarshalStringMapP or unmarshalStringMap
  • Merge changes in yaml.v3 and invopop/yaml back to original repos and remove replace directives from go.mod
  • Enhance origin to include end line and column and YAML comments as proposed by @fenollp

@reuvenharrison reuvenharrison marked this pull request as ready for review September 21, 2024 07:56
@reuvenharrison reuvenharrison changed the title Correlate OpenAPI components with their location in the originating YAML spec Add reference to originating locations in YAML specs - step 1 Sep 21, 2024
Copy link
Collaborator

@fenollp fenollp left a comment

Choose a reason for hiding this comment

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

A few minor edits otherwise LGTM

Jille and others added 7 commits October 16, 2024 13:58
* Add github.com/pb33f/libopenapi

it looks like a reasonable alternative

* Update README.md

---------

Co-authored-by: Pierre Fenoll <[email protected]>
* fix: issue unmarshalling when discriminator field is set in openapi2.0

* revert original approach

* update with different approach

* Revert "update with different approach"

This reverts commit 2db2b39.

* v2 schema with discriminator field set as string

* update ref link and comment

* run docs.sh
@fenollp fenollp changed the title Add reference to originating locations in YAML specs - step 1 openapi3: reference originating locations in YAML specs - step 1 Oct 21, 2024
@fenollp fenollp merged commit c333b34 into getkin:master Oct 21, 2024
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.

7 participants