iglo

package module
v0.0.0-...-83f8872 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 3, 2016 License: MIT Imports: 12 Imported by: 8

README

iglo

API blueprint's formatter.

Build Status

Status

DEPRECATED. Please use https://github.com/subosito/snowboard instead.

Writing API documentation

For writing API documentation, the iglo using API Blueprint syntax. You can read about its specification.

Here's the example:

FORMAT: 1A
HOST: https://api.example.com/v1

# Hello API

A simple API demo

# Group People

This section describes about the People

## Person [/people/{id}]

Represent particular Person

+ Parameters

    + id (required, string, `123`) ... The id of the Person.

+ Model (application/json)

    ```
    {"name":"Gesang","birthdate":"01-09-1917"}
    ```

### Retrieve Person [GET]

Return the information for the Person

+ Request (application/json)

    + Headers

        ```
        Authorization: Basic AbcdeFg=
        ```

+ Response 200 (application/json)

    [Person][]

Demo

Make sure you have iglo installed in the GOPATH

$ cd $GOPATH
$ go get github.com/subosito/iglo
Serving as HTTP

You can go to the examples/api-server directory and then run the main.go.

$ cd examples/api-server
$ go run main.go

Then visit http://localhost:8080/ to see the output.

Or, you can just visit this demo page :)

Exporting as HTML file

You can go to the examples/api-exporter directory and then run the main.go.

$ cd examples/api-exporter
$ go run main.go -out "api-output.html"

Now you have HTML generated output in the api-output.html.

Dependencies

The iglo ParseMarkdown requires drafter to be installed. Refer to the drafter page for the installation details.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Tmpl = `` /* 4612-byte string literal not displayed */

Functions

func CheckVersion

func CheckVersion(v string) error

func HTML

func HTML(w io.Writer, api *API) error

func HTMLCustom

func HTMLCustom(s string, w io.Writer, api *API) error

func JSONToHTML

func JSONToHTML(w io.Writer, r io.Reader) error

func JSONToHTMLCustom

func JSONToHTMLCustom(s string, w io.Writer, r io.Reader) error

func MarkdownToHTML

func MarkdownToHTML(w io.Writer, r io.Reader) error

func MarkdownToHTMLCustom

func MarkdownToHTMLCustom(s string, w io.Writer, r io.Reader) error

func ParseMarkdown

func ParseMarkdown(r io.Reader) ([]byte, error)

Types

type API

type API struct {
	Version  string    `json:"_version"`
	AST      AST       `json:"ast"`
	Error    Error     `json:"error"`
	Warnings []Warning `json:"warnings"`
}

func ParseJSON

func ParseJSON(r io.Reader) (*API, error)

type AST

type AST struct {
	Version        string          `json:"_version"`
	Name           string          `json:"name"`
	Description    string          `json:"description"`
	Metadata       []Metadata      `json:"metadata"`
	ResourceGroups []ResourceGroup `json:"resourceGroups"`
}

type Action

type Action struct {
	Name        string      `json:"name"`
	Description string      `json:"description"`
	Method      string      `json:"method"`
	Parameters  []Parameter `json:"parameters"`
	Examples    []Example   `json:"examples"`
}

type Error

type Error struct {
	Code     int      `json:"code"`
	Message  string   `json:"message"`
	Location []string `json:"location"`
}

type Example

type Example struct {
	Name        string     `json:"name"`
	Description string     `json:"description"`
	Requests    []Request  `json:"requests"`
	Responses   []Response `json:"responses"`
}

type Format

type Format struct {
	Value string `json:"value"`
}
type Header struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type Host

type Host struct {
	Value string `json:"value"`
}

type Location

type Location struct {
	Index  int `json:"index"`
	Length int `json:"length"`
}

type Metadata

type Metadata struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

type Model

type Model struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Headers     []Header `json:"headers"`
	Body        string   `json:"body"`
	Schema      string   `json:"schema"`
}

type Parameter

type Parameter struct {
	Name        string  `json:"name"`
	Description string  `json:"description"`
	Type        string  `json:"type"`
	Required    bool    `json:"required"`
	Default     string  `json:"default"`
	Example     string  `json:"example"`
	Values      []Value `json:"values"`
}

type Request

type Request struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Headers     []Header `json:"headers"`
	Body        string   `json:"body"`
	Schema      string   `json:"schema"`
}

type Resource

type Resource struct {
	Name        string      `json:"name"`
	Description string      `json:"description"`
	UriTemplate string      `json:"uriTemplate"`
	Model       Model       `json:"model"`
	Parameters  []Parameter `json:"parameters"`
	Actions     []Action    `json:"actions"`
}

type ResourceGroup

type ResourceGroup struct {
	Name        string     `json:"name"`
	Description string     `json:"description"`
	Resources   []Resource `json:"resources"`
}

type Response

type Response struct {
	Name        string   `json:"name"`
	Description string   `json:"description"`
	Headers     []Header `json:"headers"`
	Body        string   `json:"body"`
	Schema      string   `json:"schema"`
}

type Value

type Value struct {
	Value string `json:"value"`
}

type Warning

type Warning struct {
	Code     int        `json:"code"`
	Message  string     `json:"message"`
	Location []Location `json:"location"`
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL