files middleware - Warning when serving spec api json with useBasePath: true
Files middleware causes warning when serving the swagger json with useBasePath: true
The following middleware configuration causes WARNINGS when accessing <api-root>/api-docs
app.use(middleware.files({
// Override the Express App's case-sensitive and strict-routing settings for the Files middleware.
caseSensitive: false,
strict: false
}, {
useBasePath: true,
apiPath: /api-docs/,
}));
For example, I see the following when accessing api-docs: WARNING! Unable to find a Swagger path that matches "/myapi/v1/api-docs"
Adding api-docs to the yaml file works around the warnings, however this is not desired.
You get a warning on the console whenever you try to access a url that does not exist in the YAML or JSON files of your api definitions. You also get a warning when you try to access a path with a verb which is not supported. You can turn off the warning messages with an environment variable WARN=off Personally, I don't think they should be logged at all - just return the error (as they do).
can this be closed?
It's up to the author to decide. As I said before, I don't think a library should print to the console anything. It should only return errors and allow the main program to write whatever to its logs. What do you think @BebeSparkelSparkel ?
2 things
First, I think it should default to sending an error if the path is not found instead of printing to screen. If you do not want it validated there should be a whitelist option.
Second, it seems like there are a lot of open issues with very little activity that go back to 2015 that probably do not matter anymore. These have left me hanging while investigating for solutions. Perhaps after a period of time without any activity there could be a resolution comment and then close the issue.
The error is sent of course, but a rule of thumb for libraries is never to decide for the main program what to print out on the console. Give the error and let the main program log it or ignore it or whatever it wants to do with it.
Do you have permissions to merge code changes and publish a new version to npm?
I do not.