Skip to content

Support for Dynamic OpenAPI Specs ("servers": [{"url": "/"}]) #843

Closed
@sennyeya

Description

@sennyeya

Is your feature request related to a problem? Please describe.
Before I jump in, thanks for this library, it's really great! I'm working on adding OpenAPI request validation to Backstage and found this library. Basically, Backstage has a routing system that decouples the parent route from the plugin. Each plugin can be mounted at different routes for different implementations so a full Backstage spec has to be dynamic. See this.

To support that dynamic nature, each plugin has a spec with a

servers:
  - url: '/'

section (you can see an example here). Those specs can then be combined with routing knowledge at run time to create a tailored "Backstage" full API spec. However, my goal is to support per plugin validation that's decoupled from the full API spec. Plugin owners could then opt into validation and configure it themselves. Ideally, this library would be what we use for that. However, I'm getting issues from this line. The req.originalUrl will always contain the full URL with all of the parent routers, meaning it's not possible to validate against a router specific spec.

Describe the solution you'd like
A toggle to use req.path or req.url instead of req.originalUrl. Basically, the ability to turn off the functionality introduced in #211 to support fully context aware routers.

Describe alternatives you've considered
I also looked at #113, but I think this is a separate use case with a similar soluiton.

Additional context
Add any other context or screenshots about the feature request here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions