Skip to content

[BUG] [typescript-angular] Use a relative basePath #10697

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

Closed
5 of 6 tasks
bartbergmans opened this issue Oct 26, 2021 · 4 comments · Fixed by #10057
Closed
5 of 6 tasks

[BUG] [typescript-angular] Use a relative basePath #10697

bartbergmans opened this issue Oct 26, 2021 · 4 comments · Fixed by #10057

Comments

@bartbergmans
Copy link

bartbergmans commented Oct 26, 2021

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

I am using the typescript-angular generator. In the api.service it generates a basePath using http://localhost when you use a relative path.

protected basePath = 'http://localhost';
openapi-generator version

5.3.1

OpenAPI declaration file content or url
servers:
  - url: '/api'
Steps to reproduce

Set the url in the openapi specification to a relative path, for example /api. When you run the typescript-angular generator now, it will generate the basePath in the api.service as http://localhost/api instead of /api

Related issues/PRs

#2731
#8576

Suggest a fix

Remove the prefixed http://localhost when a relative path is used.

@macjohnny
Copy link
Member

Would you like to fix this?

@bartbergmans
Copy link
Author

Any idea where I should look to fix this? I have looked at the code but couldn't find the localhost part anywhere.

@macjohnny
Copy link
Member

macjohnny commented Oct 26, 2021

here are some starting points:

public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCodegen {

@code1x1
Copy link
Contributor

code1x1 commented Oct 27, 2021

already fixed in #10056 waiting for PR merge. this is a general problem. the cli tool just adds a http://localhost if the address is relative because the path gets wrapped in URL class which adds localhost automaticlly if no host part exists added a check if url ist relativ just save as is

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

Successfully merging a pull request may close this issue.

3 participants