Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from Nov 28, 2023

Conversation

fenollp
Copy link
Collaborator

@fenollp fenollp commented Feb 6, 2023

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

openapi3/loader.go Fixed Show fixed Hide fixed
openapi3/callback.go Fixed Show fixed Hide fixed
openapi3/operation.go Outdated Show resolved Hide resolved
openapi3/paths.go Outdated Show resolved Hide resolved
openapi3/paths.go Outdated Show resolved Hide resolved
openapi3/response.go Outdated Show resolved Hide resolved
openapi3/refs_test.go Outdated Show resolved Hide resolved
openapi3/loader.go Outdated Show resolved Hide resolved
openapi3/loader.go Outdated Show resolved Hide resolved
@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
openapi3/response.go Outdated Show resolved Hide resolved
Signed-off-by: Pierre Fenoll <pierrefenoll@gmail.com>
@fenollp fenollp merged commit 6740cd2 into getkin:master Nov 28, 2023
7 checks passed
@fenollp fenollp deleted the issue687 branch November 28, 2023 20:35
@mcblair
Copy link

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
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
Collaborator Author

fenollp commented Feb 3, 2024

@sonu27
Copy link
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
3 participants