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

attention points while converting draft-04 to draft-07

Open
#6 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
28
Forks
4
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.