最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

angular - Specify window.location.origin as base path in OpenAPI Generator - Stack Overflow

programmeradmin2浏览0评论

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?

发布评论

评论列表(0)

  1. 暂无评论