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

YAML declarations in SchemaProps struct #164

Closed
alexartwww opened this issue Mar 18, 2023 · 1 comment · Fixed by #185
Closed

YAML declarations in SchemaProps struct #164

alexartwww opened this issue Mar 18, 2023 · 1 comment · Fixed by #185
Labels

Comments

@alexartwww
Copy link

alexartwww commented Mar 18, 2023

This code won't work because type SchemaProps struct does not have yaml declarations, why?

schema := new(spec.Schema)
errYamlUnmarshal := yaml.Unmarshal(yamlBytes, schema)
if errYamlUnmarshal != nil {
	return errYamlUnmarshal
}

I'm working with example https://pkg.go.dev/github.com/go-openapi/validate#example-AgainstSchema
And cannot load yaml file.

@fredbi
Copy link
Member

fredbi commented Nov 30, 2023

The Spec object does not unmarshal YAML natively, only JSON.
In order to load a YAML document into a swagger spec, you need to use the loaders provided by github.com/go-openapi/loads

Please take a look at the example there: https://pkg.go.dev/github.com/go-openapi/loads#example-Spec

fredbi added a commit to fredbi/spec that referenced this issue Jan 9, 2024
These discussion threads are valuable, but no longer active.

* fixes go-openapi#164
* fixes go-openapi#23

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
fredbi added a commit that referenced this issue Jan 9, 2024
These discussion threads are valuable, but no longer active.

* fixes #164
* fixes #23

Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants