Giter Club home page Giter Club logo

Comments (5)

AustinGil avatar AustinGil commented on July 16, 2024

I was able to solve the issues by including a middleware that adds the appropriate CSP policies for the OAPI docs routes.

I'm not sure if the CSP for these pages needs to be too strict, so I left it pretty lax. Obviously it could be configured to be more specific to the resource type.

const openapiCSP = (req, res, next) => {
  res.set({ 'Content-Security-Policy': "default-src * 'self' 'unsafe-inline' 'unsafe-eval' blob: data:"});
  next();
};
app.use('/api/redoc', openapiCSP, openapi.redoc);
app.use('/api/swaggerui', openapiCSP, openapi.swaggerui);

This might be something worth adding into the library itself though.

from express-openapi.

wesleytodd avatar wesleytodd commented on July 16, 2024

Hm, I actually would prefer those libraries to handle that, since it is entirely in their domain of control. Could it be that we are outdated and need to update those packages? If that is the case an update PR would be most welcome.

from express-openapi.

AustinGil avatar AustinGil commented on July 16, 2024

Im not so familiar with the libraries being used, but I agree with trying to implement this at the highest level. Would those libraries support setting CSP policies though? Seems like something that needs to be handled at the server level.

It looks like the swagger-parser package is pretty far behind (as well as a couple others)

image

How would an update PR work? Are there autmated tests?

from express-openapi.

wesleytodd avatar wesleytodd commented on July 16, 2024

There are automated tests, so you would just make a branch, then run npm update swagger-parser --latest and commit the changes in package.json. Submit that as a PR. Even with automated tests, I typically will also run them locally to do a manual check before publishing. I also typically fire up a server and check the UI if there are changes to those packages which provide the UI.

from express-openapi.

wesleytodd avatar wesleytodd commented on July 16, 2024

Closing this in favor of the new PR.

from express-openapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.