ajv-validator / ajv-validator/json-schema-migrate
attention points while converting draft-04 to draft-07
- 主要语言
- TypeScript
- 星标
- 28
- 派生
- 4
- PR 合并指标
- 30 天内没有已合并 PR
描述
Hi,
I migrated the swagger v2.0 spec from [draft04](https://github.com/seriousme/openapi-schema-validator/blob/master/schemas.orig/v2.0/schema.json) to [draft07](https://github.com/seriousme/openapi-schema-validator/blob/master/schemas/v2.0/schema.json) and although the tool helped a lot (thanks for that !) I ran into a few issues I thought I'd share so maybe other people can benefit.
The swagger 2.0 spec contained a number of refs to the draft04 schema itself,e.g:
```json
"exclusiveMinimum": {
"$ref": "http://json-schema.org/draft-04/schema#/properties/exclusiveMinimum"
},
"maxLength": {
"$ref": "http://json-schema.org/draft-04/schema#/definitions/positiveInteger"
},
```
I changed these by hand to:
```json
"exclusiveMinimum": {
"$ref": "http://json-schema.org/draft-07/schema#/properties/exclusiveMinimum"
},
"maxLength": {
"$ref": "http://json-schema.org/draft-07/schema#/definitions/nonNegativeInteger"
},
```
It would be nice if the tool would support this.
( "positiveInteger" being replaced by "nonNegativeInteger" was quite easy to spot ;-))
The second one took me a bit more time to figure out:
- json-schema-migrate incorrectly turned:
```json
"parametersList": {
"type": "array",
"description": "The parameters needed to send a valid API call.",
"additionalItems": false,
"items": {
"oneOf": [
{
"$ref": "#/definitions/parameter"
},
{
"$ref": "#/definitions/jsonReference"
}
]
},
"uniqueItems": true
},
```
into:
```json
"parametersList": {
"type": "array",
"description": "The parameters needed to send a valid API call.",
"additionalItems": false,
"items": [{
"oneOf": [
{
"$ref": "#/definitions/parameter"
},
{
"$ref": "#/definitions/jsonReference"
}
]
}],
"uniqueItems": true
},
```
which resulted in an error that the parameter list could only have 1 item. Removing the square brackets around the object in "items" again solved this one.
Thanks again,
Hans
贡献指南
这个仓库没有索引到贡献指南
评估
这个 Issue 还没有评估数据。