All Projects → Teamwork → kommentaar

Teamwork / kommentaar

Licence: MIT license
Generate documentation for Go APIs

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to kommentaar

dzcode.io
Website & mobile app for Algerian open-source community
Stars: ✭ 104 (+215.15%)
Mutual labels:  openapi
ApiFramework
Everything is an (Open)API
Stars: ✭ 26 (-21.21%)
Mutual labels:  openapi
Swiftgger
OpenAPI support for server side Swift projects.
Stars: ✭ 97 (+193.94%)
Mutual labels:  openapi
douyin-go
抖音SDK
Stars: ✭ 73 (+121.21%)
Mutual labels:  openapi
apiclarity
Reconstruct Open API Specifications from real-time workload traffic seamlessly.
Stars: ✭ 290 (+778.79%)
Mutual labels:  openapi
ApiCenter
A repository for all your API specifications
Stars: ✭ 26 (-21.21%)
Mutual labels:  openapi
open-api-mocker
A mock server based in OpenAPI Specification
Stars: ✭ 58 (+75.76%)
Mutual labels:  openapi
spectree
API spec validator and OpenAPI document generator for Python web frameworks.
Stars: ✭ 190 (+475.76%)
Mutual labels:  openapi
bow-openapi
🌐 Functional HTTP client generator from an OpenAPI/Swagger specification.
Stars: ✭ 47 (+42.42%)
Mutual labels:  openapi
OpenDocumenter
OpenDocumenter is a automatic documentation generator for OpenAPI v3 schemas. Simply provide your schema file in JSON or YAML, then sit back and enjoy the documentation.
Stars: ✭ 137 (+315.15%)
Mutual labels:  openapi
openapi
GitHub's official OpenAPI spec with Octokit extensions
Stars: ✭ 24 (-27.27%)
Mutual labels:  openapi
Tavis.OpenApi
Parser for OpenAPI Specification
Stars: ✭ 18 (-45.45%)
Mutual labels:  openapi
starling-developer-sdk
The official JavaScript development kit for building on the Starling API
Stars: ✭ 45 (+36.36%)
Mutual labels:  openapi
wapiml
An OpenAPI round-trip tool that leverages model-driven techniques to create, visualize, manage, and generate OpenAPI definitions.
Stars: ✭ 61 (+84.85%)
Mutual labels:  openapi
graphql-to-openapi
Convert a graphql query + graphql schema into an openapi spec.
Stars: ✭ 31 (-6.06%)
Mutual labels:  openapi
lodata
The OData v4.01 Producer for Laravel
Stars: ✭ 40 (+21.21%)
Mutual labels:  openapi
openapi-ui
React based OpenAPI 3.0+ documentation generator
Stars: ✭ 32 (-3.03%)
Mutual labels:  openapi
firecracker
Stop half-done API specifications! Cherrybomb is a CLI tool that helps you avoid undefined user behaviour by validating your API specifications.
Stars: ✭ 438 (+1227.27%)
Mutual labels:  openapi
vim-swagger-preview
A Vim plugin for previewing swagger/openAPI spec in Chrome with swagger-ui.
Stars: ✭ 19 (-42.42%)
Mutual labels:  openapi
fastapi-azure-auth
Easy and secure implementation of Azure AD for your FastAPI APIs 🔒 B2C, single- and multi-tenant support.
Stars: ✭ 174 (+427.27%)
Mutual labels:  openapi

GoDoc Build Status codecov

Kommentaar generates documentation for Go APIs.

The primary focus is currently on OpenAPI output (previously known as Swagger), but it can also output directly to HTML, and the design allows easy addition of other output formats.

Goals:

  • Easy to use.
  • Good performance.
  • Will not require significant code refactors to use in almost all cases.
  • Impossible to produce invalid OpenAPI files; prefer being strict over flexible.

Non-goals:

  • Support every single last OpenAPI feature. Some features, such as different return values with anyOf, don't map well to how Go works, and supporting it would add much complexity and would benefit only a few users.

Using the tool

Install it:

$ go get github.com/teamwork/kommentaar

Parse one package:

$ kommentaar github.com/teamwork/desk/api/v1/inboxController

Or several packages:

$ kommentaar github.com/teamwork/desk/api/...

The default output is as an OpenAPI 2 YAML file. You can generate a HTML page with -output html, or directly serve it with -output html -serve :8080. When serving the documentation it will rescan the source tree on every page load, making development/proofreading easier.

See kommentaar -h for the full list of options.

You can also the Go API, for example to serve documentation in an HTTP endpoint.

Syntax

See doc/syntax.markdown for a full description of the syntax; a basic example:

type bikeRequest struct {
	// Frame colour {enum: black red blue, default: black}.
	Color string

	// Frame size in centimetres {required, range: 40-62}.
	Size int
}

type bikeResponse struct {
	// Price in Eurocents.
	Price int

	// Estimated delivery date {date}.
	DeliveryTime int
}

type errorResponse struct {
	Error []string `json:"errors"`
}

// POST /bike/{id} bikes
// Order a new bike.
//
// A more detailed multi-line description.
//
// Request body: bikeRequest
// Response 200: bikeResponse
// Response 400: errorResonse

Configuration

Kommentaar can be configured with a configuration file; see config.example for the documentation.

Running Tests

GO111MODULE=off ./bin/test ./...

Motivation and rationale

The motivation for writing Kommentaar was a lack of satisfaction with existing tools:

  • yvasiyarov/swagger requires extensive comments; you will need to duplicate every parameter as @param foo query string Some description. It's flexible but also tedious and ugly.

  • We implemented go-swagger but found several pain points:

    • Implementing it meant doing a significant rewrite of our code base and a lot of "glue code", which made the code uglier in the opinion of many developers.
    • Slow; about 30 seconds for a fairly limited amount of endpoints (Kommentaar takes about 1.5 seconds for the same).
    • Very easy to generate invalid OpenAPI files.
    • Complex codebase made it hard to figure out why it was doing what it was doing.
  • goa means a complete rewrite of our API, and whether the goa DSL approach is a good one is also debatable (we haven't tried it due to the prohibitive costs of the rewrite, so lack direct experience).

We tried implementing both yvasiyarov/swagger and go-swagger, and both ended in fairly dismal (and time-consuming) failure.

Kommentaar is designed to strike a reasonable balance:

  • You will need to duplicate some information from the code in comments, but not too much, and it shouldn't have to be updated very often; adding new request or response parameters is still easy.

  • Makes some assumptions about your code (e.g. that you're returning a struct), but not many, and rewriting existing code (e.g. handlers returning a map[string]interface{}) should be straightforward.

  • Syntax is straightforward and easy to read and write.

  • Impossible to make Kommentaar output invalid OpenAPI files (if it does, then that's a bug); the syntax doesn't offer too much flexibility, and the tool errors out when it encounters unexpected or wrong input.

  • Reasonably fast and should not exceed more than 2 or 3 seconds for moderate-sized APIs (and it can probably be made faster with some effort).

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].