Skip to content

Improvement : oapi validation middleware should only validate path/route/endpoint that included in oapi spec file. #239

@bandirsen

Description

@bandirsen

In current implementation, oapi validation middleware validate all route/path of the server application including path/route that wasn't included in oapi spec file,

I have a case when my application is serving oapi request but also serve static files from a webroot (I'm using echo framework)

e := echo.New()
e.Static('/', "path_to_static_files_dir")
...
e.Use(OapiRequestValidator(swagger))   

The middleware will reject request to static files such as http://host/index.html or http://host/javascript/any.js or http://host/image/any.png etc and send 400 error "Path was not found",

In my opinion those requests should not validated by the middleware, since was not oapi end-point. I knew we could use echo middleware Skipper, but it will be tedious job if we have many static files/folder in webroot directory.

My suggestion is if the middleware can not find a matching route from a request, it should letting the upstream application code to handle it.

Anyone agree with me ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions