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

Lack of default and exmaple properties in SDK schema #1460

Open
pboguslawski opened this issue Mar 23, 2023 · 3 comments
Open

Lack of default and exmaple properties in SDK schema #1460

pboguslawski opened this issue Mar 23, 2023 · 3 comments
Assignees

Comments

@pboguslawski
Copy link

Describe the bug
For OpenAPI type schema

 "MyNumber": {
    "minimum": 1,
    "type": "integer",
    "description": "My number.",
    "default": 1,
    "example": 2
   },

openapi-typescript-codegen --exportSchemas true does not generate default nor example properties in SDK schema (schemas/$MyNumber.ts):

export const $MyNumber = {
    type: 'number',
    description: `My number.`,
    minimum: 1,
} as const;

Schema should include both (expecially default that may be useful for clients).

@vanch3d
Copy link

vanch3d commented Jun 1, 2023

Thanks for a great tool overall!
I'm seconding this issue. I've been using the --exportSchemas to try and get values to populate forms and client-side validation and I'm missing a few of them:

components:
  schemas:
     MyObject:
      type: object
      properties:
        clientId:
          type: string
          format: string
          description: client identifier 
          example: my-example-client-id
          nullable: true
          pattern: "^[a-zA-Z0-9 -_]*"
        keepAlive:
          type: integer
          format: int32
          default: 240
          description: keepAlive
          maximum: 65535
          minimum: 0

and I'm getting this:

export const $MyObject = {
    properties: {
        clientId: {
            type: 'string',
            description: `client identifier.`,
            isRequired: true,
            isNullable: true,
            format: 'string',
            pattern: '^[a-zA-Z0-9 -_]*',
        },
        keepAlive: {
            type: 'number',
            description: `keepAlive`,
            isRequired: true,
            format: 'int32',
            maximum: 65535,
        },
  • default is missing
  • example is missing
  • minimum is missing if equal to 0 (I guess that can be checked)

@nhayfield
Copy link

also missing patternProperties

@jordanshatford
Copy link

jordanshatford commented Mar 30, 2024

I have fixed the issue with minimum missing when equal to 0 (also other min/max schema values will no longer have this bug). Please check out v0.32.1 of our fork @hey-api/openapi-ts. I plan to add default in the near future. If there are any other issues you have please open an issue and we will address as soon as we can!

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

No branches or pull requests

5 participants