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

JSON compatibility check for schemaDependencies - Object #1406

Closed
hhkkxxx133 opened this issue Apr 5, 2021 · 2 comments
Closed

JSON compatibility check for schemaDependencies - Object #1406

hhkkxxx133 opened this issue Apr 5, 2021 · 2 comments

Comments

@hhkkxxx133
Copy link
Contributor

Hello,

I am testing the JSON compatibility check for the object. There are several test cases for schemaDependencies of object type that are incorrect. From the code, it looks like one diff type compatibility is setting wrong: link

Let me know what do you think!

Tests:

  1. should be forward compatible when adding schema dependencies
"original": {
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "name": {"type": "string"},
    "address": {"type": "string"},
    "postal_code": {"type": "number"}
  },
  "required": ["name"]
},
"updated": {
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "name": {"type": "string"},
    "address": {"type": "string"},
    "postal_code": {"type": "number"}
  },
  "required": ["name"],
  "dependencies": {
    "address": {"properties": {"city": { "type": "string" }}}
  }
}
  1. should be backward compatible when removing schema dependencies
"original": {
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "name": {"type": "string"},
    "address": {"type": "string"},
    "postal_code": {"type":  "number"}
  },
  "required": ["name"],
  "dependencies": {
    "address": {"properties": {"city": { "type": "string" }}}
  }
},
"updated": {
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "name": {"type": "string"},
    "address": {"type": "string"},
    "postal_code": {"type":  "number"}
  },
  "required": ["name"]
}
  1. should be forward compatible when schema dependencies key members are added
"original": {
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "name": {"type": "string"},
    "address": {"type": "string"},
    "postal_code": {"type":  "number"}
  },
  "required": ["name"],
  "dependencies": {
    "address": {"properties": {"city": { "type": "string"}}}
  }
},
"updated": {
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "name": {"type": "string"},
    "address": {"type": "string"},
    "postal_code": {"type":  "number"}
  },
  "required": ["name"],
  "dependencies": {
    "address": {"properties": {"city": { "type": "string"}}},
    "postal_code": {"properties": {"country": { "type": "string"}}}
  }
}
  1. should be backward compatible when schema dependencies key members are removed
"original": {
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "name": {"type": "string"},
    "address": {"type": "string"},
    "postal_code": {"type":  "number"}
  },
  "required": ["name"],
  "dependencies": {
    "address": {"properties": {"city": { "type": "string"}}},
    "postal_code": {"required": ["address"]}
  }
},
"updated": {
  "$schema": "http://json-schema.org/draft-07/schema#",
  "type": "object",
  "properties": {
    "name": {"type": "string"},
    "address": {"type": "string"},
    "postal_code": {"type":  "number"}
  },
  "required": ["name"],
  "dependencies": {
    "address": {"properties": {"city": { "type": "string"}}}
  }
}
@hhkkxxx133
Copy link
Contributor Author

@jsenko Can you review this issue?

@jsenko
Copy link
Member

jsenko commented Apr 14, 2021

Hi @hhkkxxx133 , I think you're right, the OBJECT_TYPE_SCHEMA_DEPENDENCIES_CHANGED diff type should be backwards compatible, otherwise the OBJECT_TYPE_SCHEMA_DEPENDENCIES_MEMBER_REMOVED does not make sense.

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

No branches or pull requests

2 participants