Skip to content

Instantly share code, notes, and snippets.

@maiha
Last active June 29, 2020 14:09
Show Gist options
  • Save maiha/67d924ae22239e624570c8da29a62c64 to your computer and use it in GitHub Desktop.
Save maiha/67d924ae22239e624570c8da29a62c64 to your computer and use it in GitHub Desktop.

TL;DR

  • server: apisprout
  • editor: VSCode

server

localroast

$ localroast -p 8000 pets.json
$ curl -s 'http://localhost:8000/pet/1' | jq -c .
{"id":1,"category":{"id":1,"name":"dogs"},"name":"Hachiko","tags":[{"id":1,"name":"japanese"}],"status":"available"}

openapi-mock

$ docker run -p 8080:8080 -e "OPENAPI_MOCK_SPECIFICATION_URL=https://raw.githubusercontent.com/OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml" --rm muonsoft/openapi-mock
$ curl -s 'http://localhost:8000/v1/pets'

prism

$ docker run --rm -it -p 8000:4010 -v $PWD:/tmp stoplight/prism:3 mock -h 0.0.0.0 /tmp/openapi.yaml
$ curl -s 'http://localhost:8000/pets'

[5:20:54 PM] › [HTTP SERVER] get /pets ℹ  info      Request received
[5:20:54 PM] ›     [NEGOTIATOR] ℹ  info      Request contains an accept header: */*
[5:20:54 PM] ›     [VALIDATOR] ✔  success   The request passed the validation rules. Looking for the best response
[5:20:54 PM] ›     [NEGOTIATOR] ✔  success   Found a compatible content for */*
[5:20:54 PM] ›     [NEGOTIATOR] ✔  success   Responding with the requested status code 200
[5:20:54 PM] ›     [VALIDATOR] ✖  error     Violation: response.body.id should match format "int64"

apisprout

$ docker run -p 8000:8000 -v $PWD:/tmp danielgtaylor/apisprout /tmp/openapi.yaml
$ curl http://localhost:8000/pets | jq -c .
[{"id":0,"name":"string","tag":"string"}]

editor

openapi-gui

OpenAPI (Swagger) Editor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment