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

Data object "API" broken moving from 0.118.0 to 0.124.0 #939

Closed
andrewrowe-wk opened this issue Apr 15, 2024 · 2 comments
Closed

Data object "API" broken moving from 0.118.0 to 0.124.0 #939

andrewrowe-wk opened this issue Apr 15, 2024 · 2 comments

Comments

@andrewrowe-wk
Copy link

Hello! Great library and very useful for me and my team. Thank you for taking the time to write and maintain it.

When updating from 0.118.0 to 0.124.0 some of our consuming code broke and I am looking for the correct remediation. For example we had some code that looked like the following:

func getType(p *openapi3.Parameter) string {
	return p.Schema.Value.Type
}

This is no longer valid with the new structure of the Schema object. When investigating, I found I could do something like this:

func getType(p *openapi3.Parameter) string {
	return p.Schema.Value.Type.Slice()[0]
}

I don't know if getting the Type at index 0 is correct, but looking at the MarshalYaml() makes me think that's the right thing to do. I see JSON schemas supports multiple types. I did not realize this. The schemas we are parsing, for now, only use a single type.

@sebhoss
Copy link

sebhoss commented Apr 16, 2024

I think that's correct because Type.Is uses the type at index 0 as well. At least that's what I've been using in my PR at metio/terraform-provider-k8s#120 to update to the latest version.

@AnatolyRugalev
Copy link
Contributor

@andrewrowe-wk I believe it should be OK for you to take the first item of the slice. I think this issue can be closed

@fenollp fenollp closed this as completed Jul 5, 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

No branches or pull requests

4 participants