datacontract / datacontract-cli

CLI to manage your datacontract.yaml files
https://cli.datacontract.com
Other
437 stars 85 forks source link

JSON Schema Import: references and allof/oneof/anyof #202

Closed simonharrer closed 2 months ago

simonharrer commented 4 months ago
          Thanks for this PR! Looks fine, but let's exclude the definitions here for now as this needs discussion.
  1. The reference mechanism of JSON schema differs from Data Contract Specification.
  2. The Data Contract Specification currently does not support the allOf/oneOf/anyOf logic of JSON schema.

Let's discuss each of those separately.

Regarding 1: Without the allOf/oneOf/anyOf logic, we could implement an import that makes use of the definitions in DCS. We could use the $ref mechanism to link to the referenced definition. No problem here. The difference, however, is that one can override the fields (in JSON schema, you cannot). But this should not be an issue here, but more an issue when you'd do an export to JSON schema when using $ref.

Regarding 2: We could support this with config options, e.g., like this:

models:
  my-model:
    config:
      jsonSchemaAllOf:
        - ref1
        - ref2

Originally posted by @simonharrer in https://github.com/datacontract/datacontract-cli/issues/201#issuecomment-2112492939

jochenchrist commented 2 months ago

Ticket is stale, please reopen if this issue is relevant for you or you want to work on an solution.