How to generate JSON-Schema from Swagger API Declaration

前端 未结 4 1077
伪装坚强ぢ
伪装坚强ぢ 2021-01-29 21:15

I have Swagger API Declaration for services using Swagger v 1.2

My original feeling about Swagger was, that it is very close to JSON Schema (Draft 3 and lately Draft 4)

4条回答
  •  甜味超标
    2021-01-29 21:40

    I've had some success doing it like this:

    swagger.yaml -> proto -> jsonschema

    I used openapi2proto to generate proto files from Swagger yaml, then protoc-gen-jsonschema to generate the JSONSchemas from that. It's good enough to get a typed JSONSchema, but proto3 doesn't support "required" types so you miss out on this.

提交回复
热议问题