Skip to content

Default values from schema not passed through codegenΒ #34

@0237h

Description

@0237h

Hi,

Seems like when applying default values to some parameters in the OpenAPI spec, those defaults are not carried over in the codegen. This could be useful especially for Zod, etc. when parsing the resulting objects to provide the default value.

Example

"parameters": [
  {
    "name": "test_no_default",
    "in": "query",
    "schema": {
      "type": "string"
    }
  },
  {
    "name": "test_with_default",
    "in": "query",
    "schema": {
      "type": "string",
      "default": "hello world"
    }
  }
]

will generate

parameters: z.object({
  query: z.object({
    test_no_default: z.string().optional(),
    test_with_default: z.string().optional(),
  }),
})

instead of

parameters: z.object({
  query: z.object({
    test_no_default: z.string().optional(),
    test_with_default: z.string().optional().default("hello world"),
  }),
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions