openapi-schema-to-json-schema icon indicating copy to clipboard operation
openapi-schema-to-json-schema copied to clipboard

feat: adds option to delete Swagger Extension properties in schema objects.

Open Shockolate opened this issue 6 years ago • 4 comments

Deletes unsupported Swagger Extensions properties when converting to JSON Schema.

Shockolate avatar Aug 14 '18 03:08 Shockolate

Just as a note: JSON schema v4 does allow properties which are not valid JSON schema v4 keywords (such as OpenAPI's x-* properties): https://tools.ietf.org/html/draft-zyp-json-schema-04#section-3.2

But it could be useful for people that want to opt-in to get rid of them!

ehmicky avatar Aug 16 '18 07:08 ehmicky

Oh! I did not know that, @ehmicky , thanks.

I'll leave it up to @mikunn to merge or deny.

Shockolate avatar Aug 16 '18 16:08 Shockolate

I think it would still be useful as an opt-in for users that want cleaner JSON schemas.

ehmicky avatar Aug 16 '18 16:08 ehmicky

I merged this in with my fork and it was throwing up errors:

    ✖ should be equivalent
    -----------------------
      operator: deepEqual
      expected: |-
        { $schema: 'http://json-schema.org/draft-04/schema#', type: 'object', properties: { boolProperty: { type: 'boolean', 'x-extension-property': true }, 'x-extension-property': true }, 'x-extension-property': true }
      actual: |-
        { type: 'object', properties: { boolProperty: { type: 'boolean', 'x-extension-property': true } }, 'x-extension-property': true, $schema: 'http://json-schema.org/draft-04/schema#' }
      at: Test.<anonymous> (/Users/phil/src/openapi-contrib/openapi-schema-to-json-schema/test/extension_properties.test.js:64:10)
      stack: |-
  Error: should be equivalent

fancy fixing it and making a new PR over here? https://github.com/openapi-contrib/openapi-schema-to-json-schema

philsturgeon avatar Jan 17 '20 22:01 philsturgeon