18.1: Test with Swagger
Last updated
Last updated
In this section, we test our endpoints with swagger. You may be wondering why we need to do this after already having used Postman. The big difference is that Swagger is embedded into your application, and thus is exclusive to it. Postman, on the other hand, is a third party tool in which you can test multiple applications in the same collection.
Run the app
Add /swagger to the end of your URL
Click on Auth and then Expand Operations
For the grant_type, type 'password'
Enter in your username and password and click Try it out!
You should receive a token for that user in the Response Body
Copy the token without the quotes
Click on Note and then the GET method
In the Authorization field, type Bearer then a space, and then paste the token
Click Try It Out! and you should see all of the notes for the logged in user in the Response Body
Click List Operations to minimize the GET notes endpoint
Click on the POST endpoint
Click in the box w/ JSON and it will copy the text over to the box on the left
In the box on the left, replace string
with a title for your note and the other string
with the content
Copy and paste the Bearer token from the previous endpoint test
Click Try it Out! and make sure it works
Go to the GET /api/Note/{id}
request
Type in the NoteId
of the note you just posted, you can find it in dbo.Note
if you're unsure.
Paste the Bearer token
Click Try it Out! and make sure it works
Copy the JSON received by the GET request, the Response Body section.
Paste the JSON from the GET into the PUT request
Remove the Created
and Modified
entries
Modify the Title
and/or Content
Paste the Bearer token and click Try it Out!
Re-run either GET method to make sure the note has changed.
Go to the DELETE request
Type in a NoteId
and paste the Bearer token.
Click Try it Out!
Re-run the first GET method that gets all the notes and make sure the deleted note is not there.
TaDa! You've finished ElevenNote!