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

[@kubb/swagger-zod] Add local property for datetime #947

Closed
rwhendry opened this issue Apr 22, 2024 · 1 comment · Fixed by #951
Closed

[@kubb/swagger-zod] Add local property for datetime #947

rwhendry opened this issue Apr 22, 2024 · 1 comment · Fixed by #951
Labels
enhancement New feature or request

Comments

@rwhendry
Copy link

What is the problem this feature would solve?

With the new addition of Zod 3.23 it introduced the local properties in the datetime.

const schema = z.string().datetime({ local: true });
schema.parse("2022-01-01T12:00:00"); // OK

This will be helpful for parsing ISO8601 date without any Z (Zulu specified).

External documents/projects?

No response

What is the feature you are proposing to solve the problem?

Adding a flag of local in the lo

createSwaggerZod({
    dateConfig: {
        type: 'false'| 'string' | 'stringOffset' | 'date' | ,
        local: true,
    },
}),

What alternatives have you considered?

No response

@rwhendry rwhendry added the enhancement New feature or request label Apr 22, 2024
@stijnvanhulle stijnvanhulle linked a pull request Apr 23, 2024 that will close this issue
@stijnvanhulle
Copy link
Collaborator

Kubb version 2.13.3 will resolve this.

A new type for dateType called stringLocal has been added, see https://docs.kubb.dev/plugins/swagger-zod/#datetype.

import { defineConfig } from '@kubb/core'
import { definePlugin as createSwagger } from '@kubb/swagger'
import { definePlugin as createSwaggerZod } from '@kubb/swagger-zod'

export default defineConfig({
  input: {
    path: './petStore.yaml',
  },
  output: {
    path: './src/gen',
  },
  plugins: [
    createSwagger({ output: false }),
    createSwaggerZod({
      dateType: 'stringLocal',
    }),
  ],
})

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

Successfully merging a pull request may close this issue.

2 participants