GithubHelp home page GithubHelp logo

gastrodon / persim Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 43 KB

A tool for generating HTTP/REST docs in Markdown from Yaml

License: GNU Affero General Public License v3.0

Python 100.00%
yaml swagger api-documentation documentation-tool documentation-generator yaml-document rest-api rest-documentation documentation

persim's Introduction

Persim

A tool for generating HTTP/REST docs in Markdown from Yaml

Swagger may cause confusion. A persim berry might help with that

TODO

  • Load yml files as a dict
  • Add globals where they belong
    • request_headers
    • response_headers
    • responses
  • Add vars where they belong
  • Sort the parsed dict
  • Render the parsed dict to markdown
    • Path arguments
    • Everything else
  • Write it to something

Usage

Yaml parsed by this tool has 3 main sections, globals, vars, and routes.

Globals

globals are common pieces of information that are a part of every request of some method, and are added to each of those. As of yet, planned supported globals are - request_headers: for headers that are a part of a request - response_headers: for headers that are a part of a responses - responses: responses that any endpoint can return

globals can be specified in the following tree. Keep in mind that method may be a specific method, or a wildcard to be added to all methods

<type>:
    <method>:
        foo

Any time that a global is shadowed by a manually inserted value. For example where there is a document that looks like so:

globals:
    responses:
        "*":
            404: foo

routes:
    /:
        GET:
            ...
            responses:
                404: bar

the global 404 will not be added into the response for GET /

Vars

vars are variables. They can be nested and accessed using dot notation. To reference a variable, prefix the value with a $

For example the following YAML

vars:
    response:
        get_root:
            lang: JSON
            content: {"online": true}

routes:
    /:
        GET:
            ...
            responses:
                200: $response.get_root

would render in the same way as

routes:
    /:
        GET:
            ...
            responses:
                200:
                    lang: JSON
                    content: {"online": true}

Routes

routes are the primary content of the yaml, and what is rendered. A basic outline looks like this

routes:
    <route>:
        <method>:
            description: route description
            path_arguments:
                - list of
                - path arguments
            headers:
                - list of
                - headers
            query_strings:
                - list of
                - query strings
            body: request body, if any
            responses:
                code: response pairs

They take supplementing fields that look like these

headers, path arguments, and query strings

object:
    name: field name
    value: field value
    required: true | false

They look the same, just put them in the right place

body

body:
    lang: language for markdown syntax highlighting
    content: body content

response

code:
    title: response title
    description: response description
    body: response body

The body is in the same format as the body of a request

persim's People

Contributors

gastrodon avatar

Stargazers

 avatar

Watchers

 avatar

persim's Issues

README is out of date

The README.md is super stale, and doesn't reflect how the program actually works. This may make collaboration hard

Some data not sieving

Some data in gastrodon/api-docs/project-z/vars_data.yml is not sieving, and the rendered data still has $values in it

Partial variables are matched

Consider the table

vars:
    foo: I'm only foo
    foobar: I'm foo but with bar
 
routes:
   ...
   description: I want $foobar

This may result in I want I'm only foobar because only $foo is matched from $foobar, and the rest of the word bar is treated as a string literal

Sort routes

Before the rewrite, routes were sorted alphabetically, which as a natural consequence resulted in nested routes being followed, for instance

/foo/:
    ...
/foo/:some/:
   ...
/zag/:
   ...

This was not added again because @gastrodon forgot and is lazy!

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.