ProductPromotion
Logo

Go.Lang

made by https://0x3d.site

GitHub - go-oas/docs: Automatically generate RESTful API documentation for GO projects - aligned with Open API Specification standard
Automatically generate RESTful API documentation for GO projects - aligned with Open API Specification standard - go-oas/docs
Visit Site

GitHub - go-oas/docs: Automatically generate RESTful API documentation for GO projects - aligned with Open API Specification standard

GitHub - go-oas/docs: Automatically generate RESTful API documentation for GO projects - aligned with Open API Specification standard

docs

Automatically generate RESTful API documentation for GO projects - aligned with Open API Specification standard.

GolangCI Build Version Go Report Card Coverage Status codebeat badge Go Reference Mentioned in Awesome Go

go-OAS Docs converts structured OAS3 (Swagger3) objects into the Open API Specification & automatically serves it on chosen route and port. It's extremely flexible and simple, so basically it can be integrated into any framework or existing project.

We invite anyone interested to join our GH Discussions board. Honest feedback will enable us to build better product and at the same time not waste valuable time and effort on something that might not fit intended usage. So if you can, please spare few minutes to give your opinion of what should be done next, or what should be the priority for our roadmap. :muscle: :tada:


Table of Contents

Getting Started

  1. Download docs by using:
    $ go get -u github.com/go-oas/docs
    
  2. Add one line annotation to the handler you wish to use in the following format: // @OAS <FUNC_NAME> <ROUTE> <HTTP_METHOD> Examples:
    // @OAS handleCreateUser /users POST
    // @OAS handleGetUser /users GET
    
  3. Declare all required documentation elements that are shared. Or reuse ones that already exist in the examples directory.
  4. Declare specific docs elements per route.

How to use

For more explicit example, please refer to docs/examples

Add OAS TAG to your existing handler that handles fetching of a User:

package users

import "net/http"

// @OAS handleGetUser /users GET
func (s *service) handleGetUser() http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
	}
}

Create a unique API documentation function for that endpoint:

package main

import "github.com/go-oas/docs"

func handleGetUserRoute(oasPathIndex int, oas *docs.OAS) {
	path := oas.GetPathByIndex(oasPathIndex)

	path.Summary = "Get a User"
	path.OperationID = "getUser"
	path.RequestBody = docs.RequestBody{}
	path.Responses = docs.Responses{
		getResponseOK(),
	}

	path.Tags = append(path.Tags, "pet")
}

Bear in mind that creating a unique function per endpoint handler is not required, but simply provides good value in usability of shared documentation elements.

Once you created the function, simply register it for parsing by using AttachRoutes() defined upon OAS structure. E.g.:


package main

import (
	"github.com/go-oas/docs"
)

func main() {
	apiDoc := docs.New()
	apiDoc.AttachRoutes([]interface{}{
		handleGetUserRoute,
	})

If this approach is too flexible for you, you are always left with the possibility to create your own attacher - or any other parts of the system for that matter.

Examples

To run examples, and checkout hosted documentation via Swagger UI, issue the following command:

$ go run ./examples/file_output/*.go
# or uncomment line 40 and comment line 38 in internal/dist/index.html before running:
$ go run ./examples/stream_output/*.go

And navigate to http://localhost:3005/docs/api/ in case that you didn't change anything before running the example above.


Contact

Check out the current Project board or our GH Discussions board for more information.

You can join our Telegram group at: https://t.me/go_oas

Roadmap

Feature (GH issues) Description Release
Validation Add validation to all structures based on OAS3.0.3 v1.1.0
CLI Add CLI support - make it CLI friendly v1.2.0
Postman Add postman support via PM API v1.3.0
ReDoc Add ReDoc support as an alternative to SwaggerUI v1.4.0
E2E Auto-generation Go tests conversion to Cypress/Katalon suites (convert mocked unit tests into e2e tests) v1.5.0

Articles
to learn more about the golang concepts.

Resources
which are currently available to browse on.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

FAQ's
to know more about the topic.

mail [email protected] to add your project or resources here ๐Ÿ”ฅ.

Queries
or most google FAQ's about GoLang.

mail [email protected] to add more queries here ๐Ÿ”.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory