thim81 / openapi-format

Format an OpenAPI document by ordering, formatting and filtering fields.
MIT License
77 stars 14 forks source link

ConvertTo: downgrade 3.1 to 3.0 #83

Open gcacars opened 9 months ago

gcacars commented 9 months ago

Hi! I tries to use this package to downgrade a 3.1 spec file to a 3.0 one. That result in success, but the file is still in 3.1. I doing something wrong or this is not supported?

npx openapi-format openapi.yaml -o openapi3.json --convertTo "3"
==============================================================================
OpenAPI-Format CLI settings:
- Sort file:            (defaultSort.json)
- Input file:           openapi.yaml
- Output file:          openapi3.json
==============================================================================
✅  OpenAPI formatted successfully
==============================================================================
thim81 commented 9 months ago

hi @gcacars

The expected usage was foreseen to only upgrade from 3.0 to 3.1, which explains the fixed version number of 3.1.

Is it ok for you that I investigate this further, and next extend the convertTo option to respect upgrading AND downgrading?

gcacars commented 9 months ago

Yes, for sure @thim81. The reason I need this is because I'm developing OpenAPI spec in version 3.1 as this allows me to distribute schemas across different files/Internet. But many services and other tools like openapi-validator-middleware only work with specification version 3.0. :/

paul-barton commented 1 week ago

Give https://github.com/apiture/openapi-down-convert a try, I had to do the same and it worked pretty well out of the box, there were a few things I had to cleanup, but not much at all.

npx @apiture/openapi-down-convert --input .\openapi.yml --output .\openapi-3.0.yml