Skip to content

Releases: astahmer/openapi-zod-client

openapi-zod-client@1.11.1

22 Sep 20:07
Compare
Choose a tag to compare

Patch Changes

  • 536a541 Thanks @astahmer! - Thanks @mayorandrew !


    OpenAPI 3.0.3 Data Types are defined by JSON Schema Specification Wright Draft 00.

    However, the specification mentions that "null is not supported as a type" and the nullable keyword should be used instead. While it is a valid solution in most cases, it is not possible to use nullable together with $ref. One possible workaround is to define a Null schema and use it in combination with oneOf, like so:

    {
        "oneOf": [
            { "$ref": "#/components/schemas/MySchema" },
            {
                "type": "string",
                "enum": [null],
                "nullable": true
            }
        ]
    }

    It may look contradictory, but according to the enum section of JSON Schema Validation Wright Draft 00:

    The value of this keyword MUST be an array. This array SHOULD have
    at least one element. Elements in the array SHOULD be unique.

    Elements in the array MAY be of any type, including null.

    An instance validates successfully against this keyword if its value
    is equal to one of the elements in this keyword's array value.

    This means that null is a possible value for the "enum" validation of "type" "string".

    This schema also passes the swagger-cli validate check.

    The openapi-zod-client library currently crashes when generating a TypeScript type for this construct. Additionally, the generated zod schemas are not correct when using a null value in "enum" along with other values. This PR fixes that.

    #227

openapi-zod-client@1.11.0

02 Sep 21:02
Compare
Choose a tag to compare

Minor Changes

  • #221 5e55304 Thanks @craigmiller160! - Added the "all readonly" feature, which allows for generating schemas & types with all arrays and object properties set to readonly.

openapi-zod-client@1.10.8

22 Aug 13:25
Compare
Choose a tag to compare

Patch Changes

  • #219 114e809 Thanks @PeterMK85! - Handlebars helper toCamelCase should not touch the string if it's already in camel case.

openapi-zod-client@1.10.7

18 Aug 22:05
Compare
Choose a tag to compare

Patch Changes

  • #212 63c32a0 Thanks @eli0shin! - Limit --export-types to object types to prevent type errors from zod validation methods like .min

openapi-zod-client@1.10.6

18 Aug 17:32
Compare
Choose a tag to compare

Patch Changes

  • #210 675a132 Thanks @eli0shin! - Support nullable for array of types, oneOf, anyOf, and allOf in generated typescript types

openapi-zod-client@1.10.5

18 Aug 08:24
Compare
Choose a tag to compare

Patch Changes

openapi-zod-client@1.10.4

17 Aug 14:10
Compare
Choose a tag to compare

Patch Changes

openapi-zod-client@1.10.3

16 Aug 14:12
Compare
Choose a tag to compare

Patch Changes

openapi-zod-client@1.10.2

30 Jul 23:21
Compare
Choose a tag to compare

Patch Changes

openapi-zod-client@1.10.1

30 Jul 22:51
Compare
Choose a tag to compare

Patch Changes