Giter VIP home page Giter VIP logo

hiro's Introduction

Hiro

Generates HTML from API Blueprints using the Snow Crash command line tool Drafter and Iglo.

GoDoc License MIT

Dependencies

Hiro requires Drafter v3.x to be installed.

Any newer release is not supported due to usage of the deprecated --type=ast option (apiaryio/drafter@a7dd4c5).

Install it on OS X using Homebrew:

$ brew install --HEAD \
  https://raw.githubusercontent.com/apiaryio/drafter/stable/3.x/tools/homebrew/drafter.rb

Refer to the Drafter build notes if you are using a different OS.

Installation

$ go get -u github.com/peterhellberg/hiro

You can also download binaries from the releases page.

Usage

$ hiro --help

Command line arguments:

  -input="blueprint.md": Input file (.md)
  -output="index.html": Output file (.html)
  -template="": Iglo template file

Example

# Service Name

A short description of the service.

## Group Group 1

A description of this group of endpoints

## /endpoint

+ Parameters
  + foo (required, string, `example`)
  A description of the foo parameter
  + bar (optional, integer, `123`)
  A description of the bar parameter

### GET

A description of the endpoint.

header | another header
-------|---------------
foo    | bar
baz    | qux

> A quote related to the endpoint

**Bold text**

    func some(code Example) string {
      return "related to the endpoint"
    }

+ Response 200 (application/json; charset=utf-8)
  + Headers
  X-Example header
  + Body
  {"endpoint": "response"}

## Group Group 2

A description of this group of endpoints.

Hiro Blueprint Output

License (MIT)

Copyright (c) 2015-2016 Peter Hellberg

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

hiro's People

Contributors

jean avatar msageryd avatar peterhellberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hiro's Issues

Response .Body is empty

Using the latest version of the drafter I don't see the body or example of the response.

Input .md

FORMAT: 1A

# AD

# Group Sections

## GET /homepage

+ Response 200 (application/json)

    + Attributes

        + title: This is a title (string)
        + detailUrl: http://website.com/detail-url (string)

Output:
image

"Panic" with simple Markdown file

I wish I knew more about go to be of any use, but I've tried this a few times with some pretty simple markdown and hiro always throws the same error. I've checked the files with snowcrash, and they seem to parse correctly.

I'm not confident if this is an issue with hiro or with iglo?

Here's the Markdwn

FORMAT: 1A
HOST: http://api.test.com/v1/

# Test v1
Test API Version 1.

# Group Session Handling
Two simple end points to establish and destroy sessions. These sessions will keep track
of user information across multiple requests for you.

Here's the snowcrash output

$ snowcrash /Users/johannes/code/xx/webapp/app/Controller/api/api_blueprint.md

_version: 2.0
metadata:
- name: "FORMAT"
  value: "1A"
- name: "HOST"
  value: "http://api.test.com/v1/"
name: "Test v1"
description: "Test API Version 1.\n\n"
resourceGroups:
- name: "Session Handling"
  description: "Two simple end points to establish and destroy sessions. These sessions will keep track\nof user information across multiple requests for you."
  resources:

OK.

Here's the output of hiro:

$ go run main.go -input="/Users/johannes/code/xx/webapp/app/Controller/api/api_blueprint.md" -output="/Users/johannes/Desktop/test.html"
panic: json: cannot unmarshal array into Go value of type iglo.Metadata

goroutine 1 [running]:
runtime.panic(0x179440, 0x2104d4ac0)
    /usr/local/go/src/pkg/runtime/panic.c:266 +0xb6
main.check(0x45f448, 0x2104d4ac0)
    /Users/johannes/code/gocode/src/github.com/peterhellberg/hiro/main.go:17 +0x4f
main.main()
    /Users/johannes/code/gocode/src/github.com/peterhellberg/hiro/main.go:66 +0x32c
exit status 2

Docs not showing up

hiro is now generating an HTML file containing the correct content, but it's still rendering as a mostly blank page (there's a header, a subtitle, and a little blue box). I thought this was due to prettify not loading, so I created #4 to fix that.

However now I'm not even seeing run_prettify.js being requested. I'm not sure whether this due to Github's CDN. If I change to e.g. https://raw.githubusercontent.com/google/code-prettify/7be640cbb18dbc437b0d06a8d2467ae57c6938e5/loader/run_prettify.js it is retrieved, but the CSS still isn't requested.

There's no errors in the browser console; this is on firefox and chrome.

If I delete the script tag which sources bootstrap.min.css, the content does appear, and I can toggle display of snippets.

Render markdown in "outer group sections" and "header section"

I don't know if I have missed something, but I cannot get this to work. It would be really great if it could work..

Other than this I really like the simplicity of Hiro, as well as the nicely rendered documentation.

Consider this apiblueprint file:

FORMAT: 1A9
HOST: https://api.myspecialapi.com/

# My special API

## Background (this heading will not be rendered as a heading)

I would like to be able to describe stuff here using **markdown syntax**, 
but the renderer doesn't parse the section under the "My special API" 
heading as markdown. Everything will render as plain text.

## Usage

Bla bla..
----

# Group Items

I would like to be able to use markdown here as well. 
Apiary.io handles this well.

## This heading will not be rendered as a heading.

## List Items [/items]

.
.
.

Blank output generated

I use the api.apib file as exported from apiary.com
The generated file looks like it contains only scaffolding.
No error is shown.

I get the same result when I give iglo's demo as input.

~/local/go$ ./bin/hiro -input=/home/john/local/go/src/github.com/subosito/iglo/examples/API.md -output=output.html 

If I use iglo directly (after hacking main.go to point at the my apib file), I do get the correct output:

~/local/go/src/github.com/subosito/iglo/examples/api-exporter$  go run main.go 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.