Tuesday, May 29, 2018

WireMock to mock APIs

Full Stack Software Development Blog


If you have a need to mock APIs then WireMock to the rescue.

See http://wiremock.org/

In the last blog I have defined APIs in swagger hub. Now I need a way to exercise those APIs. I'm very glad to have found WireMock.

I followed the getting started guide to run WireMock locally (http://wiremock.org/docs/getting-started/). It must be a Spring Boot jar :)

I downloaded the standalone jar and ran it on port 9999.

  • java -jar wiremock-standalone-2.18.0.jar --port 9999


I then added a stub API

  • curl -X POST http://localhost:9999/__admin/mappings -d '{ "request": { "method": "GET", "url": "/hello1" }, "response": { "body": "Hello world!" }}'

Exercise the stub

  • curl http://localhost:9999/hello1

Added a new stub to return a json body

  • curl -X POST http://localhost:9999/__admin/mappings -d '{ "request": { "method": "GET", "url": "/hello2" }, "response": { "jsonBody": {"Hello": "world!" }}}'

Exercise the stub

  • curl http://localhost:9999/hello2

To see all stub mappings

  • curl http://localhost:9999/__admin/

See http://wiremock.org/docs/stubbing/ for more ways to stub.

Shutdown the local server

  • curl -X POST http://localhost:9999/__admin/shutdown


Next I deployed the WireMock server to Heroku. You can too. See my github repo
https://github.com/gpratte/wiremock-deploy-heroku

Saturday, May 26, 2018

APIs defined

Full Stack Software Development Blog


I've made a first pass for the API definitions using Open API.

What I did was look at my UI mockups (see previous Mockup blog entry) to determine what APIs the client needed. It was very helpful to think through the behavior of the system from the client point of view.

The API definitions can be found on swagger hub at
https://app.swaggerhub.com/search?type=API&owner=texastoc&sort=NAME&order=ASC

This tutorial was key to learning version 2.0 of the Open API
https://apihandyman.io/writing-openapi-swagger-specification-tutorial-part-1-introduction/



Friday, May 18, 2018

Finished with mockups

Full Stack Software Development Blog


Finished with the bootstrap mockups.

Normally I would dive into coding the backend but I'm going to start from a different point of view - the front end.

While working at a company that created many a mobile application for the past several years I would be asked the same question repeatedly by the front end developers which is
"how can I know what the back end APIs are and if they are doing the right thing?"

Next is API documentation and testing from the front end point of view.

Sunday, May 13, 2018

Mockups

Full Stack Software Development Blog


I've begun creating mockups using bootstrap (bootstrap 4 and font awesome 5).

The files can be found in github at https://github.com/gpratte/texastoc-v2-wireframes

Clone the repo, open index.html in a browser and click on the links.

Friday, May 4, 2018

UI flow

Full Stack Software Development Blog


Put together a rudimentary UI flow.

Click here to view the flow.