kin-openapi icon indicating copy to clipboard operation
kin-openapi copied to clipboard

Load yaml file for openapi2

Open ilteoood opened this issue 2 years ago • 1 comments

Hi guys, thank you so much for this awesome library.

I'm opening this issue just to ask a question: is a way to load an openapi2 specification from a yaml file?

Currently I'm:

  • loading it;
  • converting it to JSON;
  • using the UnmarshalJSON method to fill the openapi2.T object.

Is there a better way? Because the convertion yaml 2 json is a little bit heavy for large specifications.

ilteoood avatar Mar 30 '22 15:03 ilteoood

Have a look at https://github.com/ghodss/yaml

And if you have the time I'd happily review a pull request that solves this for others, be it only an example.

fenollp avatar Apr 02 '22 15:04 fenollp

See https://github.com/getkin/kin-openapi/blob/0a4abfc91ea65332d247587bda355ab2ed461ef0/openapi2/openapi2_test.go#L45

fenollp avatar Oct 28 '22 10:10 fenollp