-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Open
Labels
Description
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
When specifying a relative url in servers, the expected behaviour is for it to not prepend http://localhost to the basePath.
However, when this url has a "-" in it, it is not recognized as relative.
openapi-generator version
6.1.0
OpenAPI declaration file content or url
{
"openapi": "3.0.2",
"info": {
"title": "FastAPI",
"version": "0.1.0"
},
"servers": [
{
"url": "/api/micro-service"
}
],
"paths": {
"/token": {
"post": {
"tags": [
"micro-service"
],
"summary": "Get Token From Code",
"operationId": "get_token_from_code_token_post",
"responses": {
"200": {
"description": "Successful Response",
"content": {
"application/json": {
"schema": {}
}
}
}
}
}
}
}
}Generation Details
openapi-generator-cli generate -i openapi.json -g typescript-angular -o ./generated --additional-properties=fileNaming=kebab-case
Steps to reproduce
Use the provided openapi.json spec with the provided command line.
Check in generated/api/micro-service.service.ts that the basePath is prepended with http://localhost
Related issues/PRs
The behaviour to prevent http://localhost to be prepended to basePath was added in #10057.
Suggest a fix
Line 238 in 7ff47dc
| return Pattern.matches("^(\\/[\\w\\d]+)+", firstServer.getUrl()); |
The regex used to check if a url is relative doesn't allow for non alphanumeric characters.