Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throwing NullPointerException when using securityDefinitions with oauth #4

Open
jenreh opened this issue Jul 7, 2016 · 4 comments
Open

Comments

@jenreh
Copy link

jenreh commented Jul 7, 2016

yaml:

securityDefinitions:
  basicAuth:
    type: basic
  oauth:
    type: oauth2
    flow: application 
    tokenUrl: "/oauth/token"

Throws the following exception. When removing the oauth block eveything ist fine.

Exception:

Caused by: java.lang.NullPointerException
        at io.github.swagger2markup.internal.document.builder.SecurityDocumentBuilder.buildSecurityScheme(SecurityDocumentBuilder.java:133)
        at io.github.swagger2markup.internal.document.builder.SecurityDocumentBuilder.buildSecuritySchemeDefinitionsSection(SecurityDocumentBuilder.java:97)
        at io.github.swagger2markup.internal.document.builder.SecurityDocumentBuilder.build(SecurityDocumentBuilder.java:78)
        at io.github.swagger2markup.Swagger2MarkupConverter.toFolder(Swagger2MarkupConverter.java:177)
        at io.github.swagger2markup.Swagger2MarkupConverter$toFolder$0.call(Unknown Source)
        at io.github.swagger2markup.tasks.Swagger2MarkupTask.convertSwagger2markup(Swagger2MarkupTask.groovy:68)
        ... 22 more
@jenreh
Copy link
Author

jenreh commented Jul 7, 2016

The problem seems to be "type: oauth2"

@RobWin
Copy link
Member

RobWin commented Jul 7, 2016

Hello,

yes. The oauth2 scopes are required and must not be missing.

See: http://swagger.io/specification/#securitySchemeObject

@jenreh
Copy link
Author

jenreh commented Jul 7, 2016

Thank you, changing the yaml to

  oauth:
    type: oauth2
    flow: application
    tokenUrl: "/oauth/token"
    scopes:
      write:jarvis: schreibender Zugriff
      read:jarvis: lesender Zugriff

helped. A helpfull error message would be nice :-)

@RobWin
Copy link
Member

RobWin commented Jul 7, 2016

Yes, that's correct. Unfortunately I don't have much time atm. Feel free to create a Pull Request. :)

If you use Swagger2Markup, we would love to get your GitHub Star.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants