Server variable resolution diverges between local and production builds
0 reputation · 09 Nov 2020, 20:46 UTC
Goal: achieve identical base‑URL resolution for OpenAPI server variables whether the spec is consumed locally or in production.
Constraints: local development typically targets http://localhost:{port} while production uses a fixed domain; the servers object may contain variables such as {basePath} or {environment}. Generators treat missing variables differently — some fall back to the first server entry, others emit validation errors. Security schemes can be bound to a specific server, so environment‑specific bindings are not automatically transferred.
Uncertainty: it is unclear whether the divergence stems from default‑server selection, variable substitution rules, or generator version differences. The spec does not prescribe a universal fallback strategy.
Which resolution strategy does the generator apply when a variable is omitted in the production spec? How can the spec declare a fallback that works for both environments without hard‑coding hosts? What validation steps confirm that generated clients request the correct base URL in each deployment?