Skip to content

openapi3: add support for extensions on the few types left#763

Merged
fenollp merged 1 commit intogetkin:masterfrom
fenollp:issue687
Nov 28, 2023
Merged

openapi3: add support for extensions on the few types left#763
fenollp merged 1 commit intogetkin:masterfrom
fenollp:issue687

Conversation

@fenollp
Copy link
Copy Markdown
Collaborator

@fenollp fenollp commented Feb 6, 2023

Signed-off-by: Pierre Fenoll pierrefenoll@gmail.com

@fenollp fenollp force-pushed the issue687 branch 2 times, most recently from 7ecc3c1 to 4485967 Compare September 5, 2023 16:42
@fenollp fenollp force-pushed the issue687 branch 3 times, most recently from 4263a8c to effade4 Compare November 26, 2023 00:52
@fenollp fenollp force-pushed the issue687 branch 4 times, most recently from d746896 to 58c310d Compare November 26, 2023 21:49
@fenollp fenollp marked this pull request as ready for review November 26, 2023 23:28
@fenollp fenollp force-pushed the issue687 branch 6 times, most recently from 0bb0935 to 90365e5 Compare November 28, 2023 09:20
Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
@fenollp fenollp merged commit 6740cd2 into getkin:master Nov 28, 2023
@fenollp fenollp deleted the issue687 branch November 28, 2023 20:35
@mcblair
Copy link
Copy Markdown

mcblair commented Dec 7, 2023

This shipped in v0.122.0 and when we upgraded to it from v0.121.0 resulted in a silent change in behaviors when marshalling to yaml; paths: {}. I have confirmed that prior to marshalling, the field has a pointer to expected value. I also have confirmed that T.MarshalJSON() behaves as expected, without any loss of T.Paths. We were still using yaml.v2 but I did confirm that the problem is reproducible with yaml.v3.

Reproduce it by running the following code first with v0.121.0 and then with v0.122.0.

oas := openapi3.NewLoader()
existingDoc, err := oas.LoadFromFile("./spec/reference/example.yaml")
if err != nil {
	return fmt.Errorf("failed to load file: %s with err: %s", s.FileName, err.Error())
}
// `existingDoc.Paths` looks good when introspected with debugger.

err = existingDoc.Validate(ctx)
if err != nil {
	return fmt.Errorf("failed to validate file: %s with err: %s", s.FileName, err.Error())
}

marshalledJson, err := existingDoc.MarshalJSON() // Looks as expected.
if err != nil {
	return err
}

marshalledYaml, err := yaml.Marshal(&existingDoc) // Loss of `T.Paths`
if err != nil {
	return err
}

@sonu27
Copy link
Copy Markdown
Contributor

sonu27 commented Feb 2, 2024

This was a big breaking change.
I can no longer loop on path items, which were made private, and set directly.
Could m map[string]*PathItem be made public?

@fenollp
Copy link
Copy Markdown
Collaborator Author

fenollp commented Feb 3, 2024

@sonu27
Copy link
Copy Markdown
Contributor

sonu27 commented Feb 3, 2024

@sonu27 https://pkg.go.dev/github.com/getkin/kin-openapi/openapi3#Paths.Map

I'm using that. The problem is marshalling of yaml. Which I believe there is another bug for

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.

Responses object doesn't support extensions

4 participants