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/plugin-client] An error will be thrown when baseUrl is not defined. #1495

Closed
TopGrd opened this issue Jan 8, 2025 · 6 comments
Closed
Labels
bug Something isn't working @kubb/plugin-client

Comments

@TopGrd
Copy link
Contributor

TopGrd commented Jan 8, 2025

What version of kubb is running?

3.4.0

What kind of platform do you use?

MacOS

How does your kubb.config.ts config look like

No response

Swagger/OpenAPI file?

No response

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

No response

What steps can reproduce the bug?

When the baseUrl of the plugin-client is not defined, the generated code is as follows.
CleanShot 2025-01-08 at 19 09 55@2x

This will throw an exception. In the previous version, it was okay. Maybe a default baseUrl should be provided here.

How often does this bug happen?

None

What is the expected behavior?

No response

Additional information

No response

@TopGrd TopGrd added the bug Something isn't working label Jan 8, 2025
@TopGrd
Copy link
Contributor Author

TopGrd commented Jan 8, 2025

In my scenario, there may be three baseUrls in the code generated by OpenAPI. Is there a way to dynamically select the candidate values for baseUrl through parameter passing?

@nimo23
Copy link

nimo23 commented Jan 8, 2025

Maybe related to #1463 (comment) ?

@stijnvanhulle
Copy link
Collaborator

Base should be optional so not sure if that is the error or something else is going on: https://developer.mozilla.org/en-US/docs/Web/API/URL/URL#base

@TopGrd
Copy link
Contributor Author

TopGrd commented Jan 8, 2025

url (in the case of absolute URLs) or base + url (in the case of relative references) is not a valid URL.

@TopGrd
Copy link
Contributor Author

TopGrd commented Jan 8, 2025

url (in the case of absolute URLs) or base + url (in the case of relative references) is not a valid URL.

new URL("/en-US/docs", "");
// Raises a TypeError exception as '' is not a valid URL

new URL("/en-US/docs");
// Raises a TypeError exception as '/en-US/docs' is not a valid URL

// Other cases:

new URL("http://www.example.com");
// => 'http://www.example.com/'

new URL("http://www.example.com", B);
// => 'http://www.example.com/'

new URL("", "https://example.com/?query=1");
// => 'https://example.com/?query=1' (Edge before 79 removes query arguments)

new URL("/a", "https://example.com/?query=1");
// => 'https://example.com/a' (see relative URLs)

new URL("//foo.com", "https://example.com");
// => 'https://foo.com/' (see relative URLs)

@stijnvanhulle
Copy link
Collaborator

@nimo23 @TopGrd This will resolved in v3.4.4

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

No branches or pull requests

3 participants