Code Monkey home page Code Monkey logo

Comments (5)

gromakovsky avatar gromakovsky commented on August 24, 2024 1

Oh, I see, thanks.

Would you make a PR to fix this?

Yep, everything is clear now, so I'll probably do it, hopefully within a couple of weeks.

from openapi3.

gromakovsky avatar gromakovsky commented on August 24, 2024

So I tried putting something into _openApiSecurity and got the following error in Swagger Editor:

Semantic error at security.0
Security requirements must match a security definition

I didn't read OpenAPI specification carefully, but it looks like I must provide security definitions in order to specify security requirements, but apparently I can't do that in openapi3. Am I missing something?

from openapi3.

gromakovsky avatar gromakovsky commented on August 24, 2024

Update after reading OAS: apparently I should use _componentsSecuritySchemes :: Definitions SecurityScheme field (in the Components type) to provide all security definitions. SecurityDefinitions is just a newtype for Definitions SecurityScheme. So apparently _swaggerSecurityDefinitions :: SecurityDefinitions was changed to _componentsSecuritySchemes :: Definitions SecurityScheme in 821654c which made SecurityDefinitions type useless (? still not sure), but it was forgotten to remove this type.

from openapi3.

maksbotan avatar maksbotan commented on August 24, 2024

Hi!

apparently I should use _componentsSecuritySchemes :: Definitions SecurityScheme field (in the Components type) to provide all security definitions

Yes. See an example here: https://github.com/biocad/web-template/blob/master/src/Web/Template/Servant/Auth.hs#L295

So apparently _swaggerSecurityDefinitions :: SecurityDefinitions was changed to _componentsSecuritySchemes :: Definitions SecurityScheme in 821654c which made SecurityDefinitions type useless (? still not sure)

Looks like so. However, there is one difference, namely in Semigroup instance for SecurityDefinitions: it uses unionWith (<>), while Definitions SecuritySchem would use the plain union which discards the second version of the conflicting key.

instance Semigroup SecurityDefinitions where
(SecurityDefinitions sd1) <> (SecurityDefinitions sd2) =
SecurityDefinitions $ InsOrdHashMap.unionWith (<>) sd1 sd2

It would only matter for SecuritySchemeOAuth2 type:

instance Semigroup SecurityScheme where
SecurityScheme (SecuritySchemeOAuth2 lFlows) lDesc
<> SecurityScheme (SecuritySchemeOAuth2 rFlows) rDesc =
SecurityScheme (SecuritySchemeOAuth2 $ lFlows <> rFlows) (swaggerMappend lDesc rDesc)

Semigroup for this type merges two objects, in case they have different filled flow types. I think this is actually a correct behavior and dropping the newtype was a mistake.

Would you make a PR to fix this?

BTW, the newtype is still used in tests.

from openapi3.

maksbotan avatar maksbotan commented on August 24, 2024

Thanks!

from openapi3.

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.