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

Schema dependencies should be iterated #79

Closed
jonaslagoni opened this issue Feb 19, 2021 · 4 comments · Fixed by #249
Closed

Schema dependencies should be iterated #79

jonaslagoni opened this issue Feb 19, 2021 · 4 comments · Fixed by #249
Labels
enhancement New feature or request released

Comments

@jonaslagoni
Copy link
Sponsor Member

Reason/Context

Currently we do not iterate schema dependencies. We should iterate them and combine properties/items/types etc together.

{
  "type": "object",
  "properties": {
    "name": { "type": "string" },
    "credit_card": { "type": "number" }
  },
  "required": ["name"],
  "dependencies": {
    "credit_card": {
      "properties": {
        "billing_address": { "type": "string" }
      },
      "required": ["billing_address"]
    }
  }
}

should merge it together to give the model:

{
  "type": "object",
  "properties": {
    "name": { "type": "string" },
    "credit_card": { "type": "number" },
    "billing_address": { "type": "string" }
  },
  "required": ["name"]
}

Reason why billing_address is not added to the list of required properties, is that it is a runtime requirement that we cannot do anything about when rendering the model.

see more here: http://json-schema.org/understanding-json-schema/reference/object.html#schema-dependencies

@jonaslagoni jonaslagoni added the enhancement New feature or request label Feb 19, 2021
@magicmatatjahu
Copy link
Member

magicmatatjahu commented Feb 22, 2021

@jonaslagoni Please have in mind that final schema is only valid, when you have defined credit_card - like in example in linked web, so I think that there we have an union type with given schema:

{
  oneOf: [
    {
      "type": "object",
      "properties": {
        "name": { "type": "string" },
        "credit_card": { "type": "number" },
        "billing_address": { "type": "string" }
      },
      "required": ["name", "credit_card", "billing_address"]
    },
    {
      "type": "object",
      "properties": {
        "name": { "type": "string" }
      },
      "required": ["name"]
    }
  ]
}

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale because it has not had recent activity 😴
It will be closed in 60 days if no further activity occurs. To unstale this issue, add a comment with detailed explanation.
Thank you for your contributions ❤️

@github-actions github-actions bot added the stale label Apr 24, 2021
@jonaslagoni jonaslagoni added this to the Improvement iteration milestone Jun 9, 2021
@jonaslagoni
Copy link
Sponsor Member Author

jonaslagoni commented Jun 9, 2021

@jonaslagoni Please have in mind that final schema is only valid, when you have defined credit_card - like in example in linked web, so I think that there we have an union type with given schema:

As we have another issue defining this problem, this union type will not be the focus in this issue.

@asyncapi-bot
Copy link
Contributor

🎉 This issue has been resolved in version 0.10.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants