Git Product home page Git Product logo

postmanerator's Introduction

Build Status Coverage Status

What is it?

Some guy said:

How great would it be if we could use Postman's well-maintained collections to generate beautiful documentations with a single command?

Well guess what some guy, now you can use Postmanerator to do so! Can I?

Just download the latest release on Github. You obviously need to pick the right binary depending on your environment. Then place that binary somewhere in your system that is in your PATH, you might want to rename it to simply postmanerator.

Afterwards, export your Postman collection, let's say in $YOUR_PROJECT/postman/collection.json and simply run:

postmanerator -output=./doc.html -collection=$YOUR_PROJECT/postman/collection.json

Or, if you're using Windows Powershell:

postmanerator --output=./doc.html --collection=$YOUR_PROJECT/postman/collection.json

Want to see the result? Take a look at this example. For the record, this documentation is automatically generated by Postmanerator and published on Github Pages using Travis. Feel free to have a look at the source repository.

Configuration

There are chances that the "out-of-the-box" behavior is not good enough for you. Please consider using the following recommendations and command line options to ensure you get the result you expect.

  • Use relevant names and descriptions: folders and requests names are used to create the structure of the generated documentation. You may want to use relevant headers. Furthermore, feel free to write good descriptions for your folders (documentation sections) and requests, as they will be rendered. You may be interested to know that the default theme will parse any Markdown content found in descriptions.
  • Use saved responses: all saved request's responses are rendered in the default theme. You may want to use them to show different potential responses to your users, like a "successful" response or an "invalid data error" response.

Provide a collection file

The collection is a JSON file generated from the Postman UI. You can get more information about Postman collection from the official documentation.

Use the -collection=/path/to/collection.json option to provide the collection to Postmanerator.

Provide an environment file

The environment file is a JSON file generated from the Postman UI. You can get more information about Postman environments from the official documentation.

Use the -environment=/path/to/environment.json option to provide the environment to Postmanerator.

Provide a theme

By default, Postmanerator will use its default theme, but you can change it by using the -theme=theme_name option. You can either provide a theme name from the official themes repository, or a full local path to theme folder.

Provide the output

By default, Postmanerator will print the generated output to the standard output. You can change that by providing a path to the -output=/path/to/generated/doc.html option.

Prevent arbitrary request/response headers to be rendered

Maybe they are some request/response headers you don't want to see in your documentation. You can prevent Postmanerator to render them by providing comma separated lists of headers to the following options:

-ignored-request-headers="Content-Type"
-ignored-response-headers="Content-Type,Content-Length"

Define API structures

You may have noticed that API structures are documented at the beginning of this example generated documentation. Therefore you might be interested to know that these elements are not hard coded in the theme. You actually have the ability to provide these information to Postmanerator. How's that? you asked.

If you know how to use Postman to automate integration tests, then you know that these test cases are written in Javascript. Knowing that, you can now use Javascript to define your API structures for Postmanerator. Consider the following code snippet inserted in any of your requests "Tests" pane:

/*[[start postmanerator]]*/
function populateNewAPIStructures() {
    APIStructures['cat'] = {
        name: 'Cat',
        description: 'A great animal',
        fields: [
            {name: 'id', description: 'A unique identifier for the cat', type: 'int'},
            {name: 'color', description: 'The color of the cat', type: 'string'},
            {name: 'name', description: 'The name of the cat', type: 'string'}
        ]
    };
}
/*[[end postmanerator]]*/

The /*[[start postmanerator]]*/ and /*[[end postmanerator]]*/ delimiters are important, Postmanerator will search for these delimiters to identify the portion of Javascript it needs to interpret.

The name of the function populateNewAPIStructures is also important as Postmanerator will execute this exact function. You can define as many of these code snippets as you need, even in multiple independent requests.

When Postmanerator is done executing all the snippets, it will look for defined objects in the APIStructures global variable and make these structures definitions available for the theme.

Themes

The whole point of Postmanerator is to be able to generate beautiful documentations from a Postman collection. This is done by exposing the collection data with a few helpers to a theme. A theme contains an index.tpl file, this is the only requirement. However it could contain other templates or resources.

