Code Monkey home page Code Monkey logo

apib2swagger's Introduction

apib2swagger

Build Status Coverage Status npm version

Convert API Blueprint to Swagger 2.0 or OpenAPI 3.0.

Supported versions:

  • API Blueprint 1A9
  • Swagger 2.0
  • OpenAPI 3.0.3
  • Node.js 18.x, 20.x or higher

Install

$ npm install -g apib2swagger

Usage

Convert to Swagger specification.

$ apib2swagger -i api.md
$ apib2swagger -i api.md -o swagger.json
$ apib2swagger -i api.md --yaml -o swagger.yaml
$ apib2swagger -i api.md --prefer-reference
$ apib2swagger -i api.md --bearer-apikey
$ apib2swagger -i api.md --open-api-3
$ apib2swagger -i api.md --info-title "My API Document Title"
$ apib2swagger -i api.md --prefer-file-ref

Without -i option it reads from STDIN, without -o option writes to STDOUT.

$ apib2swagger < api.md > swagger.json
$ cat api.md | apib2swagger

Run http server with SwaggerUI. SwaggerUI will be automatically downloaded to current dir.

$ apib2swagger -i api.md -s
$ apib2swagger -i api.md -s -p 3000

# When using file references and running the SwaggerUI server, you can specify the source
# directory with the -sd flag. It will check the input directory and execution directory
# if -sd is not given.
$ apib2swagger -i api.md -s --prefer-file-ref -sd ~/project/src/

Use as a library.

var apib2swagger = require('apib2swagger'),
    apib = '...',
    options = { 
        preferReference: true, 

        // optional (Swagger 2.0 only).
        bearerAsApikey: false,

        // optional. swagger 2.0 is used by default.
        openApi3: true, 

        // optional. title will be grabbed from blueprint if not specified.
        infoTitle: 'My API Document Title', 

        // optional (Open API 3 only). 
        // will set a $ref to the given file path instead of including the file contents.
        preferFileRef: true 
    };

apib2swagger.convert(apib, options, function (error, result) {
    if (!error) console.log(result.swagger);
});

npx

You can run apib2swagger via npx (without first needing to install it) like so:

cat api.md | npx apib2swagger > swagger.json

Docker

You can also run apib2swagger inside a docker container.

$ docker run -it --rm -v $(pwd):/docs ghcr.io/kminami/apib2swagger -i /docs/api.md -o /docs/swagger.json

License

Copyright (c) 2021 Keisuke Minami

MIT

apib2swagger's People

Contributors

abailinrun avatar aparrett-hbo avatar cbarraford avatar dependabot[bot] avatar espencer avatar funkeyfreak avatar ivangoncharov avatar kareljakubec avatar kminami avatar rbren avatar simonw avatar vasiliyb avatar vlasy avatar x-jason-hu avatar zihaoyu 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

apib2swagger's Issues

<!-- include(file.apib) --> files do not get imported

As a user, if I have a base file with an <!-- include(file.apib) --> tag pointing to another file, I would expect that it would be included correctly when running apib2swagger -i api-guide.apib -o api-guide-swagger.json

OpenAPI3 output does not handle nullable values correctly

Nominal

Rendering an API Blueprint document to OpenAPI3 with flag --open-api-3 converts an input property like this:

    + errors (required, array, nullable)

into this:

  errors:
    type: array
    nullable: true
    items: {}

Actual

Rendering an API Blueprint document to OpenAPI3 with flag --open-api-3 converts an input property like this:

    + errors (required, array, nullable)

into this:

  errors:
    type:
      - array
      - 'null'
    items: {}

Remarks

According to the OpenAPI spec »null is not supported as a type« and instead the nullable property must be used.

nullable type is not probably handled.

Problem : When nullable type is specified along with primitive type or required optional type, it was not probably handled, or we say missing handling.

Solution : Add nullable type handling in mson schema convert process.

apib file

# Group Users

## A user [/user]

### Get one user [GET]
+ Response 200 (application/json)
  + Attributes (User)
+ Response 500 (application/json)

## Some users [/users]

### Get a collection of users [GET]
+ Response 200 (application/json)
  + Attributes (array[User])
+ Response 500 (application/json)

# Data Structures

## User (object)
+ id (string, required)
+ name (string, nullable, required)

## Users (object)
+ `users`(array[User], nullable, required)

json file

{
    "swagger": "2.0",
    "info": {
        "title": "",
        "version": "",
        "description": ""
    },
    "paths": {
        "/user": {
            "get": {
                "responses": {
                    "200": {
                        "description": "OK",
                        "headers": {},
                        "examples": {
                            "application/json": {
                                "id": "",
                                "name": null
                            }
                        },
                        "schema": {
                            "type": "object",
                            "properties": {
                                "id": {
                                    "type": "string"
                                },
                                "name": {
                                    "type": [
                                        "string",
                                        "null"
                                    ]
                                }
                            },
                            "required": [
                                "id",
                                "name"
                            ]
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "headers": {},
                        "examples": {}
                    }
                },
                "summary": "Get one user",
                "operationId": "Get one user",
                "description": "",
                "tags": [
                    "Users"
                ],
                "parameters": [],
                "produces": [
                    "application/json"
                ]
            }
        },
        "/users": {
            "get": {
                "responses": {
                    "200": {
                        "description": "OK",
                        "headers": {},
                        "examples": {
                            "application/json": [
                                {
                                    "id": "",
                                    "name": null
                                }
                            ]
                        },
                        "schema": {
                            "type": "array",
                            "items": {}
                        }
                    },
                    "500": {
                        "description": "Internal Server Error",
                        "headers": {},
                        "examples": {}
                    }
                },
                "summary": "Get a collection of users",
                "operationId": "Get a collection of users",
                "description": "",
                "tags": [
                    "Users"
                ],
                "parameters": [],
                "produces": [
                    "application/json"
                ]
            }
        }
    },
    "definitions": {
        "A user": {},
        "Some users": {},
        "User": {
            "type": "object",
            "required": [
                "id",
                "name"
            ],
            "properties": {
                "id": {
                    "type": "string"
                },
                "name": {
                    "type": "string" // <= it should be ["string", "null"], but the null part is missing.
                }
            }
        },
        "Users": {
            "type": "object",
            "required": [
                "users"
            ],
            "properties": {
                "users": {
                    "type": "array", // <= it should be ["array", "null"], but the null part is missing.
                    "items": {}
                }
            }
        }
    },
    "securityDefinitions": {},
    "tags": [
        {
            "name": "Users"
        }
    ]
}

YAML support

Hello!
This tool is pretty helpful, thanks for it!
But how about the swagger YAML format support for a converter?

Issue with Example Value Model output

Hi @kminami,

I found something interesting and I could not figure out why the body of the form is wrapped in an array.

In my api.md
Screen Shot 2022-02-23 at 3 22 24 PM

The output in JSON
Screen Shot 2022-02-23 at 3 22 05 PM

Is there a solution for this issue?

I expect the response body should be:

[
  "example1.com",
  "example2.com"
]

Objects with enum types generate invalid Swagger

Given the following API Blueprint excerpt (from http://docs.icons8.apiary.io/api-description-document):

## TotalV3Item (object)
+ name (string, required) icons style name
+ `api_code` (enum[string], required) - icons style code; in other places it named `plarform` or `platform_api_code`
    + Members
        + `all`
        + `ios7`
        + `win8`
        + `win10`
        + `android`
        + `androidL`
        + `color`
        + `office`
+ total (number, required) the quantity of icons

The following is generated

  TotalV3Item:
    properties:
      api_code:
        type: enum
      name:
        type: string
      total:
        type: number
    required:
      - name
      - api_code
      - total
    type: object

Whereas I would expect:

  TotalV3Item:
    properties:
      api_code:
        type: string
        enum:
          - `all`
          - `ios7`
          - `win8`
          - `win10`
          - `android`
          - `androidL`
          - `color`
          - `office
      name:
        type: string
      total:
        type: number
    required:
      - name
      - api_code
      - total
    type: object

Request uses schema - stripping example values

I'm attempting to convert a blueprint api file with example values for both request and response. The response works fine, given example values, it uses the values in the object body to provide examples for the api. The request, however, uses the schema which strips any example values.

example:


# Blog Posts [/posts]

## Retrieve All Posts [GET]
+ Request (application/json)
    + Attributes (array[BlogPost], fixed-type)

## Data Structures

### BlogPost (object)
+ id: 42 (number, required)
+ text: Hello World (string)
+ author (Author) - Author of the blog post.

### Author (object)
+ name: Boba Fett
+ email: [email protected]

converts to:

info:
  title: ''
  version: ''
  description: ''
paths:
  /posts:
    get:
      responses: {}
      summary: Retrieve All Posts
      description: ''
      tags: []
      parameters:
        - name: body
          in: body
          schema:
            type: array
            items:
              type: object
              properties:
                id:
                  type: number
                text:
                  type: string
                author:
                  type: object
                  properties:
                    name:
                      type: string
                    email:
                      type: string
                  description: Author of the blog post.
              required:
                - id
definitions:
  Blog Posts: {}
  BlogPost:
    type: object
    required:
      - id
    properties:
      id:
        type: number
      text:
        type: string
      author:
        type: Author
  Author:
    type: object
    properties:
      name:
        type: string
      email:
        type: string

(notice no examples) when I really want:

info:
  title: ''
  version: ''
  description: ''
paths:
  /posts:
    get:
      responses: {}
      summary: Retrieve All Posts
      description: ''
      tags: []
      parameters:
        - name: body
          in: body
          schema:
            type: array
            items:
              type: object
              properties:
                id:
                  type: number
                  example: 42
                text:
                  type: string
                  example: Hello World
                author:
                  type: object
                  properties:
                    name:
                      type: string
                      example: Boba Fett
                    email:
                      type: string
                      example: [email protected]
                  description: Author of the blog post.
              required:
                - id
definitions:
  Blog Posts: {}
  BlogPost:
    type: object
    required:
      - id
    properties:
      id:
        type: number
      text:
        type: string
      author:
        type: Author
  Author:
    type: object
    properties:
      name:
        type: string
      email:
        type: string

(the example: <example value>)

My question is there a particular reason why the schema is used for the request? Could we add example values to the request?

Thanks!

Parameters are not generated?

Hello,

I am trying your nice project.

Got this example:

##  Login [/users/login]
Authenticate an user.

+ Model

      + Headers

            Content-Type: application/json
            X-johndoe-token: 1234567890

      + Body

            {
                "username": "[email protected]",
                "password": "123456",
            }

      + Schema

            <!-- include(/docs/schemas/users/login.js) -->

### POST

+ Request

     Login request


+ Response 200 (application/json)

      + Body

            <!-- include(/docs/bodies/users/login.js) -->

      + Schema

            <!-- include(/docs/schemas/users/loginResponse.js) -->

What I would expect, is this will generate something like:

"/users/login": {
            "post": {
                "responses": {
                    "200": {
                        "description": "OK",
                        "headers": {},
                        "examples": {}
                    }
                },
                "summary": "",
                "description": "Login request",
                "tags": [
                    "Users"
                ],
                "parameters": [
                    {
                        "name": "user",
                        "in": "body",
                        "description": "user to add to the system",
                        "required": true,
                        "schema": {
                            "type": "object",
                            "required": [
                                "username",
                                "password"
                            ],
                            "properties": {
                                "username": {
                                    "type": "string"
                                },
                                "password": {
                                    "type": "string"
                                }
                            }
                        }
                    }
                ]
            }
        },

But the converter generates this (without the parameters and no headers filled in):

"/users/login": {
            "post": {
                "responses": {},
                "summary": "",
                "description": "Login request",
                "tags": [
                    "Users"
                ],
                "parameters": []
            }
        },

What am I doing wrong?

Custom types converted incorrectly into OpenAPI 3

Nominal

Rendering an API Blueprint document to OpenAPI3 with flag --open-api-3 converts a custom type like this:

## MyType (object)
+ id: `4711` (required, string)
+ someProperty (required, nullable, object)
    + someList (required, array)
        + (object)
            + id: `some example`(required, string)

into this:

    MyType:
      type: object
      required:
        - id
        - someProperty
      properties:
        id:
          type: string
          example: 4711
        someProperty:
          type: object
          nullable: true
          required:
            - someList
          properties:
            someList:
              type: array
              items:
                type: object
                required: 
                  - id
                properties:
                  id:
                    type: string
                    example: some example

Actual

Rendering an API Blueprint document to OpenAPI3 with flag --open-api-3 converts a custom type like this:

## MyType (object)
+ id: `4711` (required, string)
+ someProperty (required, nullable, object)
    + someList (required, array)
        + (object)
            + id: `some example`(required, string)

results in:

    MyType:
      type: object
      required:
        - id
        - someProperty
      properties:
        id:
          type: string
        someProperty:
          type: object
          required:
            - someList
          properties:
            someList:
              type: array
              items: {}
          nullable: true

Please note the missing definition in line 16 and the missing example values.

Version Issue

Hi, when I convert apib to swagger the "version" field in the swagger file is not filled, giving problem to import into API Gateways.

Is this right?

Thank you

TypeError: Cannot read property 'name' of undefined

I like the look of your project, so I curld down the an API blueprint example, and installed (npm 2.11.3, node v0.12.7) the latest apib2swagger.

Unfortunately here's the output from running apib2swagger -i RealWorldAPI.md -o foo.json:

/home/sm/n/lib/node_modules/apib2swagger/index.js:11
        'title': apib.name,
                     ^
TypeError: Cannot read property 'name' of undefined
    at module.exports.convertParsed (/home/sm/n/lib/node_modules/apib2swagger/index.js:11:22)
    at /home/sm/n/lib/node_modules/apib2swagger/index.js:289:23
sm@Afz:/tmp$ mv Real%20World%20API.md RealWorldAPI.md
sm@Afz:/tmp$ apib2swagger -i RealWorldAPI.md
/home/sm/n/lib/node_modules/apib2swagger/index.js:11
        'title': apib.name,
                     ^
TypeError: Cannot read property 'name' of undefined
    at module.exports.convertParsed (/home/sm/n/lib/node_modules/apib2swagger/index.js:11:22)
    at /home/sm/n/lib/node_modules/apib2swagger/index.js:289:23
sm@Afz:/tmp$ apib2swagger -i RealWorldAPI.md -o foo.json
/home/sm/n/lib/node_modules/apib2swagger/index.js:11
        'title': apib.name,
                     ^
TypeError: Cannot read property 'name' of undefined
    at module.exports.convertParsed (/home/sm/n/lib/node_modules/apib2swagger/index.js:11:22)
    at /home/sm/n/lib/node_modules/apib2swagger/index.js:289:23

How do I resolve this issue?

Thanks for all suggestions,

Samuel

PS: Your input directory is empty so I can't see what you expect => https://github.com/kminami/apib2swagger/tree/master/test/input

EDIT: Debugging around a little and I found the problem. The convertParsed function's apib argument isn't being populated (it's undefined).

Items' type of Array is not set

Copying from LucyBot-Inc/api-spec-converter#170

Problem : We are converting the apib below. It contains an array of User but the section "schema.items" is empty so we get a array of null as a result.

Solution : fill the "schema.items" section with the items' type definition

apib file

# Group Users
## A user [/users]

### Get a collection of users [GET]
+ Response 200 (application/json)
  + Attributes (array[User])
+ Response 500 (application/json)

# Data Structures
## User (object)
+ id (string)
+ name (string)

json file

{
  [...]
"/users": {
      "get": {
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "examples": {
                  "response": {
                    "value": [
                      {
                        "id": "",
                        "name": ""
                      }
                    ]
                  }
                },
                "schema": {
                  "items": {}, // <= the definition is empty
                  "type": "array"
                }
              }
            },
            "description": "OK",
            "headers": {}
          },
          "500": {
            "description": "Internal Server Error",
            "headers": {}
          }
        },
        "tags": [
          "Users"
        ],
        "description": "",
        "summary": "Get a collection of users"
      }
    },
  [...]
}

Definitions block missing in output

$ref: "#/definitions/PostModel"

Here is what's generated from the "Real World API" API blueprint example, then converted to YAML:

swagger: "2.0"
info: 
  title: "Real World API"
  version: ""
  description: "This API Blueprint demonstrates a real world example documenting a portion of [App.net API](http://developers.app.net).\n\nNOTE: This document is a **work in progress**.\n\n"
host: "alpha-api.app.net"
basePath: "/"
schemes: 
  - "https"
paths: 
  /stream/0/posts/{post_id}: 
    get: 
      responses: 
        200: 
          description: "OK"
          headers: {}
          examples: {}
      summary: "Retrieve a Post"
      description: "Returns a specific Post.\n\n"
      tags: 
        - "Posts"
      parameters: 
        - 
          name: "post_id"
          in: "path"
          description: "The id of the Post."
          required: true
          type: "string"
    delete: 
      responses: 
        204: 
          description: "No Content"
          headers: {}
          examples: {}
      summary: "Delete a Post"
      description: "Delete a Post. The current user must be the same user who created the Post. It returns the deleted Post on success.\n\n"
      tags: 
        - "Posts"
      parameters: 
        - 
          name: "post_id"
          in: "path"
          description: "The id of the Post."
          required: true
          type: "string"
  /stream/0/posts: 
    post: 
      responses: 
        201: 
          description: "Created"
          headers: {}
          examples: {}
      summary: "Create a Post"
      description: "Create a new Post object. Mentions and hashtags will be parsed out of the post text, as will bare URLs...\n\n"
      tags: 
        - "Posts"
      parameters: 
        - 
          name: "body"
          in: "body"
          schema: 
            $ref: "#/definitions/PostModel"
    get: 
      responses: 
        200: 
          description: "OK"
          headers: {}
          examples: {}
      summary: "Retrieve all Posts"
      description: "Retrieves all posts.\n\n"
      tags: 
        - "Posts"
      parameters: []
  /stream/0/posts/{post_id}/star: 
    post: 
      responses: 
        200: 
          description: "OK"
          headers: {}
          examples: {}
      summary: "Star a Post"
      description: "Save a given Post to the current User’s stars. This is just a “save” action, not a sharing action.\n\n*Note: A repost cannot be starred. Please star the parent Post.*\n\n"
      tags: 
        - "Posts"
      parameters: 
        - 
          name: "post_id"
          in: "path"
          description: "The id of the Post."
          required: true
          type: "string"
    delete: 
      responses: 
        200: 
          description: "OK"
          headers: {}
          examples: {}
      summary: "Unstar a Post"
      description: "Remove a Star from a Post.\n\n"
      tags: 
        - "Posts"
      parameters: 
        - 
          name: "post_id"
          in: "path"
          description: "The id of the Post."
          required: true
          type: "string"
definitions: {}

Content-Type application/scim+json isn't creating a corresponding "consumes" section

I'm using v1.16.1, and have some apib like this:

### Create a user [POST /api/scim/v2/Users]

+ Request
    + Headers

            Content-Type: application/scim+json
            Authorization: Bearer token

    + Body

            {
                "schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
                "userName": "fredsmith",
                "name": {
                    "givenName": "Fred",
                    "familyName": "Smith"
                },
                "emails": [
                    {"primary": true, "value": "[email protected]", "type": "work"}
                ],
                "displayName": "Fred Smith",
                "externalId": "fred-external-id",
                "active": true
            }

+ Response 201 (application/scim+json)

    + Attributes (ExistingUser)

When producing the swagger json, it creates a produces section, but not consumes, which then causes a UI viewer to default (I'm assuming) to application/json for "content type" and "request body schema". If I add the consumes section myself, it displays correctly.

"produces": [
    "application/scim+json"
],
"consumes": [
    "application/scim+json"
],

Thank you!

operationId is not generated

I would expect the generated code contains something like this:

"/product/get-product-list/": {
      "get": {
        "operationId": "product_get-product-list_list",
        "description": "",
        "parameters": [...]

However, operationId is not being generated. This causes issues with some front-end generators based on swagger.

no info about models (resources)

Now if I take the more isolated example (and without faulty JSONs) 11. Resource Model.md, I see this in definitions:

    "definitions": {
        "My Message": {},
        "My MessageModel": {
            "type": "object",
            "properties": {
                "class": {
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "properties": {
                    "type": "object",
                    "properties": {
                        "message": {
                            "type": "string"
                        }
                    }
                },
                "links": {
                    "type": "array",
                    "items": {
                        "type": "object",
                        "properties": {
                            "rel": {
                                "type": "string"
                            },
                            "href": {
                                "type": "string"
                            }
                        }
                    }
                }
            },
            "example": {
                "class": [
                    "message"
                ],
                "properties": {
                    "message": "Hello World!"
                },
                "links": [
                    {
                        "rel": "self",
                        "href": "/message"
                    }
                ]
            }
        }
    },

So there are both "My Message": {}, and "My MessageModel": {.... I may be wrong but shouldn't it just be "My Message": but with all the properties?

Also, what concerns me much more, in this example the Retrieve a Message [GET] method refers to the My Message model in response:

### Retrieve a Message [GET]
At this point we will utilize our `Message` resource model and reference it in
`Response 200`.

+ Response 200

    [My Message][]

Shouldn't the schema be added into the response section too? Now there's only the example JSON there:

"/message": {
            "get": {
                "responses": {
                    "200": {
                        "description": "This is the `application/vnd.siren+json` message resource representation.",
                        "headers": {},
                        "examples": {
                            "application/vnd.siren+json": {
                                "class": [
                                    "message"
                                ],
                                "properties": {
                                    "message": "Hello World!"
                                },
                                "links": [
                                    {
                                        "rel": "self",
                                        "href": "/message"
                                    }
                                ]
                            }
                        }
                    }
                },
...

Originally posted by @Vanderhoof in LucyBot-Inc/api-spec-converter#209 (comment)

Does not work with the latest node version v4.1.1

Tested with v4.1.1 on both OS X and Linux (Ubuntu 14.04) and it failed.

Was able to get it to compile with v0.12.

(was not able to attach output so I'm copy/pasting it in issue - apologies).

$ npm install -g apib2swagger

[email protected] install /home/tbostelmann/.nvm/versions/node/v4.1.1/lib/node_modules/apib2swagger/node_modules/protagonist
node-gyp rebuild

make: Entering directory /home/tbostelmann/.nvm/versions/node/v4.1.1/lib/node_modules/apib2swagger/node_modules/protagonist/build' CXX(target) Release/obj.target/libmarkdownparser/drafter/ext/snowcrash/ext/markdown-parser/src/ByteBuffer.o CXX(target) Release/obj.target/libmarkdownparser/drafter/ext/snowcrash/ext/markdown-parser/src/MarkdownNode.o CXX(target) Release/obj.target/libmarkdownparser/drafter/ext/snowcrash/ext/markdown-parser/src/MarkdownParser.o AR(target) Release/obj.target/drafter/ext/snowcrash/markdownparser.a COPY Release/markdownparser.a CXX(target) Release/obj.target/libsnowcrash/drafter/ext/snowcrash/src/HTTP.o In file included from ../drafter/ext/snowcrash/src/Blueprint.h:17:0, from ../drafter/ext/snowcrash/src/HTTP.h:13, from ../drafter/ext/snowcrash/src/HTTP.cc:9: ../drafter/ext/snowcrash/src/MSON.h:371:37: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<Elements> m_elements; ^ CXX(target) Release/obj.target/libsnowcrash/drafter/ext/snowcrash/src/MSON.o In file included from ../drafter/ext/snowcrash/src/MSON.cc:9:0: ../drafter/ext/snowcrash/src/MSON.h:371:37: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<Elements> m_elements; ^ CXX(target) Release/obj.target/libsnowcrash/drafter/ext/snowcrash/src/MSONOneOfParser.o In file included from ../drafter/ext/snowcrash/src/Blueprint.h:17:0, from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:12, from ../drafter/ext/snowcrash/src/ModelTable.h:21, from ../drafter/ext/snowcrash/src/SectionParserData.h:12, from ../drafter/ext/snowcrash/src/SectionProcessor.h:12, from ../drafter/ext/snowcrash/src/SignatureSectionProcessor.h:12, from ../drafter/ext/snowcrash/src/SectionParser.h:13, from ../drafter/ext/snowcrash/src/MSONMixinParser.h:12, from ../drafter/ext/snowcrash/src/MSONOneOfParser.h:12, from ../drafter/ext/snowcrash/src/MSONOneOfParser.cc:9: ../drafter/ext/snowcrash/src/MSON.h:371:37: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<Elements> m_elements; ^ In file included from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:13:0, from ../drafter/ext/snowcrash/src/ModelTable.h:21, from ../drafter/ext/snowcrash/src/SectionParserData.h:12, from ../drafter/ext/snowcrash/src/SectionProcessor.h:12, from ../drafter/ext/snowcrash/src/SignatureSectionProcessor.h:12, from ../drafter/ext/snowcrash/src/SectionParser.h:13, from ../drafter/ext/snowcrash/src/MSONMixinParser.h:12, from ../drafter/ext/snowcrash/src/MSONOneOfParser.h:12, from ../drafter/ext/snowcrash/src/MSONOneOfParser.cc:9: ../drafter/ext/snowcrash/src/MSONSourcemap.h:177:51: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<SourceMap<mson::Elements> > m_elements; ^ CXX(target) Release/obj.target/libsnowcrash/drafter/ext/snowcrash/src/MSONSourcemap.o In file included from ../drafter/ext/snowcrash/src/Blueprint.h:17:0, from ../drafter/ext/snowcrash/src/MSONSourcemap.h:12, from ../drafter/ext/snowcrash/src/MSONSourcemap.cc:9: ../drafter/ext/snowcrash/src/MSON.h:371:37: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<Elements> m_elements; ^ In file included from ../drafter/ext/snowcrash/src/MSONSourcemap.cc:9:0: ../drafter/ext/snowcrash/src/MSONSourcemap.h:177:51: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<SourceMap<mson::Elements> > m_elements; ^ CXX(target) Release/obj.target/libsnowcrash/drafter/ext/snowcrash/src/MSONTypeSectionParser.o In file included from ../drafter/ext/snowcrash/src/Blueprint.h:17:0, from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:12, from ../drafter/ext/snowcrash/src/ModelTable.h:21, from ../drafter/ext/snowcrash/src/SectionParserData.h:12, from ../drafter/ext/snowcrash/src/SectionProcessor.h:12, from ../drafter/ext/snowcrash/src/SignatureSectionProcessor.h:12, from ../drafter/ext/snowcrash/src/SectionParser.h:13, from ../drafter/ext/snowcrash/src/MSONMixinParser.h:12, from ../drafter/ext/snowcrash/src/MSONOneOfParser.h:12, from ../drafter/ext/snowcrash/src/MSONTypeSectionParser.cc:9: ../drafter/ext/snowcrash/src/MSON.h:371:37: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<Elements> m_elements; ^ In file included from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:13:0, from ../drafter/ext/snowcrash/src/ModelTable.h:21, from ../drafter/ext/snowcrash/src/SectionParserData.h:12, from ../drafter/ext/snowcrash/src/SectionProcessor.h:12, from ../drafter/ext/snowcrash/src/SignatureSectionProcessor.h:12, from ../drafter/ext/snowcrash/src/SectionParser.h:13, from ../drafter/ext/snowcrash/src/MSONMixinParser.h:12, from ../drafter/ext/snowcrash/src/MSONOneOfParser.h:12, from ../drafter/ext/snowcrash/src/MSONTypeSectionParser.cc:9: ../drafter/ext/snowcrash/src/MSONSourcemap.h:177:51: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<SourceMap<mson::Elements> > m_elements; ^ CXX(target) Release/obj.target/libsnowcrash/drafter/ext/snowcrash/src/MSONValueMemberParser.o In file included from ../drafter/ext/snowcrash/src/Blueprint.h:17:0, from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:12, from ../drafter/ext/snowcrash/src/ModelTable.h:21, from ../drafter/ext/snowcrash/src/SectionParserData.h:12, from ../drafter/ext/snowcrash/src/SectionProcessor.h:12, from ../drafter/ext/snowcrash/src/SignatureSectionProcessor.h:12, from ../drafter/ext/snowcrash/src/SectionParser.h:13, from ../drafter/ext/snowcrash/src/MSONMixinParser.h:12, from ../drafter/ext/snowcrash/src/MSONOneOfParser.h:12, from ../drafter/ext/snowcrash/src/MSONValueMemberParser.cc:9: ../drafter/ext/snowcrash/src/MSON.h:371:37: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<Elements> m_elements; ^ In file included from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:13:0, from ../drafter/ext/snowcrash/src/ModelTable.h:21, from ../drafter/ext/snowcrash/src/SectionParserData.h:12, from ../drafter/ext/snowcrash/src/SectionProcessor.h:12, from ../drafter/ext/snowcrash/src/SignatureSectionProcessor.h:12, from ../drafter/ext/snowcrash/src/SectionParser.h:13, from ../drafter/ext/snowcrash/src/MSONMixinParser.h:12, from ../drafter/ext/snowcrash/src/MSONOneOfParser.h:12, from ../drafter/ext/snowcrash/src/MSONValueMemberParser.cc:9: ../drafter/ext/snowcrash/src/MSONSourcemap.h:177:51: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<SourceMap<mson::Elements> > m_elements; ^ CXX(target) Release/obj.target/libsnowcrash/drafter/ext/snowcrash/src/Blueprint.o In file included from ../drafter/ext/snowcrash/src/Blueprint.h:17:0, from ../drafter/ext/snowcrash/src/Blueprint.cc:9: ../drafter/ext/snowcrash/src/MSON.h:371:37: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<Elements> m_elements; ^ CXX(target) Release/obj.target/libsnowcrash/drafter/ext/snowcrash/src/BlueprintSourcemap.o In file included from ../drafter/ext/snowcrash/src/Blueprint.h:17:0, from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:12, from ../drafter/ext/snowcrash/src/BlueprintSourcemap.cc:9: ../drafter/ext/snowcrash/src/MSON.h:371:37: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<Elements> m_elements; ^ In file included from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:13:0, from ../drafter/ext/snowcrash/src/BlueprintSourcemap.cc:9: ../drafter/ext/snowcrash/src/MSONSourcemap.h:177:51: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<SourceMap<mson::Elements> > m_elements; ^ CXX(target) Release/obj.target/libsnowcrash/drafter/ext/snowcrash/src/Section.o CXX(target) Release/obj.target/libsnowcrash/drafter/ext/snowcrash/src/Signature.o In file included from ../drafter/ext/snowcrash/src/Blueprint.h:17:0, from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:12, from ../drafter/ext/snowcrash/src/ModelTable.h:21, from ../drafter/ext/snowcrash/src/SectionParserData.h:12, from ../drafter/ext/snowcrash/src/SectionProcessor.h:12, from ../drafter/ext/snowcrash/src/SignatureSectionProcessor.h:12, from ../drafter/ext/snowcrash/src/SectionParser.h:13, from ../drafter/ext/snowcrash/src/Signature.cc:10: ../drafter/ext/snowcrash/src/MSON.h:371:37: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<Elements> m_elements; ^ In file included from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:13:0, from ../drafter/ext/snowcrash/src/ModelTable.h:21, from ../drafter/ext/snowcrash/src/SectionParserData.h:12, from ../drafter/ext/snowcrash/src/SectionProcessor.h:12, from ../drafter/ext/snowcrash/src/SignatureSectionProcessor.h:12, from ../drafter/ext/snowcrash/src/SectionParser.h:13, from ../drafter/ext/snowcrash/src/Signature.cc:10: ../drafter/ext/snowcrash/src/MSONSourcemap.h:177:51: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<SourceMap<mson::Elements> > m_elements; ^ CXX(target) Release/obj.target/libsnowcrash/drafter/ext/snowcrash/src/snowcrash.o In file included from ../drafter/ext/snowcrash/src/Blueprint.h:17:0, from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:12, from ../drafter/ext/snowcrash/src/snowcrash.h:12, from ../drafter/ext/snowcrash/src/snowcrash.cc:9: ../drafter/ext/snowcrash/src/MSON.h:371:37: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<Elements> m_elements; ^ In file included from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:13:0, from ../drafter/ext/snowcrash/src/snowcrash.h:12, from ../drafter/ext/snowcrash/src/snowcrash.cc:9: ../drafter/ext/snowcrash/src/MSONSourcemap.h:177:51: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<SourceMap<mson::Elements> > m_elements; ^ CXX(target) Release/obj.target/libsnowcrash/drafter/ext/snowcrash/src/UriTemplateParser.o In file included from ../drafter/ext/snowcrash/src/Blueprint.h:17:0, from ../drafter/ext/snowcrash/src/UriTemplateParser.h:12, from ../drafter/ext/snowcrash/src/UriTemplateParser.cc:9: ../drafter/ext/snowcrash/src/MSON.h:371:37: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<Elements> m_elements; ^ CXX(target) Release/obj.target/libsnowcrash/drafter/ext/snowcrash/src/HeadersParser.o In file included from ../drafter/ext/snowcrash/src/Blueprint.h:17:0, from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:12, from ../drafter/ext/snowcrash/src/ModelTable.h:21, from ../drafter/ext/snowcrash/src/SectionParserData.h:12, from ../drafter/ext/snowcrash/src/SectionProcessor.h:12, from ../drafter/ext/snowcrash/src/SignatureSectionProcessor.h:12, from ../drafter/ext/snowcrash/src/SectionParser.h:13, from ../drafter/ext/snowcrash/src/HeadersParser.h:12, from ../drafter/ext/snowcrash/src/HeadersParser.cc:1: ../drafter/ext/snowcrash/src/MSON.h:371:37: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<Elements> m_elements; ^ In file included from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:13:0, from ../drafter/ext/snowcrash/src/ModelTable.h:21, from ../drafter/ext/snowcrash/src/SectionParserData.h:12, from ../drafter/ext/snowcrash/src/SectionProcessor.h:12, from ../drafter/ext/snowcrash/src/SignatureSectionProcessor.h:12, from ../drafter/ext/snowcrash/src/SectionParser.h:13, from ../drafter/ext/snowcrash/src/HeadersParser.h:12, from ../drafter/ext/snowcrash/src/HeadersParser.cc:1: ../drafter/ext/snowcrash/src/MSONSourcemap.h:177:51: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<SourceMap<mson::Elements> > m_elements; ^ CXX(target) Release/obj.target/libsnowcrash/drafter/ext/snowcrash/src/posix/RegexMatch.o AR(target) Release/obj.target/drafter/ext/snowcrash/snowcrash.a COPY Release/snowcrash.a CC(target) Release/obj.target/libsundown/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/autolink.o CC(target) Release/obj.target/libsundown/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/buffer.o CC(target) Release/obj.target/libsundown/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/markdown.o CC(target) Release/obj.target/libsundown/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/src_map.o CC(target) Release/obj.target/libsundown/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/src/stack.o CC(target) Release/obj.target/libsundown/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html/houdini_href_e.o CC(target) Release/obj.target/libsundown/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html/houdini_html_e.o CC(target) Release/obj.target/libsundown/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html/html.o CC(target) Release/obj.target/libsundown/drafter/ext/snowcrash/ext/markdown-parser/ext/sundown/html/html_smartypants.o AR(target) Release/obj.target/drafter/ext/snowcrash/sundown.a COPY Release/sundown.a CXX(target) Release/obj.target/libdrafter/drafter/src/drafter.o In file included from ../drafter/ext/snowcrash/src/Blueprint.h:17:0, from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:12, from ../drafter/ext/snowcrash/src/snowcrash.h:12, from ../drafter/src/drafter.h:13, from ../drafter/src/drafter.cc:9: ../drafter/ext/snowcrash/src/MSON.h:371:37: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<Elements> m_elements; ^ In file included from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:13:0, from ../drafter/ext/snowcrash/src/snowcrash.h:12, from ../drafter/src/drafter.h:13, from ../drafter/src/drafter.cc:9: ../drafter/ext/snowcrash/src/MSONSourcemap.h:177:51: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<SourceMap<mson::Elements> > m_elements; ^ CXX(target) Release/obj.target/libdrafter/drafter/src/cdrafter.o In file included from ../drafter/ext/snowcrash/src/Blueprint.h:17:0, from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:12, from ../drafter/ext/snowcrash/src/snowcrash.h:12, from ../drafter/src/cdrafter.cc:3: ../drafter/ext/snowcrash/src/MSON.h:371:37: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<Elements> m_elements; ^ In file included from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:13:0, from ../drafter/ext/snowcrash/src/snowcrash.h:12, from ../drafter/src/cdrafter.cc:3: ../drafter/ext/snowcrash/src/MSONSourcemap.h:177:51: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<SourceMap<mson::Elements> > m_elements; ^ CXX(target) Release/obj.target/libdrafter/drafter/src/Serialize.o In file included from ../drafter/ext/snowcrash/src/Blueprint.h:17:0, from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:12, from ../drafter/src/Serialize.h:13, from ../drafter/src/Serialize.cc:9: ../drafter/ext/snowcrash/src/MSON.h:371:37: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<Elements> m_elements; ^ In file included from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:13:0, from ../drafter/src/Serialize.h:13, from ../drafter/src/Serialize.cc:9: ../drafter/ext/snowcrash/src/MSONSourcemap.h:177:51: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<SourceMap<mson::Elements> > m_elements; ^ CXX(target) Release/obj.target/libdrafter/drafter/src/SerializeAST.o In file included from ../drafter/ext/snowcrash/src/Blueprint.h:17:0, from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:12, from ../drafter/src/Serialize.h:13, from ../drafter/src/SerializeAST.h:12, from ../drafter/src/SerializeAST.cc:10: ../drafter/ext/snowcrash/src/MSON.h:371:37: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<Elements> m_elements; ^ In file included from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:13:0, from ../drafter/src/Serialize.h:13, from ../drafter/src/SerializeAST.h:12, from ../drafter/src/SerializeAST.cc:10: ../drafter/ext/snowcrash/src/MSONSourcemap.h:177:51: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<SourceMap<mson::Elements> > m_elements; ^ CXX(target) Release/obj.target/libdrafter/drafter/src/SerializeSourcemap.o In file included from ../drafter/ext/snowcrash/src/Blueprint.h:17:0, from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:12, from ../drafter/src/Serialize.h:13, from ../drafter/src/SerializeSourcemap.h:12, from ../drafter/src/SerializeSourcemap.cc:9: ../drafter/ext/snowcrash/src/MSON.h:371:37: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<Elements> m_elements; ^ In file included from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:13:0, from ../drafter/src/Serialize.h:13, from ../drafter/src/SerializeSourcemap.h:12, from ../drafter/src/SerializeSourcemap.cc:9: ../drafter/ext/snowcrash/src/MSONSourcemap.h:177:51: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<SourceMap<mson::Elements> > m_elements; ^ CXX(target) Release/obj.target/libdrafter/drafter/src/SerializeResult.o In file included from ../drafter/ext/snowcrash/src/Blueprint.h:17:0, from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:12, from ../drafter/src/Serialize.h:13, from ../drafter/src/SerializeResult.h:12, from ../drafter/src/SerializeResult.cc:9: ../drafter/ext/snowcrash/src/MSON.h:371:37: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<Elements> m_elements; ^ In file included from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:13:0, from ../drafter/src/Serialize.h:13, from ../drafter/src/SerializeResult.h:12, from ../drafter/src/SerializeResult.cc:9: ../drafter/ext/snowcrash/src/MSONSourcemap.h:177:51: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<SourceMap<mson::Elements> > m_elements; ^ AR(target) Release/obj.target/drafter/drafter.a COPY Release/drafter.a CXX(target) Release/obj.target/libsos/drafter/ext/sos/src/sos.o AR(target) Release/obj.target/drafter/sos.a COPY Release/sos.a CXX(target) Release/obj.target/protagonist/src/annotation.o In file included from ../src/protagonist.h:6:0, from ../src/annotation.cc:1: ../node_modules/nan/nan.h:261:25: error: redefinition of ‘template<class T> v8::Local<T> _NanEnsureLocal(v8::Local<T>)’ NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Local<T> val) { ^ ../node_modules/nan/nan.h:256:25: error: ‘template<class T> v8::Local<T> _NanEnsureLocal(v8::Handle<T>)’ previously declared here NAN_INLINE v8::Local<T> _NanEnsureLocal(v8::Handle<T> val) { ^ ../node_modules/nan/nan.h:661:13: error: ‘node::smalloc’ has not been declared , node::smalloc::FreeCallback callback ^ ../node_modules/nan/nan.h:661:35: error: expected ‘,’ or ‘...’ before ‘callback’ , node::smalloc::FreeCallback callback ^ ../node_modules/nan/nan.h: In function ‘v8::Local<v8::Object> NanNewBufferHandle(char*, size_t, int)’: ../node_modules/nan/nan.h:665:50: error: ‘callback’ was not declared in this scope v8::Isolate::GetCurrent(), data, length, callback, hint); ^ ../node_modules/nan/nan.h:665:60: error: ‘hint’ was not declared in this scope v8::Isolate::GetCurrent(), data, length, callback, hint); ^ ../node_modules/nan/nan.h: In function ‘v8::Local<v8::Object> NanNewBufferHandle(const char*, uint32_t)’: ../node_modules/nan/nan.h:672:67: error: call of overloaded ‘New(v8::Isolate*, const char*&, uint32_t&)’ is ambiguous return node::Buffer::New(v8::Isolate::GetCurrent(), data, size); ^ ../node_modules/nan/nan.h:672:67: note: candidates are: In file included from ../node_modules/nan/nan.h:25:0, from ../src/protagonist.h:6, from ../src/annotation.cc:1: /home/tbostelmann/.node-gyp/4.1.1/include/node/node_buffer.h:31:40: note: v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate*, v8::Local<v8::String>, node::encoding) <near match> NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate, ^ /home/tbostelmann/.node-gyp/4.1.1/include/node/node_buffer.h:31:40: note: no known conversion for argument 3 from ‘uint32_t {aka unsigned int}’ to ‘node::encoding’ /home/tbostelmann/.node-gyp/4.1.1/include/node/node_buffer.h:43:40: note: v8::MaybeLocal<v8::Object> node::Buffer::New(v8::Isolate*, char*, size_t) <near match> NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate, ^ /home/tbostelmann/.node-gyp/4.1.1/include/node/node_buffer.h:43:40: note: no known conversion for argument 2 from ‘const char*’ to ‘char*’ In file included from ../src/protagonist.h:6:0, from ../src/annotation.cc:1: ../node_modules/nan/nan.h: In function ‘v8::Local<v8::Object> NanNewBufferHandle(uint32_t)’: ../node_modules/nan/nan.h:676:61: error: could not convert ‘node::Buffer::New(v8::Isolate::GetCurrent(), ((size_t)size))’ from ‘v8::MaybeLocal<v8::Object>’ to ‘v8::Local<v8::Object>’ return node::Buffer::New(v8::Isolate::GetCurrent(), size); ^ ../node_modules/nan/nan.h: In function ‘v8::Local<v8::Object> NanBufferUse(char*, uint32_t)’: ../node_modules/nan/nan.h:683:12: error: ‘Use’ is not a member of ‘node::Buffer’ return node::Buffer::Use(v8::Isolate::GetCurrent(), data, size); ^ In file included from ../drafter/ext/snowcrash/src/Blueprint.h:17:0, from ../src/protagonist.h:7, from ../src/annotation.cc:1: ../drafter/ext/snowcrash/src/MSON.h: At global scope: ../drafter/ext/snowcrash/src/MSON.h:371:37: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<Elements> m_elements; ^ In file included from ../drafter/ext/snowcrash/src/BlueprintSourcemap.h:13:0, from ../src/protagonist.h:8, from ../src/annotation.cc:1: ../drafter/ext/snowcrash/src/MSONSourcemap.h:177:51: warning: ‘auto_ptr’ is deprecated (declared at /usr/include/c++/4.8/backward/auto_ptr.h:87) [-Wdeprecated-declarations] std::auto_ptr<SourceMap<mson::Elements> > m_elements; ^ make: *** [Release/obj.target/protagonist/src/annotation.o] Error 1 make: Leaving directory/home/tbostelmann/.nvm/versions/node/v4.1.1/lib/node_modules/apib2swagger/node_modules/protagonist/build'
gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/home/tbostelmann/.nvm/versions/node/v4.1.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 3.19.0-25-generic
gyp ERR! command "/home/tbostelmann/.nvm/versions/node/v4.1.1/bin/node" "/home/tbostelmann/.nvm/versions/node/v4.1.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/tbostelmann/.nvm/versions/node/v4.1.1/lib/node_modules/apib2swagger/node_modules/protagonist
gyp ERR! node -v v4.1.1
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
npm ERR! Linux 3.19.0-25-generic
npm ERR! argv "/home/tbostelmann/.nvm/versions/node/v4.1.1/bin/node" "/home/tbostelmann/.nvm/versions/node/v4.1.1/bin/npm" "install" "-g" "apib2swagger"
npm ERR! node v4.1.1
npm ERR! npm v2.14.4
npm ERR! code ELIFECYCLE

npm ERR! [email protected] install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script 'node-gyp rebuild'.
npm ERR! This is most likely a problem with the protagonist package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get their info via:
npm ERR! npm owner ls protagonist
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /home/tbostelmann/npm-debug.log

Crash with .length of undefined

TypeError: Cannot read property 'length' of undefined
    at convertMsonToJsonSchema (/usr/local/lib/node_modules/apib2swagger/src/mson_to_json_schema.js:30:38)
    at /usr/local/lib/node_modules/apib2swagger/index.js:47:67
    at Array.forEach (<anonymous>)
    at /usr/local/lib/node_modules/apib2swagger/index.js:38:26
    at Array.forEach (<anonymous>)
    at module.exports.convertParsed (/usr/local/lib/node_modules/apib2swagger/index.js:33:8)
    at Object.exports.convert (/usr/local/lib/node_modules/apib2swagger/index.js:374:23)
    at processBlueprint (/usr/local/lib/node_modules/apib2swagger/bin/apib2swagger.js:87:18)
    at ReadStream.on.on (/usr/local/lib/node_modules/apib2swagger/bin/apib2swagger.js:67:5)
    at emitNone (events.js:111:20)

Gist for the file: https://gist.github.com/JesperWe/8ce928186f25a8739e31af43f76dc375

Nullable custom types break OpenAPI3 export

Nominal

Rendering an API Blueprint document to OpenAPI3 with flag --open-api-3 converts an input property like this:

    + images (required, nullable, ImagesType)

into this:

    images:
        type: ImagesType
        nullable: true
        …

Actual

Rendering an API Blueprint document to OpenAPI3 with flag --open-api-3 converts an input property like this:

    + images (required, nullable, ImagesType)

results in this error stack trace:

Error
    at Object.<anonymous> (/usr/local/lib/node_modules/apib2swagger/node_modules/json-schema-to-openapi-schema/index.js:8:30)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/apib2swagger/src/requests.js:4:19)
    at Module._compile (node:internal/modules/cjs/loader:1103:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10) {
  name: 'InvalidTypeError',
  message: 'Type "null" is not a valid type'
}

Remarks

#65 is related but only shows a workaround which is not useful if you want to use a certain type to be not nullable and nullable in different areas of your API.

Body API Blueprint body not defined

When the body of a request is defined as:

+ Request (application/json)
    + Attributes (Foo Model)

The body is not exported into the Postman body. It looks as though drafter parses this fine, so not sure what's going on here.

HTTP message-header Accept not converted to consumes

This Blueprint section

  • Request
    • Headers

      Accept: text/plain
      

should create Swagger output that contains:

"consumes": ["text/plain"]

Without "consumes", the request header contains Accept: application/json and plain text responses fail.

It doesn't matter what is specified for Accept in the Blueprint input.

Why are names and descriptions discarded in Resources?

https://github.com/kminami/apib2swagger/blob/22678e5bcc5712d49135dee3cf5a24c429b3c6cb/index.js#L64C30-L64C30

In looking why our docs did not retain the categorization and description fields from the resources when converted from apib to open-api-3 I noticed in this comment above that the fields are specifically being discarded for resources. I couldn't find any history that listed a reason, but I'm curious why that is the case rather than include that info? Is it because the default swagger renderer doesn't display them in a great location, just putting them in the header?

I ask mostly because I feel in some cases the info is better to have than to totally leave out, even if it's not totally great looking, but also if using the Redoc renderer it displays much better and pretty close to some apib renderers.

As it currently displays discarding those fields:

Screenshot 2023-10-16 at 11 30 21 AM

With converted json keeping resource names and descriptions:

Screenshot 2023-10-16 at 11 18 52 AM

Redoc version with converted openapi json.

Screenshot 2023-10-16 at 11 24 35 AM

Sample apib data:


# Hello API Endpoints

## V1 Hello [/api/v1/hello/{?options}]
Version 1 of the Hello API provides a number of helpful endpoints for testing and debugging.

+ Parameters
    + `options`: `displayText` (string, optional) - Some display text

### query param based methods [GET]

+ Response 200 (application/json)
    + Attributes (array[Metadata])

## V2 Hello [/api/v2/hello/]

Version 2 of the Hello API aims to provide a number of helpful endpoints for testing and debugging.

### Filtering, Ordering, & Pagination

#### Filtering

This API can filter returned metadata based on provided query parameters. The following fields can be used to filter results:
- type
- identifier
- tag

Default boolean values are encoded as strings in generated code.

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/apib2swagger/src/parameters.js b/node_modules/apib2swagger/src/parameters.js
index eb26c47..1afdae8 100644
--- a/node_modules/apib2swagger/src/parameters.js
+++ b/node_modules/apib2swagger/src/parameters.js
@@ -69,6 +69,8 @@ module.exports.processParameters = (parameters, uriTemplate, options) => {
         if (parameter.default) {
             if (paramType === 'number' || paramType === 'integer') {
                 parameterDefault = Number(parameter.default);
+            } else if (paramType === 'boolean') {
+                parameterDefault = parameter.default === 'true';
             } else {
                 parameterDefault = parameter.default;
             }

This issue body was partially generated by patch-package.

generated swagger.json fails swagger validation

Taking the test file https://github.com/kminami/apib2swagger/blob/master/test/input/Attributes.md, and generating a swagger.json file with apib2swagger, the json file has errors (if you upload it into http://editor.swagger.io/).

If i convert the file using https://apimatic.io/transformer, the file has no errors (see resulting json below).

{
  "swagger": "2.0",
  "info": {
    "version": "",
    "title": "Example API",
    "description": "TODO: Add a description",
    "license": {
      "name": "MIT",
      "url": "http://github.com/gruntjs/grunt/blob/master/LICENSE-MIT"
    }
  },
  "host": "www.example.com",
  "basePath": "/",
  "securityDefinitions": {},
  "schemes": [
    "http"
  ],
  "consumes": [
    "application/json"
  ],
  "produces": [
    "application/json"
  ],
  "paths": {
    "/some/resource": {
      "post": {
        "description": "",
        "operationId": "Create_SomeResource_",
        "produces": [
          "application/json"
        ],
        "parameters": [],
        "responses": {
          "200": {
            "description": ""
          }
        },
        "x-unitTests": [],
        "x-operation-settings": {
          "CollectParameters": false,
          "AllowDynamicQueryParameters": false,
          "AllowDynamicFormParameters": false,
          "IsMultiContentStreaming": false
        }
      }
    }
  }
}

Type "null" is not a valid type

Following fails atm (1.14.2) with Type "null" is not a valid type :

## User (object)
+ `name`(string,required)

## Comment (object)
+ `auhor`(User, nullable)

any suggestions on how to fix the apib to allow nullable there? Or can that be fixed in apib2swagger?

Conversion fails – because of nullable attributes?

When I try to convert the API Blueprint docs to Open API v3.0, the script fails.
cat apiary.apib | npx apib2swagger --yaml --open-api-3 > swagger.yaml

TypeError: Cannot read properties of undefined (reading 'value')
    at setResponseSchema (/Users/userme/.npm/_npx/b8304055354efd5a/node_modules/apib2swagger/src/responses.js:92:28)
    at module.exports.processResponses (/Users/userme/.npm/_npx/b8304055354efd5a/node_modules/apib2swagger/src/responses.js:181:29)
    at swaggerOperation (/Users/userme/.npm/_npx/b8304055354efd5a/node_modules/apib2swagger/index.js:160:22)
    at swaggerPaths (/Users/userme/.npm/_npx/b8304055354efd5a/node_modules/apib2swagger/index.js:148:60)
    at /Users/userme/.npm/_npx/b8304055354efd5a/node_modules/apib2swagger/index.js:71:17
    at Array.forEach (<anonymous>)
    at /Users/userme/.npm/_npx/b8304055354efd5a/node_modules/apib2swagger/index.js:62:26
    at Array.forEach (<anonymous>)
    at module.exports.convertParsed (/Users/userme/.npm/_npx/b8304055354efd5a/node_modules/apib2swagger/index.js:57:8)
    at exports.convert (/Users/userme/.npm/_npx/b8304055354efd5a/node_modules/apib2swagger/index.js:200:23)

When I run the script without the --open-api-3 flag, the file is converted, but IDE indicates "Property 'oneOf' is not allowed" errors and the official SwaggerEditor detects problems for all the nullable - 'null' properties. I guess the problem could be caused by the nullable values which are not handled properly.

Generated Open API v2.0:

      homeAddress:
        oneOf:
          - $ref: '#/definitions/Address'
            description: homeAddress, response only
          - type: 'null'

The source document has more than 1300 lines and is private so I cannot post it. It is valid according the API blueprint specs.

Allow input file or output file to be stdin/stdout

There are a few instances where it would be nice to use pipes instead of actual files when converting apib files to a swagger json file. An example of such usage might be:

cat header.apib admin.apib database.apib users.apib | apib2swagger -i - -o - | curl -F 'f:1=<-' https://example.com/upload

Transfer body parameters from API Blueprint

Currently, it doesn't look like the parameters (that are defined in the + Schema block in API Blueprint) are transferred to body parameters in Swagger. Am I missing something?

//API Blueprint Request Schema

Some resource [GET]

+ Request

    +Schema

      {
        type: "object",
        properties: {
          "prop1": {
            type: "string",
            required: true
          }
        }
      }

    + Body

      {
        prop1: "a string"
      }



//Swagger 2.0 
{
  "/some/resource/":{
     "get": {
       ...
       "parameters": []
     } 
   }
}

Also, by the Swagger 2.0 spec it looks like parameters is supposed to be an object, rather than array, it is supposed to be an object of objects:

{
  "skipParam": {
    "name": "skip",
    "in": "query",
    "description": "number of items to skip",
    "required": true,
    "type": "integer",
    "format": "int32"
  },
  "limitParam": {
    "name": "limit",
    "in": "query",
    "description": "max records to return",
    "required": true,
    "type": "integer",
    "format": "int32"
  }
} 

Arrays are not handled correctly

I tried to convert one of my blueprint projects to Swagger and noticed that arrays don't seem to render correctly. Please see the following example.

# POST /foo

+ Request (application/json)
    + Attributes(Foo)

+ Response 200

# Data Structure

## Foo
+ things (array[string])
+ bars (array[Bar])
+ baz (Baz)

## Bar
+ name (string)

## Baz
+ name (string)

Here's the output

{
    "swagger": "2.0",
    "info": {
        "title": "",
        "version": "",
        "description": ""
    },
    "paths": {
        "/foo": {
            "post": {
                "responses": {
                    "200": {
                        "description": "OK",
                        "headers": {},
                        "examples": {}
                    }
                },
                "summary": "",
                "description": "",
                "tags": [],
                "parameters": [
                    {
                        "name": "body",
                        "in": "body",
                        "schema": {
                            "$schema": "http://json-schema.org/draft-04/schema#",
                            "type": "object",
                            "properties": {
                                "things": {
                                    "type": "array"
                                },
                                "bars": {
                                    "type": "array"
                                },
                                "baz": {
                                    "type": "object",
                                    "properties": {
                                        "name": {
                                            "type": "string"
                                        }
                                    }
                                }
                            }
                        }
                    }
                ]
            }
        }
    },
    "definitions": {
        "Foo": {
            "type": "object",
            "properties": {
                "things": {
                    "type": "array",
                    "items": {}
                },
                "bars": {
                    "type": "array",
                    "items": {}
                },
                "baz": {
                    "type": "Baz"
                }
            }
        },
        "Bar": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string"
                }
            }
        },
        "Baz": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string"
                }
            }
        }
    }
}

I think this

"properties": {
    "things": {
        "type": "array"
    },
    "bars": {
        "type": "array"
    },
    "baz": {
        "type": "object",
        "properties": {
            "name": {
                "type": "string"
            }
        }
    }
}

should be

"properties": {
    "things": {
        "type": "array",
        "items": {
            "type": "string",
        }
    },
    "bars": {
        "type": "array",
        "items": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string"
                }
            }
        }
    },
    "baz": {
        "type": "object",
        "properties": {
            "name": {
                "type": "string"
                
            }
        }
    }
}

Or am I missing something? I'm new to API Blueprint and just checked out this awesome converter :) Thanks for your hard work!

Error Trying to Npm Install on Windows

Is there a work around?

[email protected] install C:\Users\andy\AppData\Roaming\npm\node_modules\apib2swagger\node_modules\protagonist
node-gyp rebuild

C�L�I�N�K� ��[1;32;40mC:\Users\andy\AppData\Roaming\npm\node_modules\apib2swagger\node_modules\protagonist {git}
�[1;30;40m{lamb} �[0mif not defined npm_config_node_gyp (node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (rebuild)
Warning: Missing input files:
C:\Users\andy\AppData\Roaming\npm\node_modules\apib2swagger\node_modules\protagonist\build\drafter\ext\snowcrash........\drafter\ext\snowcrash\src\Version.h
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(55,5): error MSB8020: The build tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found. To build using the v100 build tools, please install Visual Studio 2010 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\andy\AppData\Roaming\npm\node_modules\apib2swagger\node_modules\protagonist\build\drafter\libdrafter.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(55,5): error MSB8020: The build tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found. To build using the v100 build tools, please install Visual Studio 2010 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\andy\AppData\Roaming\npm\node_modules\apib2swagger\node_modules\protagonist\build\drafter\ext\snowcrash\libmarkdownparser.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(55,5): error MSB8020: The build tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found. To build using the v100 build tools, please install Visual Studio 2010 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\andy\AppData\Roaming\npm\node_modules\apib2swagger\node_modules\protagonist\build\drafter\ext\snowcrash\libsnowcrash.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(55,5): error MSB8020: The build tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found. To build using the v100 build tools, please install Visual Studio 2010 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\andy\AppData\Roaming\npm\node_modules\apib2swagger\node_modules\protagonist\build\drafter\libsos.vcxproj]
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.Cpp.Platform.targets(55,5): error MSB8020: The build tools for Visual Studio 2010 (Platform Toolset = 'v100') cannot be found. To build using the v100 build tools, please install Visual Studio 2010 build tools. Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting "Retarget solution". [C:\Users\andy\AppData\Roaming\npm\node_modules\apib2swagger\node_modules\protagonist\build\drafter\ext\snowcrash\libsundown.vcxproj]

Objects are not referenced

The attributes of objects used in responses (and everywhere in the interface description) are directly copy-pasted without using reference to the object. References are used only when pointing from an object definition to another definition.

Desired solution

references should be used in Swagger in all places, where they were used in Api Blueprint

Example Api Blueprint

...

  • Response 200 (application/json)
    • Attributes (object)
      • segment (SEGMENT) - One segment.
      • segmentsArray (array[SEGMENT], fixed-type) - Array of segments.
        ...

--- Data Structures

--- PLAN (object)

  • segment (SEGMENT) - One segment.
  • segmentsArray (array[SEGMENT], fixed-type) - Array of segments.

--- SEGMENT (object)

  • attr1
  • attr2
  • attr3

Example generated Swagger

get:
  responses:
    '200':
      description: OK
      headers: {}
      examples:
        application/json:
          segment:
            attr1: ''
            attr2: ''
            attr3: ''
          segmentsArray:
            - attr1: ''
              attr2: ''
              attr3: ''
      schema:
        type: object
        properties:
          segment:
            type: object
            properties:
              attr1:
                type: string
              attr2:
                type: string
              attr3:
                type: string
            description: One segment.
          segmentsArray:
            type: array
            items:
              type: object
              properties:
                attr1:
                  type: string
                attr2:
                  type: string
                attr3:
                  type: string
            description: Array of segments.
  summary: Get Plans of People
  description: xyz
  tags:
    - People
  parameters:
    - name: dateFrom
      in: query
      description: Date from.
      required: false
      x-example: '2018-08-01'
      type: string
    - name: dateTo
      in: query
      description: Date to.
      required: false
      x-example: '2018-08-30'
      type: string
  produces:
    - application/json

definitions:
Collection of Plans of People: {}
PLAN:
type: object
properties:
segment:
type: SEGMENT
segmentsArray:
type: array
items:
$ref: '#/definitions/SEGMENT'
SEGMENT:
type: object
properties:
attr1:
type: string
attr2:
type: string
attr3:
type: string

Schema Estimation for Response

Hi, I read from an issue before that schema estimation from examples for the request body was implemented. Can it also be implemented for the response body?

Response Headers not generated

Looks like Response Headers that aren't "Content-Type" are not output to the swagger output. a55845f

For example, take the following blueprint:

FORMAT: 1A9

# Test

Test API

## Test Collection [/tests]
The collection of test stuff

### Create a Test [POST]

+ Attributes
  + name (string) - The name of the test thing

+ Request (application/json)

            {
                "name": "bar"
            }

+ Response 201 (application/json)

    + Headers

            Location: /tests/1

    + Body

                {
                    "name": "bar",
                    "created_at": "2019-06-19T15:20:51.620Z",
                    "url": "/tests/1"
                }

I expect the swagger response section to include the Location header and value.

It seems like you could reuse the swaggerHeader method used to populate Request headers (other than content-type and authorization) to populate the Response headers.

As of v1.9.2, the above template outputs:

{
    "swagger": "2.0",
    "info": {
        "title": "Test",
        "version": "",
        "description": "Test API"
    },
    "paths": {
        "/tests": {
            "post": {
                "responses": {
                    "201": {
                        "description": "Created",
                        "headers": {},
                        "examples": {
                            "application/json": {
                                "name": "bar",
                                "created_at": "2019-06-19T15:20:51.620Z",
                                "url": "/tests/1"
                            }
                        }
                    }
                },
                "summary": "Create a Test",
                "description": "",
                "tags": [],
                "parameters": [
                    {
                        "name": "body",
                        "in": "body",
                        "schema": {
                            "type": "object",
                            "properties": {
                                "name": {
                                    "type": "string",
                                    "description": "The name of the test thing"
                                }
                            }
                        }
                    }
                ],
                "produces": [
                    "application/json"
                ]
            }
        }
    },
    "definitions": {
        "Test Collection": {}
    },
    "securityDefinitions": {},
    "tags": []
}

Enums are not referenced

Dear developers,

here is my problem: if I use an enum as a data structure, it is not converted as a reference to the structure, but the enum is used directly.

Here is my input apiary:

FORMAT: 1A

INT-1_Plan_v1_dev

This API is a HTTP-1.1 REST service that provides plans

Changelog

Date of change Description
03.08.2018 Document creation

Group People

Collection of Plans of People [/myapp/people/plans{?dateFrom,dateTo}]

Get Plans of People [GET]

  • Paginated ✖

  • Sortable ✖

  • Signable ✖

Error Codes

Possible error codes for this resource.

HTTP Status Code Error Code Purpose
400 VALIDATION_ERROR Validation error.
400 FIELD_MISSING A required field is missing.
  • Parameters

    • dateFrom: 2018-08-01 (string, optional) - Date from.
    • dateTo: 2018-08-30 (string, optional) - Date to.
  • Request

    • Headers

        some-key: <here comes some key>
        auth: <here comes some token>
      
  • Response 200 (application/json)

    • Attributes (object)
      • segments (array[SEGMENT_ENUM], required, fixed-type) - List of found segments
      • plans (array, required, fixed-type) - List of plans
        • (object)
          • state: COMPLETED (string, required) - State code
          • stateCounters (array, required, fixed-type) - List of states of plans by segment
            • (object)
              • segment (SEGMENT_ENUM, required) - segment code
              • count: 5 (number, required) - number of plans

Data Structures

SEGMENT_ENUM (enum)

  • LOW
  • MIDDLE
  • HIGH

And here is the result swagger:

swagger: '2.0'
info:
title: INT-1_Plan_v1_dev
version: ''
description: |-
This API is a HTTP-1.1 REST service that provides plans

**Changelog**

| Date of change    | Description       |
| ----------------- | ----------------- |
| 03.08.2018        | Document creation |

paths:
/myapp/people/plans:
get:
responses:
'200':
description: OK
headers: {}
examples:
application/json:
segments:
- LOW
plans:
- state: COMPLETED
stateCounters:
- segment: LOW
count: 5
schema:
type: object
properties:
segments:
type: array
items:
type: string
enum:
- LOW
- MIDDLE
- HIGH
description: List of found segments
plans:
type: array
items:
type: object
properties:
state:
type: string
description: State code
stateCounters:
type: array
items:
type: object
properties:
segment:
type: string
enum:
- LOW
- MIDDLE
- HIGH
description: segment code
count:
type: number
description: number of plans
required:
- segment
- count
description: List of states of plans by segment
required:
- state
- stateCounters
description: List of plans
required:
- segments
- plans
summary: Get Plans of People
description: |-
* Paginated ✖

    * Sortable &#10006;

    * Signable &#10006;

    #### Error Codes

    Possible error codes for this resource.

    | HTTP Status Code  | Error Code        | Purpose   |
    | ----------------- | ----------------- | --------- |
    | 400               | VALIDATION\_ERROR | Validation error. |
    | 400               | FIELD\_MISSING    | A required field is missing. |
  tags:
    - People
  parameters:
    - name: dateFrom
      in: query
      description: Date from.
      required: false
      x-example: '2018-08-01'
      type: string
    - name: dateTo
      in: query
      description: Date to.
      required: false
      x-example: '2018-08-30'
      type: string
  produces:
    - application/json

definitions:
Collection of Plans of People: {}
SEGMENT_ENUM:
allOf:
- $ref: '#/definitions/enum'
- type: object
properties: {}

SEGMENT_ENUM is not used above. Instead, its value were pasted directly to the place where it is used. In addition, SEGMENT_ENUM has a reference to "#/definitions/enum" which does not exist. Is there a different way how I can share my enums with a few REST services?

Fails to generate OpenAPI from API Blueprint

I'm trying to convert an API Blueprint document to OpenAPI but it fails with the following error: Type "extend" is not a valid type.

Here's a minmal test case of an API Blueprint document that fails:

FORMAT: 1A
HOST: http://127.0.0.1/api/v1

# Group Extensions

## Extensions [/extensions]

### Get extensions [GET]

+ Response 200 (application/json)
    + Attributes (Extension)

## Data Structures

### Extension (enum)

+ (Foo type)

### Foo type (object, fixed-type)

+ id (string) - the id

I used the following command to run the tool:

apib2swagger -i example.md --open-api-3 -o openapi.json

The full output of running the above command is:

Error
    at Object.<anonymous> (apib2swagger/node_modules/json-schema-to-openapi-schema/index.js:8:30)
    at Module._compile (node:internal/modules/cjs/loader:1255:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1309:10)
    at Module.load (node:internal/modules/cjs/loader:1113:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1137:19)
    at require (node:internal/modules/helpers:121:18)
    at Object.<anonymous> (apib2swagger/src/requests.js:4:19)
    at Module._compile (node:internal/modules/cjs/loader:1255:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1309:10) {
  name: 'InvalidTypeError',
  message: 'Type "extend" is not a valid type'
}

Some outputs are not valid against swagger 2.0 json schema

Hi @kminami,
at first let me thank you for this wonderful tool. I use it currently quite extensively to convert blueprints. We've integrated it into our system, which stores just swagger and it checks validity of each swagger file before storing. I've discovered that there are some outputs which are not valid against swagger 2.0 schema.

For instance:

  • Body parameters in swagger dost not support "type" and "default" properties, all must be stored under "schema" property as json schema.
  • "required" property in json schema must always be non-empty array or must not be present

I am enclosing a pull request (which however depends on my previous pull request) that should solve the issues I've found. There is also a test which now validates all inputs against swagger json schema and ome blueprints for testing purposes which caused the troubles.

I still know about one valid blueprint which is converted to non-valid swagger, but it's bit a more complex issue than these two, so I will push it later once it's solved properly.

Best regards,
Karel

Hard-coded query parameters are wrongly extracted as path parameters

Given the following from http://docs.icons8.apiary.io/api-description-document

# Search [/api/iconsets]

## By Keyword [GET /api/iconsets/v3/search?term={term}&amout={amount}&offset={offset}&platform={platform}&language={language}]

+ Parameters
    + term: `home` (string, required) - the name or tag of the icon or any other phrase.
        e.g. use "@home" to find icons with the tag "home" and "=home" to find icons with the name "home"
    + amount (number, optional) - the maximum number of icons which you'd like to receive
        + Default: 25
    + offset (number, optional) - the offset from the first received result
        + Default: 0
    + platform (enum[string], optional) - the style of the icons
        + Default: `all`
        + Members
            + `all`
            + `ios7`
            + `win8`
            + `win10`
            + `android`
            + `androidL`
            + `color`
            + `office`
    + language: `en-US` (enum[string], required) - the language code to get localized result
        + Members
            + `en-US`
            + `fr-FR`
            + `de-DE`
            + `it-IT`
            + `pt-BR`
            + `pl-PL`
            + `ru-RU`
            + `es-ES`

The generated swagger looks like:

  '/api/iconsets/v3/search?term={term}&amout={amount}&offset={offset}&platform={platform}&language={language}':
    get:
      description: ''
      parameters:
        - description: |
            the name or tag of the icon or any other phrase.
            e.g. use "@home" to find icons with the tag "home" and "=home" to find icons with the name "home"
          in: path
          name: term
          required: true
          type: string
        - default: 25
          description: the maximum number of icons which you'd like to receive
          in: path
          name: amount
          required: true
          type: number
        - description: the offset from the first received result
          in: path
          name: offset
          required: true
          type: number
        - default: all
          description: the style of the icons
          enum:
            - all
            - ios7
            - win8
            - win10
            - android
            - androidL
            - color
            - office
          in: path
          name: platform
          required: true
          type: string
        - description: the language code to get localized result
          enum:
            - en-US
            - fr-FR
            - de-DE
            - it-IT
            - pt-BR
            - pl-PL
            - ru-RU
            - es-ES
          in: path
          name: language
          required: true
          type: string

Whereas I would expect something like:

  '/api/iconsets/v3/search':
    get:
      description: ''
      parameters:
        - description: |
            the name or tag of the icon or any other phrase.
            e.g. use "@home" to find icons with the tag "home" and "=home" to find icons with the name "home"
          in: query
          name: term
          required: true
          type: string
        - default: 25
          description: the maximum number of icons which you'd like to receive
          in: query
          name: amount
          required: true
          type: number
        - description: the offset from the first received result
          in: query
          name: offset
          required: true
          type: number
        - default: all
          description: the style of the icons
          enum:
            - all
            - ios7
            - win8
            - win10
            - android
            - androidL
            - color
            - office
          in: query
          name: platform
          required: true
          type: string
        - description: the language code to get localized result
          enum:
            - en-US
            - fr-FR
            - de-DE
            - it-IT
            - pt-BR
            - pl-PL
            - ru-RU
            - es-ES
          in: query
          name: language
          required: true
          type: string

Group descriptions not converted

Using the following

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

# Example

Intro


# Group Test

Group description.

## /endpoint

### GET [GET]

Endpoint description.

+ Response 200

The group description does not get converted

Output:

swagger: '2.0'
info:
  title: Example
  version: ''
  description: Intro
host: example.com
basePath: /
schemes:
  - https
paths:
  /endpoint:
    get:
      responses:
        '200':
          description: OK
          headers: {}
          examples: {}
      summary: GET
      description: Endpoint description.
      tags:
        - Test
      parameters: []
definitions: {}

Security authorization header not generated?

Hi!

I'm trying to export to swagger some http request methods with Header Authorization and the swagger security section is not generated.

## Whatever [GET /whatever{?limit}]

+ Parameters

    + limit (number, optional) - The maximum number of results to return.
        + Default: `10`

+ Request basic (application/json)

    + Headers
    
            Authorization: Basic 12345

But in the generated swagger.json there is nothing about the Header in the request neither about the security section. Do you have any idea?

Thanks

Definitions are created containing / characters - leading to unresolvable $refs

Input URL: http://docs.shipstation.apiary.io/api-description-document

Contains headers with multiple HTTP verbs?

## Get/Delete Order [/orders/{orderId}]

Generated swagger (excerpts):

          "parameters": [
            {
              "name": "storeId",
              "in": "path",
              "description": "A unique ID generated by ShipStation and assigned to each store.",
              "required": true,
              "type": "number"
            },
            {
              "name": "body",
              "in": "body",
              "schema": {
                "$ref": "#/definitions/Get/Update StoreModel"
              }
            }
          ]

The output models/definitions also appear to be blank:

    "definitions": {
      "Get/Delete Order": {},
      "Get/Delete OrderModel": {},
      ...
    }

Refs APIs-guru/openapi-directory#121

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.