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

attention points while converting draft-04 to draft-07

Aperta
#6 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
TypeScript
Stelle
28
Fork
4
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.