I have an Angular application connected to a backend with an OpenAPI specification. The application should not have a hard-coded address and needs to run under different locations, but the backend will always be reachable on the same host, (backend calls all start with /api
), so I would like the clients to just use window.location.origin
as the base address.
The clients for the OpenAPI backend are generated using the OpenAPI generator. The generator does support a parameter for the base path, but turns it into a string. Therefore, calling it using
openapi-generator-cli generate -i swagger.json -g typescript-angular -o src/generated-sources/openapi --additional-properties=ngVersion=17.1.1,npmName=restClient,supportsES6=true,npmVersion=10.2.4,basePath=window.location.origin
results in code that contains window.location.origin
as a string (instead of as a variable). Is there any possibility to change that behavior?