List themes

If you want to know the list of themes that are available in your local environment, simply use the following command:

postmanerator themes list

The list of available themes will be printed out to the standard output. By default, themes are located under the $USER_HOME/.postmanerator/themes directory. If you want to change that, simply define the POSTMANERATOR_PATH environment variable.

Download new themes

By now, you probably only have the default theme available, the postmanerator themes get command allows you download a new existing theme. You can either specify the name of one of the themes that are indexed in the official themes repository, or either specify a full URL pointing to git repository. Moreover the -theme-local-name option allows you to change the name of your local copy of the theme. Please see the following examples.

postmanerator themes get markdown # will down the theme 'markdown' and copy it under your local themes directory in a folder named 'markdown'
postmanerator -theme-local-name="my-markdown" themes get markdown # will down the theme 'markdown' and copy it under your local themes directory in a folder named 'my-markdown'
postmanerator themes get https://github.com/aubm/postmanerator-markdown-theme.git # will clone the given repository under your local themes directory, in a folder named 'postmanerator-markdown-theme'
postmanerator -theme-local-name="markdown" themes get https://github.com/aubm/postmanerator-markdown-theme.git # will clone the given repository under your local themes directory, in a folder named 'markdown'

Delete a theme

Use the following command to remove a theme from your local themes directory.

postmanerator themes delete markdown

Create your own theme

So far, all we did was playing with existing themes. While this may be good enough, you may eventually want to customize the look of your documentation. A theme is really just a folder with an index.tpl inside, so starting your own one is not that difficult.

If you start from the existing default, which could be a good idea, you will notice that the syntax is pretty simple. In fact, if you have been writing some Go code, there are chances that you have been playing with the template/text package from the standard library. If so, then good news: you (almost) already know everything you need to know to get started. If not, don't worry, this is relatively easy to learn. Here is the page from the documentation of the language.

While working on your theme, it will quickly become annoying to relaunch the postmanerator command each time you bring a change in the sources. To avoid that, you can use the -watch flag that will do the job for you.

postmanerator -output="/tmp/doc.html" -theme="my-custom-theme" -collection="collection.json" -watch

Postmanerator comes with some handy template helpers that you can use. Let's explore each one of them.

Find a response

To find a specific response for a given request, you can use the following helper:

{{ $res := findResponse $req "response name" }}

Parse markdown content

You can parse some Markdown content using the internal Markdown parser. Typically you may want to do that for the description of a folder or a request.

{{ $desc := markdown $req.Description }}

Format JSON

Sometimes, a JSON string contained somewhere in the collection in not properly formatted. Postmanerator can help you with that, by using the indentJSON helper. Using this helper, you can turn this:

