Skip to content

[REQ] Allow usage of Spring properties in server variables for context-path configuration #22549

@MelleD

Description

@MelleD

I would like to request a feature in the OpenAPI Generator to support using Spring properties in the server section for defining the context path.

When defining a server with a variable placeholder, for example:

servers:
  - url: http://petstore.swagger.io/{context-path}
    description: Server URL
    variables:
      context-path:
        default: ${server.servlet.context-path}

The problem is that variables are re-evaluated after property resolution. As a result, it is currently not possible to define a Spring property (like ${server.servlet.context-path}) for the context path in this section, since the property is treated again as a template variable instead of being resolved.

It would be helpful if the generator could either:

Detect and preserve Spring property placeholders (e.g. ${server.servlet.context-path}) without reinterpreting them
This would allow configuring the generated server URL dynamically based on Spring properties, which is especially useful in environments where the context path differs between deployments.

Issue is here
https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/URLPathUtils.java#L79

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions