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

OpenAPI schemas with a default value aren't marked as optional #72

Closed
killjoy1221 opened this issue Apr 18, 2024 · 3 comments
Closed

OpenAPI schemas with a default value aren't marked as optional #72

killjoy1221 opened this issue Apr 18, 2024 · 3 comments
Labels

Comments

@killjoy1221
Copy link
Contributor

killjoy1221 commented Apr 18, 2024

Environment

❯ npx nuxi info
Working directory: /home/projects/nuxt-starter-8hsfcz
Nuxt project info:

------------------------------
- Operating System: Linux
- Node Version:     v18.18.0
- Nuxt Version:     3.11.2
- CLI Version:      3.11.1
- Nitro Version:    2.9.6
- Package Manager:  npm@10.2.3
- Builder:          -
- User Config:      modules, watch, apiParty, devtools
- Runtime Modules:  nuxt-api-party@2.0.0
- Build Modules:    -
------------------------------

Reproduction

https://stackblitz.com/edit/nuxt-starter-qqitc3?file=nuxt.config.ts

Describe the bug

Components with a default value and aren't included in the required key aren't marked as optional in the resulting typescript declarations.

Additional context

Input schema:

components:
  schemas:
    UserRegistration:
      type: object
      properties:
        name:
          type: string
        age:
          type: number
        subscribe:
          type: boolean
          default: true
      required: [ name ]

Output .d.ts

export interface components {
  schemas: {
    UserRegistration: {
      name: string;
      age?: number;
      /** @default true */
      subscribe: boolean;
    }
  }
}

Logs

No response

@killjoy1221
Copy link
Contributor Author

Upstream issue: drwpow/openapi-typescript#1368 (comment)

@johannschopplich
Copy link
Owner

Thank you for paying attention! I hope this issue get resolved soon.

@johannschopplich
Copy link
Owner

johannschopplich commented May 13, 2024

Should be resolved by #74. Now, all openapi-typescript versions from v5 to v7 supported (again).

This specific issue is resolvable by installing openapi-typescript@6.

Thanks a lot, @killjoy1221!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants