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

Zod: OpenAPI URI type is generated to URL #767

Closed
kopach opened this issue Jan 11, 2024 · 1 comment · Fixed by #771
Closed

Zod: OpenAPI URI type is generated to URL #767

kopach opened this issue Jan 11, 2024 · 1 comment · Fixed by #771
Assignees
Labels
bug Something isn't working

Comments

@kopach
Copy link

kopach commented Jan 11, 2024

What version of kubb is running?

kubb/2.1.6 darwin-arm64 node-v18.17.0

What platform is your computer?

macOS

What version of external packages are you using(@tanstack-query, MSW, React, Vue, ...)

No response

What steps can reproduce the bug?

OpenApi schema with property "format": "uri" generated into url(), which is incorrect. URI !== URL.
e.g. this is valid uri: tel:000000 but not valid URL

See docs on URL https://url.spec.whatwg.org/
See docs on URI https://en.wikipedia.org/wiki/Uniform_Resource_Identifier

e.g. for OpenAPI file provided below following schema will be generated

export const SomeSchemaDTO = z.object({
  uri: z.string().url().nullish(),
});

How often does this bug happen?

Every time

What is the expected behavior?

Since there is no URI representation in zod, we should just use more wide string() type
Also in OpenAI itself uri has some variability in implementation

This schema should be generated

export const SomeSchemaDTO = z.object({
  uri: z.string().nullish(),
});

Swagger/OpenAPI file?

//...
      "SomeSchemaDTO": {
        "type": "object",
        "properties": {
          "uri": { "type": "string", "nullable": true, "format": "uri" }
        }
      },
//...

Additional information

No response

@kopach kopach added the bug Something isn't working label Jan 11, 2024
@stijnvanhulle stijnvanhulle self-assigned this Jan 11, 2024
@stijnvanhulle stijnvanhulle linked a pull request Jan 14, 2024 that will close this issue
@kopach
Copy link
Author

kopach commented Jan 15, 2024

Thank you @stijnvanhulle. you solve those issues extremely fast. All the best for this project. I'ts really helpful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants