Skip to content

go-chassis/go-restful-swagger20

This branch is 23 commits ahead of, 1 commit behind emicklei/go-restful-swagger12:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

9243cbe · Jul 4, 2022

History

29 Commits
Mar 17, 2021
Dec 21, 2018
Jan 30, 2017
Feb 3, 2017
Oct 29, 2019
Dec 21, 2018
Dec 9, 2019
Oct 29, 2019
Jul 4, 2022
Mar 17, 2021
May 9, 2019
Jan 30, 2017
Dec 21, 2018
Mar 10, 2020
Mar 10, 2020
Jul 4, 2022
Dec 9, 2019
Dec 9, 2019
May 8, 2019

Repository files navigation

go-restful-swagger20

overview

openapi extension to the go-restful package, OpenAPI-Specification version 2.0

dependencies

how to use

use it to replace go-restful-swagger12

config := swagger.Config{
		WebServices:    restful.DefaultContainer.RegisteredWebServices(), 
		FileStyle:	"json", //optional, default is yaml
		OpenService:     true,  //should show it in rest API service
		WebServicesUrl: "http://localhost:8080",
        ApiPath:        "/apidocs.json", //swagger doc api path
		OutFilePath: os.Getenv("SWAGGERFILEPATH"),
} 
swagger.RegisterSwaggerService(config, restful.DefaultContainer)

How to change or ignore the name of a field

go struct

	type X struct {
		A int
		B int `json:"C"`  //Will generate C here
		D int `json:"-"`  //Will ignore it
	}

result

	  "X": {
		"type": "object",
	   "properties": {
		"A": {
		 "type": "integer",
		 "format": "int32"
		},
		"C": {
		 "type": "integer",
		 "format": "int32"
		}
	   }
	  }

Example

About

Swagger 2.0 extension to the go-restful package

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%