Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenAPI.Server - the basePath not work as intended #83

Open
ndy2 opened this issue Dec 12, 2024 · 0 comments
Open

OpenAPI.Server - the basePath not work as intended #83

ndy2 opened this issue Dec 12, 2024 · 0 comments

Comments

@ndy2
Copy link

ndy2 commented Dec 12, 2024

Hi. I found an issue related to OpenAPI.Server specification.
the Server in OpenAPI 3.0 combines host and basePath from OpenAPI 2.0 and the basePath part not work as intended.


In sample pet store case,

image

the /pet path should route to /api/v3/pet.

But, if we use SwaggerRouteDSL.getWithDoc, it whould register actual endpoint /pet instead of /api/v3/pet

def getWithDoc[RequestType: Manifest, ResponseType: Manifest](route: String,
                                                                name: String = "",
                                                                admin: Boolean = false,
                                                                routeIndex: Option[RouteIndex] = None,
                                                                registerOptionsRequest: Boolean = false)
                                                               (doc: Operation => Operation)
                                                               (callback: RequestType => ResponseType): Unit = {
    registerOperation(route, HttpMethod.GET)(doc)
    get(prependBasePath(route), name, admin, routeIndex)(callback)
    if (registerOptionsRequest) {
      options(route, name, admin, routeIndex)(noopCallback)
    }
  }

def prependBasePath(route) String {
   ???
}

First, I think we could get basePath from the OpenAPI.servers property but it is not applicable for some use case where it has
multiple server object with different basePath.

If the SwaggerController supply some overidable configuration for the basePath with default of empty string, and it may be used at the prependBasePath above or some.


If I go on some PR for this, I would leave a comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant