/go-swagger

go-swagger testbed

MIT LicenseMIT

Build Status

Readme

This is my take on the Todo List tutorial at goswagger.com.

Steps

  1. Create initial swagger.yml file:
swagger init spec --title "Todo list" --description "Sample todo list app" --version 1.0.0 --scheme http --consumes application/com.thesaleem.examples.todo-list.v1+json --produces application/com.thesaleem.examples.todo.list.v1+json
  1. Edit it as as instructed in the tutorial, or as you wish.

  2. Create a go module:

go mod init com.thesaleem/examples/todo-list
  1. Generate swagger server:
swagger generate server -A todo-list -f ./swagger.yml

This should print out a lot of stuff, ending with two missing packages that you need to get.

  1. Get the missing packages, like this:
 go get -u -f ./...
  1. Install the generated server:
go install ./cmd/todo-list-server/

This will generate a runnable todo-list-server and put it in your $GOPATH/bin folder. Verify it by doing ls -la $GOPATH/bin/todo-list-server. You should not get a No such file or directory

  1. Run the server:
$GOPATH/bin/todo-list-server

This should launch the http server and show you something like this:

Serving todo list at http://127.0.0.1:54439
  1. Test your server:
curl http://127.0.0.1:54439

This should return "operation TodosGet has not yet been implemented". This is understandable, because we haven't written any implementation for our todo-list yet. However, the API documentation is being served.