Update following properties with your PostgresDB configurations
spring.r2dbc.url=${POSTGRES_URL:r2dbc:postgresql://localhost:5432/problem_webflux_db} spring.r2dbc.username=${POSTGRES_USER:postgres} spring.r2dbc.password=${POSTGRES_USER:admin} spring.flyway.url=${POSTGRES_URL:jdbc:postgresql://localhost:5432/problem_webflux_db} spring.flyway.user=${POSTGRES_USER:postgres} spring.flyway.password=${POSTGRES_PASSWORD:admin}Update following properties with your MongoDB configurations
spring.data.mongodb.uri=${MONGODB_URL:mongodb://localhost:27017/problem_web_db}Run the main class ProblemWebFluxDemoApplication and access Swagger Swagger at http://localhost:8080/swagger-ui.html
Select Application from dropdown Select a definition
- State management APIs are using MongoDB, to test database constraint violations.
- Employee management APIs are using PostgresDB, to test database constraint violations.
- Problem Demo APIs throws exceptions explicitly. Have a look at
DemoProblemController - State and Employee management APIs are secured, so need to pass a JWT token in
Authorizationheader. See the lock symbol against the API in Swagger
Click on Authorize button to pass the JWT Token. Use following as JWT Token.
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c - Call the APIs providing invalid inputs to make it throw exception and have a look at response.
- Set
problem.debug-enabled=trueinapplication.propertiesto get the message resolvers and set the messages inerrors.propertiesto customize the error response attributes in response. - Test with setting
problem.stacktrace-enabled=trueandproblem.cause-chains-enabled=trueinapplication.propertiesto get Stacktrace and Cause in response. - Update
help.htmlwith any custom error description and follow thetypeurl in error response to see the error description on help page.