Giter VIP home page Giter VIP logo

Comments (4)

noelmccrory avatar noelmccrory commented on June 12, 2024 4

Bingo. I was missing the following from my API Spec:

security:
  - bearerAuth: []

After including it, Specmatic started to autogenerate an Authorization header. I was then able to use System.setProperty("bearerAuth", "abcdef"); to set my own token.

It may be worth updating https://specmatic.in/documentation/authentication.html to include some extra detail on setting the security as well as the security scheme.

Thanks!

from specmatic.

noelmccrory avatar noelmccrory commented on June 12, 2024 1

The API Spec is being generated using SpringDoc. I do have Stoplight installed and it didn't flag the unused security scheme 😞 Thanks again.

from specmatic.

yogeshnikam671 avatar yogeshnikam671 commented on June 12, 2024

Hi @noelmccrory, thanks for reaching out.

Looks like you are trying to run contract tests with a specification that has a security scheme defined.

Can you confirm if you are applying this security scheme to the APIs you are trying to test? Here's the documentation on how you can apply the defined security scheme to your APIs.

It would help us if you post a specification that would help us replicate the problem.

from specmatic.

yogeshnikam671 avatar yogeshnikam671 commented on June 12, 2024

@noelmccrory Glad you figured it out!
Just curious if you use any linters, if yes, it might have highlighted this issue in the spec in your IDE itself.
For example, in the following screenshot the Swagger Editor is telling me that I have not used the defined security scheme anywhere -

unused_security_scheme

While technically Specmatic is operating correctly based on the OpenAPI spec, what we can do is, add the suggestion of using linters in our documentation to help users find out any spec level issues (e.g. unused security scheme) to get early feedback.

Closing this issue for now. Please feel free to reopen if necessary.

from specmatic.

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.