slimapi / apib2json Goto Github PK
View Code? Open in Web Editor NEWA command-line utility for get JSON Schema(s) from API Blueprint
License: MIT License
A command-line utility for get JSON Schema(s) from API Blueprint
License: MIT License
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.
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
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?
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
I keep getting File <input> cannot be opened
any idea what could be the causes for this. I can generate HTML using snowboard from the apib
file and and also checked for any error all looks good.
https://github.com/o5/apib2json/blob/44b0559a6d3ca4d9143ae068695f1291f5d88015/bin/apib2json#L61
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)
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.