Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attention points while converting draft-04 to draft-07 #6

Open
seriousme opened this issue May 14, 2021 · 3 comments · Fixed by NeuraLegion/json-schema-migrate#1
Open

Comments

@seriousme
Copy link

Hi,

I migrated the swagger v2.0 spec from draft04 to draft07 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:

  "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:

  "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:
"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:

"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

mvhysko added a commit to mvhysko/json-schema-migrate that referenced this issue Jun 15, 2021
mvhysko added a commit to mvhysko/json-schema-migrate that referenced this issue Jun 15, 2021
mvhysko added a commit to mvhysko/json-schema-migrate that referenced this issue Jun 15, 2021
derevnjuk pushed a commit to NeuraLegion/json-schema-migrate that referenced this issue Jun 15, 2021
mvhysko added a commit to mvhysko/json-schema-migrate that referenced this issue Jun 15, 2021
mvhysko added a commit to mvhysko/json-schema-migrate that referenced this issue Jun 15, 2021
mvhysko added a commit to mvhysko/json-schema-migrate that referenced this issue Jun 16, 2021
mvhysko added a commit to mvhysko/json-schema-migrate that referenced this issue Jun 16, 2021
mvhysko added a commit to mvhysko/json-schema-migrate that referenced this issue Jun 16, 2021
@davedoesdev
Copy link

I also had to convert "media": {"binaryEncoding": "..."} to "contentEncoding", per https://json-schema.org/draft-07/json-schema-release-notes.html

@davedoesdev
Copy link

davedoesdev commented Jan 13, 2022

And added "type": "object" alongside "additionalProperties"

@epoberezkin
Copy link
Member

I also had to convert "media": {"binaryEncoding": "..."} to "contentEncoding"

that may be added

And added "type": "object" alongside "additionalProperties"

this changes validation result, so it should not be added. In JSON Schema "type" is optional, and schema without "type" simply allows non-objects. While it's often indicates a mistake that Ajv strict mode would catch, this is not something this tool should change - missing type can be intentional and completely valid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

3 participants