ajv-validator / ajv-validator/json-schema-migrate

attention points while converting draft-04 to draft-07

オープン
#6 コメント 3 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
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 はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。