springboot-angular2-tutorial / boot-app

This repository is an example application for Spring Boot and Angular2 tutorial.
MIT License
113 stars 42 forks source link

Test Full authentication request in swagger #13

Closed kamil-wisniewski closed 7 years ago

kamil-wisniewski commented 7 years ago

Hi ! I have a problem with testing controller in swagger if access is protected. Can you explain me how I can do that's? How I can simulate loged user?

akirasosa commented 7 years ago

Hi @banditeye

Thanks for trying!

https://github.com/swagger-api/swagger-ui#header-parameters According to it, we can set custom header from browser console. For example, the example below worked for me.

swaggerUi.api.clientAuthorizations.add("key", new SwaggerClient.ApiKeyAuthorization("authorization", "Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiIxIiwiZXhwIjoxNDg5MDI0NTU1fQ.wNsEseSroEja_ya_29GCrlkI0GemN5OocyQN9pQ9niMcOEqWxhynT1u9WFJDIkq4bQPbemZgUzmnPouPjPD7rw", "header"));

As a note, you have to get jwt token at first from /api/auth.