paperclip-rs / paperclip

WIP OpenAPI tooling for Rust.
Apache License 2.0
876 stars 117 forks source link

Paperclip CLI fails on openapi v3: YAML error: missing field `swagger` #476

Open jayvdb opened 1 year ago

jayvdb commented 1 year ago

I built paperclip master CLI with

> cargo install --path . --features cli,v3,codegen,chrono,url,uuid

(Did I miss a feature needed?)

When I use it with a v3 spec, I get

> paperclip --out models_paperclip my_spec.yaml --api v3
YAML error: missing field `swagger` 

If I convert the same spec to v2, using https://github.com/LucyBot-Inc/api-spec-converter, it works perfectly

> api-spec-converter my_spec.yaml --from=openapi_3 --to=swagger_2 > my_spec_v2.yaml
> paperclip --out models_paperclip my_spec_v2.yaml --api v2
tiagolobocastro commented 1 year ago

This is something I'm looking into but V3 is not supported for client side code generation as things stand.

jayvdb commented 1 year ago

If it isnt easy to fix, perhaps the docs / error message can improved to indicate only v2 is supported at present.

tiagolobocastro commented 1 year ago

I don't know what the CLI is doing but the "--api v3" should have triggered some kind of not supported error, but I wonder if it's because the spec yaml is being provided before the --api, and it's always parsed as v2 which will fail since your spec is v3, so we never get to processing the "--api v3" argument.

jayvdb commented 1 year ago

paperclip --out models_paperclip --api v3 my_spec.yaml and paperclip --api v3 --out models_paperclip my_spec.yaml have the same error.