{"firstname": "John", "lastname: "Doe"}

Into this:

{
    "firstname": "John",
    "lastname": "Doe"
}

Here is how:

{{ $formattedJSON := indentJSON $res.RawData }}

Generate a Curl snippet

Postmanerator can generate a Curl snippet from a request, this can be really useful:

{{ curlSnippet $req }}

Generate a HTTP snippet

Alternatively, you can generate a HTTP snippet from a request:

{{ httpSnippet $req }}

Inline some content

Let's assume you are creating a HTML theme, at some point you may want to use libraries downloaded from some CDN like highlightjs or jquery. If so, it is also possible that you want your generated documentation to be fully functional even without an internet connexion.

To help you with that, Postmanerator can download some content on the web, and inline it in your template on the fly. Consider the following example:

<script>{{ inline "https://code.jquery.com/jquery-2.2.2.min.js" }}</script>

To inline local content, you can use to Golang built-in template:

<style>{{ template 'style.css' }}</style>

Generate URL friendly slugs from requests/folders names

To remove special chars and white spaces from an input string, you can use the following helper:

<a href="#{{ slugify $req.Name }}">{{ $req.Name }}</a>

Check for any content

If an endpoint of your API returns an empty response body, Postman may export that saved response body as a non-empty string " " or "\n". As a workaround, Postmanerator provides the hasContent helper which can be used as follow:

{{ if hasContent $res.Data }}
    <pre><code>{{ $res.Data }}</code></pre>
{{ end }}

Installation

As said in the introduction, the easiest way to get it installed for now is to download the latest appropriate release on Github, depending on your system. Then copy it somewhere in your PATH, renaming it to postmanerator.

Alternatively, you can download the source code and compile it by hand. The Go programming language has to be installed on your machine for that.

There is also a community maintained docker image available, simply run:

docker run \
-v [YOUR-PROJECT-PATH]:/usr/var \
hughmp/postmanerator:latest \
-collection /usr/var/[YOUR-COLLECTION.JSON] \
-output /usr/var/[YOUR-HTML.html]

Contributing

Contributions are welcome. Please refer to the contributions guidelines for more information.

License

MIT License

postmanerator's People

Contributors

arush-sal avatar aubm avatar hughmp avatar nabeelvalley avatar testwill 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

postmanerator's Issues

output file fail

Postman(4.5.0) export v1 version
postmanerator -output=./doc.html -collection=mycol.json
and the file
2016-08-02 10 40 50

Nested JSON response

Hi,
I'm using the postmanerator for documenting my API calls, but I have a problem with one use case. One of my responses that I saved are as follows:

 {
  "id": "1234",
  "user": {
    "firstName": "FName",
    "lastName": "LName",
    "email": "[email protected]"
  }
}

But when I run the posmanerator I don't get any result in the response and I think it's because of the nested json. If I change the response to this(wrapping the inner json with an array) then everything works:

 {
  "id": "1234",
  "user": [{
    "firstName": "FName",
    "lastName": "LName",
    "email": "[email protected]"
  }]
}

Do you have any idea what's happening here? maybe I did something wrong? I used the default theme

Extract API structures from collection

One should be able to have access to a list of structures composing the API, in order to render it the way he likes in the documentation.

For example, if the API deals with cats, and exposes endpoints like GET /api/cats, GET /api/cats/{catId} or POST /api/cats, there should be a way to invoke a function that returns the definition of a cat in the API.

Thus, if the user makes a call to GetStructDefinition("Cat"), an object of the following type will be returned :

type StuctDefinition struct {
    Name string
    Description string
    Fields []struct{
        Name string
        Description string
        Type string
    }
}

One way of doing this, is to extract a portion of Javascript code written in the "Tests" section of a Postman request. The portion would be delimited by custom comment markups as in the following example :

// here goes the actual Postman tests ...

/*[[start postmanerator]]*/
var responseBody = JSON.parse(responses['default'].body);
APIStructures['cat'] = {
    name: 'Cat',
    description: 'This structure represents a cat',
    fields: [
        {name: 'id', description: 'A unique identifier for the cat', type: 'int'},
        descriptionForPropertyPath('color'),
        descriptionForPropertyPath('owner.name')
    ]
};
/*[[end postmanerator]]*/

This project could be used to execute the above Javascript code.
responses, descriptionForPropertyPath and APIStructures would be specific variables set in in the VM by postmanerator.

  • responses: a javascript representation of the saved responses for the request.
  • descriptionForPropertyPath: a helper function used to generate a Field object by reflection on a given property of an object.
  • APIStructures: an array the user should populate to add new API structures available for postmanerator.

Not parsing descriptions of request.

I have version v0.9.0, and postman collection.json v.2.1.
I am able to generate the html file, and the description of the folder is generated correctly.
However, the description for each requests are not generated on the html.

Using the same text, copy and paste from the folder's description into the request's description, I still can not see the description generated for each requests, only for folders. Only the name of the request are shown, following by curl/http code.

add: I can see the "description" field in my json file under each request node, so the descriptions are exported indeed. Also I can see them formatted and displayed correctly on Postman.

Any idea?

Generated HTML docs has no API list

I'm exporting from Postman both v1 or v2 of Collection json.
Then I run the command with default theme

./postmanerator -theme="default" -collection=./api.json -output=./docs/api.html

When I open the api.html file, I do not any api api reference in. just the basic structure like this
schermata 2017-05-12 alle 14 39 58

json: cannot unmarshal array into Go value of type string

I got Errors when try to use this with postman collection. I'm using Windows 10 x64.

Here's what I got:

E:\docs>postmanerator.exe -collection E:\docs\PostmanEcho.json.postman_collection
�[31mFailed to parse collection file: json: cannot unmarshal string into Go value of type struct { URL string "json:"url""; Headers []struct { Key string "json:"key""; Value string "json:"value""; Name string "json:"name""; Enabled bool "json:"enabled"" } "json:"headers""; Data string "json:"data""; Method string "json:"method""; DataMode string "json:"dataMode"" }�[0m

Is there any support for Markdown tables?

In the generated output, I get the unrendered table:

| Constant | Definition | | ----------- | ------------------------------------------------------------------------------------- | | weekly | ... | | 

fatal error: runtime: split stack overflow

I get this error with Postman docs v1.0

Generating output ... runtime: newstack sp=0x10a50d3c stack=[0xea184499, 0x2c065]
	morebuf={pc:0x18ccb sp:0x10a50d44 lr:0x0}
	sched={pc:0x185a0 sp:0x10a50d40 lr:0x0 ctxt:0x0}
runtime: gp=0x10c1a0e0, gp->status=0x4
 runtime: split stack overflow: 0x10a50d3c < 0xea184499
fatal error: runtime: split stack overflow

runtime stack:
runtime.throw(0x4b7ee0, 0x1d)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/runtime/panic.go:527 +0x79
runtime.newstack()
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/runtime/stack1.go:746 +0x797
runtime.morestack()
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/runtime/asm_386.s:336 +0x66

goroutine 19 [stack growth]:
runtime.(*bgMarkSignal).wait(0x741b4c)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/runtime/mgc.go:723 fp=0x10a50d44 sp=0x10a50d40
runtime.gc(0x0)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/runtime/mgc.go:1037 +0x29b fp=0x10a50fc8 sp=0x10a50d44
runtime.backgroundgc()
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/runtime/mgc.go:896 +0x31 fp=0x10a50fe0 sp=0x10a50fc8
runtime.goexit()
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/runtime/asm_386.s:1662 +0x1 fp=0x10a50fe4 sp=0x10a50fe0
created by runtime.startGC
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/runtime/mgc.go:869 +0x146

goroutine 1 [runnable]:
runtime.Gosched()
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/runtime/proc.go:166 +0x10
regexp.(*bitState).reset(0x10fbc080, 0x14, 0x2)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/regexp/backtrack.go:87 +0xe1
regexp.(*machine).backtrack(0x10fc2000, 0x8336a8, 0x10fc206c, 0x0, 0x14, 0x2, 0x11ca6)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/regexp/backtrack.go:324 +0xc7
regexp.(*Regexp).doExecute(0x10fc0060, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10fb60a0, 0x14, 0x0, 0x2, ...)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/regexp/exec.go:449 +0x356
regexp.(*Regexp).replaceAll(0x10fc0060, 0x0, 0x0, 0x0, 0x10fb60a0, 0x14, 0x2, 0x10b4ec48, 0x0, 0x0, ...)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/regexp/regexp.go:486 +0xc9
regexp.(*Regexp).ReplaceAllString(0x10fc0060, 0x10fb60a0, 0x14, 0x462c30, 0x1, 0x0, 0x0)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/regexp/regexp.go:449 +0xbb
github.com/aubm/postmanerator/theme/helper.slugify(0x10afd0a0, 0x14, 0x0, 0x0)
	/home/travis/gopath/src/github.com/aubm/postmanerator/theme/helper/helper.go:168 +0x83
reflect.Value.call(0x3d0360, 0x5e9ba8, 0x13, 0x463f38, 0x4, 0x10fb8000, 0x1, 0x1, 0x0, 0x0, ...)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/reflect/value.go:432 +0xee2
reflect.Value.Call(0x3d0360, 0x5e9ba8, 0x13, 0x10fb8000, 0x1, 0x1, 0x0, 0x0, 0x0)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/reflect/value.go:300 +0x86
text/template.(*state).evalCall(0x10b4fc38, 0x4131a0, 0x10be5af4, 0x56, 0x3d0360, 0x5e9ba8, 0x13, 0x30b1f028, 0x10bf80c0, 0x10be2bb9, ...)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/text/template/exec.go:602 +0x921
text/template.(*state).evalFunction(0x10b4fc38, 0x4131a0, 0x10be5af4, 0x56, 0x10bf80e0, 0x30b1f028, 0x10bf80c0, 0x10bfa070, 0x2, 0x2, ...)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/text/template/exec.go:475 +0x287
text/template.(*state).evalCommand(0x10b4fc38, 0x4131a0, 0x10be5af4, 0x56, 0x10bf80c0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/text/template/exec.go:372 +0x15f
text/template.(*state).evalPipeline(0x10b4fc38, 0x4131a0, 0x10be5af4, 0x56, 0x10bfc000, 0x0, 0x0, 0x0)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/text/template/exec.go:345 +0x13a
text/template.(*state).walk(0x10b4fc38, 0x4131a0, 0x10be5af4, 0x56, 0x8337c8, 0x10bf8160)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/text/template/exec.go:180 +0x100
text/template.(*state).walk(0x10b4fc38, 0x4131a0, 0x10be5af4, 0x56, 0x30b1f000, 0x10be47a0)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/text/template/exec.go:188 +0x67d
text/template.(*state).walkIfOrWith(0x10b4fc38, 0x13, 0x39f7a0, 0x10a7f478, 0xd8, 0x10be6210, 0x10be47a0, 0x0)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/text/template/exec.go:216 +0x1df
text/template.(*state).walk(0x10b4fc38, 0x39f7a0, 0x10a7f478, 0xd8, 0x30adf000, 0x10bf8ea0)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/text/template/exec.go:199 +0x547
text/template.(*state).walk(0x10b4fc38, 0x39f7a0, 0x10a7f478, 0xd8, 0x30b1f000, 0x10be4640)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/text/template/exec.go:188 +0x67d
text/template.(*state).walkRange.func1(0x39f3a0, 0x10be8880, 0x42, 0x39f7a0, 0x10a7f478, 0xd8)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/text/template/exec.go:270 +0x13f
text/template.(*state).walkRange(0x10b4fc38, 0x433e40, 0x10a462ec, 0xd9, 0x10bf8f20)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/text/template/exec.go:279 +0x3bd
text/template.(*state).walk(0x10b4fc38, 0x433e40, 0x10a462ec, 0xd9, 0x8338b8, 0x10bf8f20)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/text/template/exec.go:191 +0x205
text/template.(*state).walk(0x10b4fc38, 0x433e40, 0x10a462ec, 0xd9, 0x30b1f000, 0x10be41a0)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/text/template/exec.go:188 +0x67d
text/template.(*state).walkIfOrWith(0x10b4fc38, 0x13, 0x433e40, 0x10a462ec, 0xd9, 0x10be6060, 0x10be41a0, 0x0)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/text/template/exec.go:216 +0x1df
text/template.(*state).walk(0x10b4fc38, 0x433e40, 0x10a462ec, 0xd9, 0x30adf000, 0x10bf8f60)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/text/template/exec.go:199 +0x547
text/template.(*state).walk(0x10b4fc38, 0x433e40, 0x10a462ec, 0xd9, 0x30b1f000, 0x10be4120)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/text/template/exec.go:188 +0x67d
text/template.(*state).walkRange.func1(0x39f3a0, 0x10ebc670, 0x42, 0x433e40, 0x10a462ec, 0xd9)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/text/template/exec.go:270 +0x13f
text/template.(*state).walkRange(0x10b4fc38, 0x448ac0, 0x10c10460, 0x59, 0x10bf8fc0)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/text/template/exec.go:279 +0x3bd
text/template.(*state).walk(0x10b4fc38, 0x448ac0, 0x10c10460, 0x59, 0x8338b8, 0x10bf8fc0)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/text/template/exec.go:191 +0x205
text/template.(*state).walk(0x10b4fc38, 0x448ac0, 0x10c10460, 0x59, 0x30b1f000, 0x10b56d00)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/text/template/exec.go:188 +0x67d
text/template.(*Template).Execute(0x10b56ca0, 0x833178, 0x10a586d0, 0x448ac0, 0x10c10460, 0x0, 0x0)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/text/template/exec.go:143 +0x20b
text/template.(*Template).ExecuteTemplate(0x10b56be0, 0x833178, 0x10a586d0, 0x487478, 0x9, 0x448ac0, 0x10c10460, 0x0, 0x0)
	/home/travis/.gimme/versions/go1.5.linux.amd64/src/text/template/exec.go:123 +0x1db
main.generate(0x833178, 0x10a580d8, 0x10a586d0, 0x10b56ba0, 0x3, 0x4, 0x10a9d0a0)
	/home/travis/gopath/src/github.com/aubm/postmanerator/main.go:188 +0x6a9
main.defaultCommand(0x833178, 0x10a580d8, 0xbffff99a, 0xc, 0x0, 0x0, 0xbffff986, 0x7, 0xbffff9af, 0xc, ...)
	/home/travis/gopath/src/github.com/aubm/postmanerator/main.go:161 +0x814
main.main()
	/home/travis/gopath/src/github.com/aubm/postmanerator/main.go:83 +0x37

Provide an environnement file

Currently, postmanerator doesn't know about environnement variables when generating the documentation. That leads to (for example), curl snippets like the one below:

curl -X GET "http://{{domain}}/api/cats"

The postman UI provides a way to export an environnement in a JSON format. One should be able to provide this exported file, in completing of the collection file, in order to have to generate a rendering like the following:

curl -X GET "http://my-awesome.com/api/cats"

The environnement should be provided as a command line argument:

postmanerator -output="doc.html" -theme="my/theme/location" -environnement="env.json" collection.json

Write a good documentation

The README.md file should provide a clear and elegant documentation.

The two main subjects should be:

  • the usage of the command line interface
  • the creation of a custom theme

No longer works with v1.0 JSON output from Postman v7.0.9

As of Postman v. 7.0.9, parameter args are no longer parsed. Output only includes CURL and HTTP request and response; no parameter descriptions are generated.

Also, there is apparently no support for v2.0/v2.1 (v1.0 has been deprecated). Docs don't reflect this (or is not easily found), would be cool if they did.

Move themes to their own git repository

As the two default themes are not included in the binary, they should be moved into their own git repository.

One idea is to create one git repository for each theme, and a third repository to aggregate all the themes using the git submodules mechanism. That way, one could create a theme for his/her own usage, and submit a pull request to this repository to give visibility to it.

Postmanerator detailed install document

Hi,

I am new to Sparx tool and trying to add postmanerator to it. Does anyone have a detailed installation guide explaining step by step procedure to get this done.

If available, you can also mail me that document to [email protected]

Thanks,
Sundar

Default theme does not appear.

I have the following error:
error

I have installed Git in my operative system(Windows 10 Pro ) and my file is updated

screenshot 3

I don't understand why it occurs this issue.

Postmanerator as a service

Hey, firstly thank you for making this, it's awesome :)

I made a very simple api which takes a URL or a JSON object and converts it to an html page using Postmanerator.

It's hosted here: https://postmanerator.now.sh

Just give it a URL like this:

https://postmanerator.now.sh?collection=https://raw.githubusercontent.com/heremaps/postman-collections/master/location-custom.postman_collection

and it'll perform the magic :)

I'll make it describe itself shortly!

Got a few ideas for this which would be great to collaborate on if you fancy?

help required

i placed folder inside D: drive .after that when i am running the command "postmanerator -output=D:\postmanerator\doc.html -collection=D:\postmanerator\Learn jwt.postman_collection.json" gives error postmanerator is not recognized as internal or external command

Update the default markdown theme

The default HTML theme now makes use of curl/http snippets, and provides a navigation menu. The default markdown theme should be updated in the same way.

Watch option

The feature would allow the user to automatically regenerate the output file when the theme sources are modified.

index.tpl:76: function "findRequest" not defined

I've downloaded the latest windows exe file but when I try to run it throws this error:

Generating output... �[31mFAIL. template: index.tpl:76: function "findRequest" not defined�[0m

Same result with another theme:

Generating output... �[31mFAIL. template: index.tpl:40: function "findRequest" not defined�[0m

I tried with all 3 postman collection versions (v1, v2, v2.1) but the same error appears

Failed to parse environment file: json: cannot unmarshal number into Go struct field .value of type string

I can parse a collection fine using the following command--

postmanerator -output=./doc.html -collection=/var/www/[email protected]/config/postman_collection.json

this will show me a success message, however when i try and attach my corresponding environment variables, i get the following error:

postmanerator -output=./doc.html -collection=/var/www/[email protected]/config/postman_collection.json -environment=/var/www/[email protected]/config/postman_environment.json

Failed to parse environment file: json: cannot unmarshal number into Go struct field .value of type string

Upon inspection of the postman_environment.json file i have seen the few lines which are causing the issue by a process of elmination:

{
"key": "expires_in",
"value": 31536000,
"enabled": true,
"type": "text"
},

{
"key": "device_id",
"value": 22,
"enabled": true,
"type": "text"
},

It appears that upon inspecting a integer value which is labeled as a text type, postmanerator will read as a string. I can fix the issue by surrounding the value in quotes, however we wish to make the process of documentation automated. Thanks

Error: function "findRequest" not defined

Hi there,

I try to run postamnerator.exe on a simple Postman collection.

Command:
postmanerator.exe -collection .\Test.postman_collection.json -output ./doc.html

Output:
Generating output... FAIL. template: index.tpl:76: function "findRequest" not defined

The file (in Collection v1 format)
{ "id": "4057bcfb-3544-fb26-5394-e95830a73fa7", "name": "Test", "description": "", "order": [], "folders": [ { "name": "Test Folder", "description": "", "collectionId": "4057bcfb-3544-fb26-5394-e95830a73fa7", "order": [ "97344fd0-4575-d8d8-6193-d01aaa0c840b" ], "owner": "879589", "folders_order": [], "id": "68214c4e-5140-9cec-21cc-0f1ec9103b03" } ], "folders_order": [ "68214c4e-5140-9cec-21cc-0f1ec9103b03" ], "timestamp": 1505925551843, "owner": "879589", "public": false, "requests": [ { "id": "97344fd0-4575-d8d8-6193-d01aaa0c840b", "headers": "Content-Type: application/json\n", "headerData": [ { "key": "Content-Type", "value": "application/json", "description": "", "enabled": true } ], "url": "http://www.google.fr", "queryParams": [], "pathVariables": {}, "pathVariableData": [], "preRequestScript": null, "method": "GET", "collectionId": "4057bcfb-3544-fb26-5394-e95830a73fa7", "data": [], "dataMode": "raw", "name": "http://www.google.fr", "description": "", "descriptionFormat": "html", "time": 1505925598916, "version": 2, "responses": [], "tests": null, "currentHelper": "normal", "helperAttributes": {}, "folder": "68214c4e-5140-9cec-21cc-0f1ec9103b03", "rawModeData": "" } ] }

Failed to parse collection file, all parsers failed

Hi there,

I'm unable to create html docs, postamanerator gives me error metioned above.

Command used:
./postmanerator-0.8.0 -output=/path/to/output/collect.html -collection=/path/to/MyCollection.postman_collection.json -environment=/path/to/MyCollection.postman_environment.json

Tried to export collection using Postman's collection schema version 1, 2 and 2.1.
Additionally I've tried to use environment option with exported environment, but with no luck too.

I built postmanerator from source code, MacOS HighSierra 10.13.3.

Same name in different folders example error

When you have 2 different folders having items with same name within it breaks the example navigation.

- resource 1 folder
  - v1 endpoint
     |curl example|http example|
  - v2 endpoint
     |curl example|http example|

- resource 2 folder
  - v1 endpoint
     |curl example|http example|
  - v2 endpoint  
     |curl example|http example|

When you click on v2 endpoint http example from resource 2 folder it is showed in resource 1 folder > v2 endpoint > http example box

Allow to ignore arbitrary headers in curl and http snippets

Several possibilities:

  • use a flag, as in the following example: postmanerator -theme="/theme/path" -ignore-headers=["Accept", "Postman-Token"] collection.json
  • use template helpers arguments to define ignored headers directly from the template: curlSnippet $req "Accept" "Postman-Token"
  • use a javascript code snippet that the user has to define in the "tests" tab of postman requests (in the UI).

"Define API structures" & Subfolders are not shown up in the generated html file

I have this following code in one of the requests "Test" tab but not seen in the generated html and also, all the requests are arranged in alphabetical order instead of sub folders structure - please refer the image. Any help will be highly appreciated, thanks.
/[[start postmanerator]]/
function populateNewAPIStructures() {
APIStructures['Blueprint'] = {
name: 'Blueprint',
description: 'Blueprints are the architectural guidelines to build things. Blueprints are designed to provide you with a framework that you can construct multiple data instances from',
fields: [
{name: 'NodeType', description: 'You can create different node types and assign the required fields into it', type: 'xxx'},
{name: 'Edges', description: 'The links between the nodes', type: 'string'},
{name: 'Fields', description: 'Different types of data., Textbox, number, Memo etc', type: 'xxx'}
]
};
}
/[[end postmanerator]]/

postmanerator_html

The postman collection looks like this:
postmanerator_postman

*NOTE
As the postman did not included the "postmanerator" related scripts, i have manually updated them and it looks like in the JSON file.

"events": [
{
"listen": "test",
"script": {
"id": "44b78a2a-7373-42bc-8920-f0c361bc1391",
"exec": [
"pm.test("Status code is 200", function () {",
" pm.response.to.have.status(200);",
"});",
"",
"",
"(pm.response.code===200 ? pm.test : pm.test.skip)("Response returned valid guid", function () {",
" ",
" pm.expect(pm.response.text()).to.include(pm.environment.get("BlueprintId"));",
" pm.environment.set('BlueprintData', pm.response.text());",
" ",
"});",
"",
"",
"/[[start postmanerator]]/",
"function populateNewAPIStructures() {",
"var responseBody = JSON.parse(responses['default'].body);",
"APIStructures['Blueprints'] = {",
"name: 'Blueprint',",
"description: 'Blueprints are the architectural guidelines to build things. Blueprints are designed to provide you with a framework that you can construct multiple data instances from',",
"fields: [",
"{name: 'Node Type', description: 'You can create different node types and assign the required fields into it', type: 'xxx'},",
"{name: 'Edges', description: 'The links between the nodes', type: 'string'},",
"{name: 'Fields', description: 'Different types of data., Textbox, number, Memo etc', type: 'xxx'}",
"]",
"};",
"}",
"/[[end postmanerator]]/",

"",
""
],

I am using Postman version # 6.7.3 and Windows 10 pro in my system.

Provide a subtring template helper

The idea is to provide a way for the user to print a sub string for a given input.

As Postman does not allow manual ordering of folders in a collection, a workaround is to prefix folders name with a number.

01 - Libraries
02 - Books

One use case would be to remove this prefix from the name of a request.

Add Dockerfile

It would be cool to use Docker, don'tcha reckon?

Here's a PR for starters: #35 👍

Using `hu` theme gives an error

Used following command to download theme

postmanerator themes get hu

It was downloaded successfully. Running postmanerator themes list does show it in list. Tried to create documentation using following command.

postmanerator -collection=collection.json -environment=environment.json -theme=hu -output=output/index.html

Terminal throws following error:

Generating output... FAIL. template: index.tpl:92: function "findRequest" not defined

Same withmarkdown theme. Only default theme is working.

FAIL. template: index.tpl:40: function "findRequest" not defined

I'm using the latest available binary and I was trying Postman v1.0, v2.0 and recommended v2.1 but I get always:

$ postmanerator_darwin_386 -theme="markdown" -collection=./aiapi.json -output=./aiapi.html
Generating output... FAIL. template: index.tpl:40: function "findRequest" not defined

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.