Giter VIP home page Giter VIP logo

apib2json's Issues

TypeError: Cannot read property 'contentType' of undefined

I tried to run apib2json on the following Blueprint: https://airdcpp.docs.apiary.io. I get the following error:

/src/apib2json/lib/apib2json.js:92
                                        if (isAsset && rContent.attributes.contentType === 'application/schema+json') {
                                                                           ^

TypeError: Cannot read property 'contentType' of undefined
    at httpTransaction.content.forEach (/src/apib2json/lib/apib2json.js:92:76)
    at Array.forEach (<anonymous>)
    at content.content.forEach (/src/apib2json/lib/apib2json.js:90:61)
    at Array.forEach (<anonymous>)
    at transition.content.forEach (/src/apib2json/lib/apib2json.js:72:49)
    at Array.forEach (<anonymous>)
    at resource.content.forEach (/src/apib2json/lib/apib2json.js:66:48)
    at Array.forEach (<anonymous>)
    at group.content.forEach (/src/apib2json/lib/apib2json.js:61:42)
    at Array.forEach (<anonymous>)

I did some debugging and there seems to be two resources that are missing the attributes key:

It seems to be when the response code is anything other than 2xx.

Race condition

Hi,

I have found a bug but I'm not sure how to fix it. I have a document that includes a title for a response, parsing the file with apib2json does not return the title in meta object. Looking at the code, this line has the test to decide if the title should be set or not https://github.com/o5/apib2json/blob/master/lib/apib2json.js#L114

if ('meta' in httpTransaction && 'title' in httpTransaction.meta) {
    item.meta.title = httpTransaction.meta.title;
}

The issue is that httpTransaction.meta is empty at this point, inside the closure httpTransaction.content.forEach((rContent) => {}

But if I print httpTransaction.meta just before entering the closure the value is there.

Sorry, I'm not really a nodejs developer, I know for sure is a race condition but not sure how to fix it, I hope you can help me with this.

Cheers,
Mario

Missing atrribute in schema

Hi,

I have problem with parsing attributes and I do not know if I missing something or if this is a bug.

I will try to demonstrate it on following minimal example. This is the minimal blueprint file:

FORMAT: 1A

# Minimal example API

Example of minimal API

# Group Authentication

## Authentication [/et/v1/{id}/auth]
Authentication...

+ Parameters
    + id: `42` (number) - example id

### Initialize Authentication [GET]

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

# Data Structures

## BaseModel (object)
+ _links (string)

## AuthenticationModel (BaseModel)
+ example (boolean)

And this is corresponding json output, generated using apib2json.

{
  "[GET]/et/v1/{id}/auth": [
    {
      "meta": {
        "type": "response",
        "title": null,
        "group": "Authentication",
        "statusCode": "200"
      },
      "schema": {
        "$schema": "http://json-schema.org/draft-04/schema#",
        "type": "object",
        "properties": {
          "_links": {
            "type": "string"
          },
          "example": {
            "type": "boolean"
          }
        }
      }
    }
  ]
}

Unfortunately, I cannot find any information about id parameter in generated JSON file. Am I missing something or is it a bug?

Remove docker instances after exiting

Hi, you should advise in the README to run the Docker image with --rm option, otherwise users will end up with tons of unused stale containers.

From docker run -h

      --rm                             Automatically remove the container when it exits

Did not recognizance contenttype

I tried using this tool to convert our blueprint to json and got a empty object as output.

After some debugging found out that line 93 of lib/apib2json.js was the problem.

It checks the content type for "application/scheme+json" While for the blueprint we use it was "application/json".

A possible solution for this is to check for both or make a regex expression to catch multiple cases (i have personally never seen scheme+json so there might be a few others i have never seen).

(For the rest this tool was exactly what i was looking for. No other npm module could give me something to mock requests that where defined in apib)

Node 10 and greater support?

Is there a plan to support this module further? Currently due to the dependency on protagonist this tool is not useable in CIs running with Node LTS 10 and above. If protagonist is to remain a hard dependency either this module needs updating protagonist or decoupling from it. If there is no plan to support further versions of node then we should include a engine restriction in the package.json to prevent installs and throw an error when node version is greater than the supported version.

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.