Skip to content

Instantly share code, notes, and snippets.

@tai2
Created December 11, 2019 04:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tai2/67fa96fbe1303c26f14259ddedb5b422 to your computer and use it in GitHub Desktop.
Save tai2/67fa96fbe1303c26f14259ddedb5b422 to your computer and use it in GitHub Desktop.
OpenAPI go-gin-server

Go API Server for openapi

This is a sample server Petstore server. For this sample, you can use the api key special-key to test the authorization filters.

Overview

This server was generated by the [openapi-generator] (https://openapi-generator.tech) project. By using the OpenAPI-Spec from a remote server, you can easily generate a server stub.

To see how to make this your own, look here:

README

  • API version: 1.0.0
  • Build date: 2019-12-11T13:00:13.718+09:00[Asia/Tokyo]

Running the server

To run the server, follow these simple steps:

go run main.go

To run the server in a docker container

docker build --network=host -t openapi .

Once the image is built, just run

docker run --rm -it openapi 

Known Issue

Endpoints sharing a common path may result in issues. For example, /v2/pet/findByTags and /v2/pet/:petId will result in an issue with the Gin framework. For more information about this known limitation, please refer to gin-gonic/gin#388 for more information.

A workaround is to manually update the path and handler. Please refer to gin-gonic/gin/issues/205#issuecomment-296155497 for more information.

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