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 Schema output is not working for Scalar Arrays #745

Closed
KrishnaPG opened this issue Oct 23, 2023 · 0 comments · Fixed by #746
Closed

JSON Schema output is not working for Scalar Arrays #745

KrishnaPG opened this issue Oct 23, 2023 · 0 comments · Fixed by #746

Comments

@KrishnaPG
Copy link
Contributor

Bug Report 🐛 The JSON Schema generated from a concerto model is incorrect for scalar array types.

Consider the below model:

     scalar SSN extends String default="000-00-0000" regex=/\d{3}-\d{2}-\d{4}/
      concept Product identified by sku
      {
          o Double d1
          o Double[] d2
          o SSN[] ssn
          o SSN ssn2
      }

Generating a JSONSchema for the above works fine for all except the SSN[] type.

    "[email protected]": {
      "title": "Product",
      "description": "An instance of [email protected]",
      "type": "object",
      "properties": {
        "$class": {
          "type": "string",
          "default": "[email protected]",
          "pattern": "^catalog@1\\.0\\.0\\.Product$",
          "description": "The class identifier for [email protected]"
        },
        "d1": {
          "type": "number"
        },
        "d2": {
          "type": "array",
          "items": {
            "type": "number"
          }
        },
        "ssn": {
          "default": "000-00-0000",
          "type": "string",
          "pattern": "\\d{3}-\\d{2}-\\d{4}"
        },
        "ssn2": {
          "default": "000-00-0000",
          "type": "string",
          "pattern": "\\d{3}-\\d{2}-\\d{4}"
        }
      },
      "required": [
        "$class",
        "d1",
        "d2",
        "ssn",
        "ssn2"
      ]
    },

Both SSN and SSN[] types are generated as string and string array in SSN[] case.

Expected Behavior

The Scalar Array types should be generated as array types correctly in the JSON Schema output.

Current Behavior

Sclar array is generated as scalar type without the array modifier.

Context (Environment)

"@accordproject/concerto-codegen": "^3.16.2",
"@accordproject/concerto-core": "^3.13.0",
"@apidevtools/json-schema-ref-parser": "^11.1.0",
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

Successfully merging a pull request may close this issue.

1 participant