2
9 Comments

How Do You Write an API Documentation

Hi guy! When you're working on your project API, how do write the documentation and push it online?

on April 26, 2022
  1. 2

    Open API Spec is a good starting place https://swagger.io/tools/swaggerhub/

      1. 1

        There are much better versions out there, you'll want to check out https://openapi.tools for a full list. For instance we use the OpenAPI Explorer.

  2. 1

    When I am working on developing RESTful service, I choose to use go-doudou microservice framework. It has built-in OpenAPI 3.0 specification compatible online document. When your service has been deployed on server, frontend developers can visit the document from /go-doudou/doc page. The document is protected by http basic auth with default username/password admin/admin. Of cource you can configure them. The document supports rendering custom html+css code, means you can write plain text or html + css code behind // as golang comment above go interface declare place and methods, the comments will be rendering on online document.

    BTW, the document ui is written by vuejs+typescript. It can be used standalone or integrated into your own framework by parsing OpenAPI 3.0 json format specification. I integrated it into my another java open source project, too.

    go-doudou repo: https://github.com/unionj-cloud/go-doudou
    document ui repo: https://github.com/unionj-cloud/go-doudou-openapi-ui

  3. 1

    I use postman's documentation framework to share API documentation across teams: https://learning.postman.com/docs/publishing-your-api/documenting-your-api/

  4. 1

    We document using OpenAPI, there are quite a few options out there. The only one I wouldn't use is the SwaggerUI version.

  5. 1

    OpenAPI (previously swagger) or GraphQL is a must. Both support generating types (GraphQL supports generating even more helpers and has a query playground), so that errors in your code are easily detectable. Documentation is great too, but can often be integrated into and generated with OpenAPI or GraphQL too.

    1. 1

      Great! many thanks.