REGnosys / rosetta-code-generators

Write code generators for any language, based on the rosetta DSL
Apache License 2.0
17 stars 33 forks source link

JSON schema generator does not generate the correct structure #289

Open dmostert-gresham opened 7 months ago

dmostert-gresham commented 7 months ago

Description

The JSON schema generator is generating the following structure for ContractualProduct:

{
  "$schema": [http://json-schema.org/draft-04/schema#](https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fjson-schema.org%2Fdraft-04%2Fschema&data=05%7C02%7Cdmostert%40greshamtech.com%7C6df732652fe74e50fefc08dc5ac9b8d9%7C4aed35c0c2db42c68c17efca15bfabfb%7C1%7C0%7C638485069669347732%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C0%7C%7C%7C&sdata=4tqcadyLIh%2BBvWd%2BEZe%2BsmvGZ5SoTLeCNmpn7oMNzMw%3D&reserved=0),
  "$anchor": "cdm.product.template",
  "type": "object",
  "title": "ContractualProduct",
  "description": " A class to specify the contractual products' economic terms, alongside their product identification and product taxonomy. The contractual product class is meant to be used across the pre-execution, execution and (as part of the Contract) post-execution lifecycle contexts.",
  "properties": {
    "economicTerms": {
      "description": "The economic terms associated with a contractual product, i.e. the set of features that are price-forming.",
      "$ref": "cdm-product-template-EconomicTerms.schema.json"
    },
    "productTaxonomy": {
      "description": "Specifies the product taxonomy, which is composed of a taxonomy value and a taxonomy source.",
      "type": "array",
      "items": {
        "$ref": "cdm-base-staticdata-asset-common-ProductTaxonomy.schema.json"
      },
      "minItems": 0
    },
    "productIdentifier": {
      "description": "Comprises an identifier and a source. The associated metadata key denotes the ability to associate a hash value to the ProductIdentifier instantiations for the purpose of model cross-referencing, in support of functionality such as the event effect and the lineage.",
      "type": "array",
      "items": {
        "$ref": "cdm-base-staticdata-asset-common-metafields-ReferenceWithMetaProductIdentifier.schema.json"
      },
      "minItems": 0
    }
  },
  "required": [
    "economicTerms"
  ]
}

This is made up of :

type ContractualProduct extends ProductBase: <" A class to specify the contractual products' economic terms, alongside their product identification and product taxonomy. The contractual product class is meant to be used across the pre-execution, execution and (as part of the Contract) post-execution lifecycle contexts.">
    [metadata key]
    [metadata template]

    economicTerms EconomicTerms (1..1) <"The economic terms associated with a contractual product, i.e. the set of features that are price-forming.">

    condition PrimaryAssetClass: <"Specifies that when nonStandardisedTerms are True that a primary asset class must be specified.">
        if economicTerms -> nonStandardisedTerms = True
        then productTaxonomy -> primaryAssetClass exists

and

type ProductBase: <"Serves as an abstract class to specify a product using a productIdentifier.">
    productTaxonomy ProductTaxonomy (0..*) <"Specifies the product taxonomy, which is composed of a taxonomy value and a taxonomy source.">
    productIdentifier ProductIdentifier (0..*) <"Comprises an identifier and a source. The associated metadata key denotes the ability to associate a hash value to the ProductIdentifier instantiations for the purpose of model cross-referencing, in support of functionality such as the event effect and the lineage.">
        [metadata address "pointsTo"=Observable->productIdentifier]

and

type ProductIdentifier: <"Comprises an identifier and a source. The associated metadata key denotes the ability to associate a hash value to the ProductIdentifier instantiations for the purpose of model cross-referencing, in support of functionality such as the event effect and the lineage.">
    [metadata key]
    identifier string (1..1) <"Provides an identifier associated with a specific product.  The identifier is unique within the public source specified in the source attribute.">
        [metadata scheme]
    source ProductIdTypeEnum (1..1) <"Defines the source of the identifier.">

Is this a regression?

No

Expected behaviour

The "identifier" and "source" child elements must also appear in the generated JSON schemas

Steps to reproduce

  1. Run the code generator on the DRR rosetta sources.

Screenshots

If applicable, add screenshots to help explain your problem.

🌍 Your Environment


-OS i.e. macOS Sonoma version 14.4.1
-IDE details, i.e IntelliJ IDEA 2024.1
-Maven version i.e. 3.6.3