Skip to content

Releases: accordproject/concerto-codegen

v3.13.0

06 Jun 18:47
1200c2c
Compare
Choose a tag to compare

What's Changed

  • fix(typescript) do not create unions for enums and fix imports by @dselman in #33

Full Changelog: v3.12.0...v3.13.0

v3.12.0

02 Jun 16:32
8f0cd19
Compare
Choose a tag to compare

What's Changed

Closes #29

  • Fixed bug where URI-escaped commas don't get unescaped.
  • Fixed error thrown by possibly undefined element.
  • Fixed typos.
  • Implemented handling of definitions with reference in body.
  • Implemented handling of definitions with freeform body.
  • Implemented handling of definitions with empty object ({}) freeform body.
  • Implemented handling of definitions with array in body.
  • Implemented handling of definitions with fixed element array in body.
  • Implemented handling of type unions.

Full Changelog: v3.11.1...v3.12.0

Handling of JSON Schema features that are nonexistent in Concerto

Definitions with freeform body

JSON Schema allows for definitions that are free from any validation constraints. In our case we map these definitions to a String scalar with @StringifiedJson decorator. This scalar is then referred to by concepts.

Example

This JSON Schema:

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "definitions": {
        "Foo": {
            "type": "object",
            "properties": {
                "bar": {
                    "$ref": "#/definitions/Bar"
                }
            },
            "required": [
                "bar"
            ]
        },
        "Bar": {}
    }
}

gets converted to:

namespace [email protected]

concept Foo {
  o Bar bar
}

@StringifiedJson
scalar Bar extends String

Definitions with array in body

There is no way to define a Concerto concept as an array. Instead, we convert the JSON Schema definition to a Concerto concept property, without a (or a reference to) a standalone concept.

Example

This JSON Schema:

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "definitions": {
        "Foo": {
            "type": "object",
            "properties": {
                "bar": {
                    "$ref": "#/definitions/Bar"
                }
            },
            "required": [
                "bar"
            ]
        },
        "Bar": {
            "type": "array",
            "items": {
                "type": "string"
            }
        }
    }
}

gets converted to:

namespace [email protected]

concept Foo {
  o String[] bar optional
}

Definitions with fixed element array in body

Using JSON Schema one can define an array with known element shapes. It's possible to define an array with a fixed number of elements, all of them with defined shapes, or with some defined shapes and the rest freeform. Those two cases are handled different in our inference.

If the array allows only known shapes, then we convert it to a Concerto concept with properties corresponding to the indexed elements.

Example

This JSON Schema:

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "definitions": {
        "Foo": {
            "type": "object",
            "properties": {
                "bar": {
                    "$ref": "#/definitions/Bar"
                }
            },
            "required": [
                "bar"
            ]
        },
        "Bar": {
            "type": "array",
            "minItems": 3,
            "maxItems": 3,
            "items": [
                {
                    "type": "object",
                    "properties": {
                        "name": {
                            "type": "string"
                        }
                    }
                },
                {
                    "type": "object",
                    "properties": {
                        "dob": {
                            "type": "string"
                        }
                    }
                },
                {
                    "type": "object",
                    "properties": {
                        "address": {
                            "type": "string"
                        }
                    }
                }
            ]
        }
    }
}

gets converted to:

namespace [email protected]

concept Foo {
  o definitions$_Bar bar optional
}

concept definitions$_Bar {
  o definitions$_Bar$_properties$_0 0
  o definitions$_Bar$_properties$_1 1
  o definitions$_Bar$_properties$_2 2
}

concept definitions$_Bar$_properties$_0 {
  o String name optional
}

concept definitions$_Bar$_properties$_1 {
  o String dob optional
}

concept definitions$_Bar$_properties$_2 {
  o String address optional
}

If the array allows not only known shapes, but a known or unknown number of freeform objects, then we simply convert it so an array of String scalars with @StringifiedJson decorator.

Example

This JSON Schema:

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "definitions": {
        "Foo": {
            "type": "object",
            "properties": {
                "bar": {
                    "$ref": "#/definitions/Bar"
                }
            },
            "required": [
                "bar"
            ]
        },
        "Bar": {
            "type": "array",
            "minItems": 3,
            "maxItems": 4,
            "items": [
                {
                    "type": "object",
                    "properties": {
                        "name": {
                            "type": "string"
                        }
                    }
                },
                {
                    "type": "object",
                    "properties": {
                        "dob": {
                            "type": "string"
                        }
                    }
                },
                {
                    "type": "object",
                    "properties": {
                        "address": {
                            "type": "string"
                        }
                    }
                }
            ]
        }
    }
}

gets converted to:

namespace [email protected]

concept Foo {
  @StringifiedJson
  o String bar optional
}

Union types

JSON Schema union types are unsupported by Concerto. When inferring they get converted to String types decorated by a @StringifiedUnionType decorator containing the stringified union types in its first argument.

Example

This JSON Schema:

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "definitions": {
        "Foo": {
            "type": "object",
            "properties": {
                "bar": {
                    "type": "array",
                    "items": {
                        "type": [
                            "number",
                            "boolean"
                        ]
                    }
                }
            },
            "required": [
                "bar"
            ]
        }
    }
}

gets converted to:

namespace [email protected]

concept Foo {
  @StringifiedUnionType("[number,boolean]")
  o String[] bar
}

v3.11.1

30 May 12:27
eedba26
Compare
Choose a tag to compare

What's Changed

  • chore(actions): publish v3.11.0 to npm by @github-actions in #26
  • fix(*): pascal casing fix to resolve fqn by @ragi-dayananda in #27

Full Changelog: v3.11.0...v3.11.1

v3.11.0

25 May 08:19
0478a8e
Compare
Choose a tag to compare

What's Changed

  • chore(actions): publish v3.10.0 to npm by @github-actions in #20
  • fix(*):fix concept name conflict with dependent namespaces by @ragi-dayananda in #23
  • fix(json schema): fix handling alternations and generating derivative definitions by @stefanblaginov in #25

Full Changelog: v3.10.0...v3.11.0

v3.10.0

23 May 10:06
9563f99
Compare
Choose a tag to compare

What's Changed

  • chore(actions): publish v3.9.1 to npm by @github-actions in #18
  • feat(*): String length validation for csharp,json generators by @ragi-dayananda in #19

Full Changelog: v3.9.1...v3.10.0

v3.9.1

19 May 08:32
eb6e1b5
Compare
Choose a tag to compare

What's Changed

  • chore(actions): publish v3.9.0 to npm by @github-actions in #14
  • chore(deps-dev): bump nunjucks from 3.2.3 to 3.2.4 by @dependabot in #3
  • fix(jsonschema): fix bug with inference from JSON Schema by @stefanblaginov in #17

New Contributors

Full Changelog: v3.9.0...v3.9.1

v3.9.0

02 May 13:03
840a45e
Compare
Choose a tag to compare

What's Changed

  • chore(actions): publish v3.8.0 to npm by @github-actions in #12
  • fix(tools): Add dummy classes to dotnet gen models to avoid compilation errors by @ragi-dayananda in #13

New Contributors

  • @github-actions made their first contribution in #12
  • @ragi-dayananda made their first contribution in #13

Full Changelog: v3.8.0...v3.9.0

v3.8.0

27 Apr 07:54
2435e01
Compare
Choose a tag to compare

What's Changed

Full Changelog: https://github.com/accordproject/concerto-codegen/commits/v3.8.0