Convert JSON to JSON Schema draft 4 compatible with Swagger 2.0

前端 未结 3 1449
南旧
南旧 2021-01-04 03:03

I\'ve been given some JSON files generated by a REST API with plenty of properties.

I\'ve created a Swagger 2.0 definition for this API and need to give it the corre

3条回答
  •  迷失自我
    2021-01-04 04:06

    I know there are some tools to convert JSON to JSON schemas but, if I’m not mistaken, Swagger only has $refs to other objects definitions thus only has one level

    You are mistaken. Swagger will respect any valid v4 JSON schema, as long as it only uses the supported subset.

    The Schema Object...is based on the JSON Schema Specification Draft 4 and uses a predefined subset of it. On top of this subset, there are extensions provided by this specification to allow for more complete documentation.

    It goes on to list the parts of JSON schema which are supported, and the bits which are not, and the bits which are extended by swagger.

提交回复
热议问题