apiaryio / swagger2blueprint Goto Github PK
View Code? Open in Web Editor NEWConvert Swagger API descriptions into API Blueprint
License: MIT License
Convert Swagger API descriptions into API Blueprint
License: MIT License
Currently the tests are testing only if it can read files locally and remotely.
It should test the conversion itself, compare expected API Blueprint with a result of conversion.
I like the look of this project! - Are there plans to go in the other direction also?
When converting, the resulting API Blueprint file is missing the HOST
key/value in the metadata section.
Swagger input:
# this is an example of the Uber API
# as a demonstration of an API spec in YAML
swagger: '2.0'
info:
title: Uber API
description: Move your app forward with the Uber API
version: "1.0.0"
# the domain of the service
host: api.uber.com
# array of all schemes that your API supports
schemes:
- https
# will be prefixed to all paths
basePath: /v1
produces:
- application/json
...
API Blueprint output:
FORMAT: 1A
# Uber API
Move your app forward with the Uber API
...
Hi, I'm trying to generate a spec for the post action of a endpoint of our api but I'm not able to generate the output as I was expecting.
That action accepts some parameters in the body as a json payload and generates some different responses. So, I wrote a parameters section (with a schema definition) and some responses (200, 400, 404, 422, 500).
When I run swagger2blueprint it generates an output with two pairs request (schema ) + response sections ... but I was expecting one parameters section and two response sections.
It is a problem because when I run later aglio for generating a static html documentation it consideres that outputs as examples instead of a parameters + responses specification.
It is the expected output ? (btw, I'm using the latest version 1.0.2)
Input:
swagger: '2.0'
info:
title: Test API
description: Test
version: "1.0"
host: www.test.com
schemes:
- https
consumes:
- application/json
produces:
- application/json
paths:
/interviews/appointments?order={order}:
get:
summary: List of appointments
operationId: appointmentsList
parameters:
- in: query
name: order
type: string
responses:
200:
schema:
$ref: '#/definitions/Appointment'
500:
schema:
$ref: '#/definitions/Error'
post:
summary: Create an appointment
operationId: appointmentsCreation
parameters:
- name: appointment
in: body
description: appointment to create
required: true
schema:
$ref: '#/definitions/NewAppointment'
responses:
200:
schema:
$ref: '#/definitions/Appointment'
500:
schema:
$ref: '#/definitions/Error'
definitions:
NewAppointment:
required:
- time
- first_name
properties:
time:
type: string
first_name:
type: string
Appointment:
required:
- id
- time
- first_name
properties:
id:
type: integer
format: int32
time:
type: string
first_name:
type: string
Error:
required:
- code
- message
properties:
code:
type: integer
format: int32
message:
type: string
Output:
FORMAT: 1A
# Test API
Test
### /interviews/appointments?order={order}
#### List of appointments [GET /interviews/appointments?order={order}{?order}]
+ Parameters
+ order
+ Relation: appointmentsList
+ Response 200
+ Body
+ Schema
{
"required": [
"id",
"time",
"first_name"
],
"properties": {
"id": {
"type": "integer",
"format": "int32"
},
"time": {
"type": "string"
},
"first_name": {
"type": "string"
}
}
}
+ Response 500
+ Body
+ Schema
{
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
}
#### Create an appointment [POST]
+ Relation: appointmentsCreation
+ Request
+ Body
+ Schema
{
"required": [
"time",
"first_name"
],
"properties": {
"time": {
"type": "string"
},
"first_name": {
"type": "string"
}
}
}
+ Response 200
+ Body
+ Schema
{
"required": [
"id",
"time",
"first_name"
],
"properties": {
"id": {
"type": "integer",
"format": "int32"
},
"time": {
"type": "string"
},
"first_name": {
"type": "string"
}
}
}
+ Request
+ Body
+ Schema
{
"required": [
"time",
"first_name"
],
"properties": {
"time": {
"type": "string"
},
"first_name": {
"type": "string"
}
}
}
+ Response 500
+ Body
+ Schema
{
"required": [
"code",
"message"
],
"properties": {
"code": {
"type": "integer",
"format": "int32"
},
"message": {
"type": "string"
}
}
}
sm@Sof:~$ node --version
v0.10.40
sm@Sof:~$ npm install -g swagger2blueprint
> [email protected] install /home/sm/n/lib/node_modules/swagger2blueprint/node_modules/fury/node_modules/robotskirt
> node-gyp rebuild
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: incorrect header check
gyp ERR! stack at Zlib._binding.onerror (zlib.js:296:17)
gyp ERR! System Linux 3.19.0-26-generic
gyp ERR! command "node" "/home/sm/n/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/sm/n/lib/node_modules/swagger2blueprint/node_modules/fury/node_modules/robotskirt
gyp ERR! node -v v0.10.40
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok
> [email protected] install /home/sm/n/lib/node_modules/swagger2blueprint/node_modules/fury/node_modules/drafter/node_modules/protagonist
> node-gyp rebuild
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: incorrect header check
gyp ERR! stack at Zlib._binding.onerror (zlib.js:296:17)
gyp ERR! System Linux 3.19.0-26-generic
gyp ERR! command "node" "/home/sm/n/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/sm/n/lib/node_modules/swagger2blueprint/node_modules/fury/node_modules/drafter/node_modules/protagonist
gyp ERR! node -v v0.10.40
gyp ERR! node-gyp -v v1.0.1
gyp ERR! not ok
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is most likely a problem with the robotskirt 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 robotskirt
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.19.0-26-generic
npm ERR! command "/home/sm/n/bin/node" "/home/sm/n/bin/npm" "install" "-g" "swagger2blueprint"
npm ERR! cwd /home/sm
npm ERR! node -v v0.10.40
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYC
This PR has added support to convert arrays in query parameters but it hadn't converted the value in the arrays to MSON in API Blueprint
$ swagger2blueprint some.yml
Template render error: (/usr/local/lib/node_modules/swagger2blueprint/node_modules/fury-adapter-apib-serializer/template.nunjucks) [Line 51, Column 23]
Error: Unable to call item["key"]["toValue"]
, which is undefined or falsey
Any idea what this is or how to fix it?
Many node-gyp compilation errors when installing with npm finally resulting in an msbuild exit code:1
##redacted long list of similar errors
C:\Users\Jonny\.node-gyp\0.12.6\deps\v8\include\v8.h(317) : see declaration of 'v8::Handle<v8::Value
>::Handle'
c:\users\jonny\appdata\roaming\npm\node_modules\swagger2blueprint\node_modules\fury\node_modules\robotskirt\sr c\version.hpp(52): error C2039: 'New' : is not a member of 'v8::String' [C:\Users\Jonny\AppData\Roaming\npm\no de_modules\swagger2blueprint\node_modules\fury\node_modules\robotskirt\build\robotskirt.vcxproj]
C:\Users\Jonny\.node-gyp\0.12.6\deps\v8\include\v8.h(1599) : see declaration of 'v8::String'
c:\users\jonny\appdata\roaming\npm\node_modules\swagger2blueprint\node_modules\fury\node_modules\robotskirt\sr c\version.hpp(52): error C3861: 'New': identifier not found [C:\Users\Jonny\AppData\Roaming\npm\node_modules\s wagger2blueprint\node_modules\fury\node_modules\robotskirt\build\robotskirt.vcxproj]
C:\Users\Jonny\.node-gyp\0.12.6\deps\v8\include\v8.h(1599) : see declaration of 'v8::String'
C:\Users\Jonny\.node-gyp\0.12.6\deps\v8\include\v8.h(1599) : see declaration of 'v8::String'
c:\users\jonny\appdata\roaming\npm\node_modules\swagger2blueprint\node_modules\fury\node_modules\robotskirt\sr c\version.hpp(68): error C2248: 'v8::HandleScope::HandleScope' : cannot access protected member declared in cl ass 'v8::HandleScope' [C:\Users\Jonny\AppData\Roaming\npm\node_modules\swagger2blueprint\node_modules\fury\nod e_modules\robotskirt\build\robotskirt.vcxproj]
C:\Users\Jonny\.node-gyp\0.12.6\deps\v8\include\v8.h(816) : see declaration of 'v8::HandleScope::Han
dleScope'
C:\Users\Jonny\.node-gyp\0.12.6\deps\v8\include\v8.h(800) : see declaration of 'v8::HandleScope'
c:\users\jonny\appdata\roaming\npm\node_modules\swagger2blueprint\node_modules\fury\node_modules\robotskirt\sr c\version.hpp(68): error C3083: 'ObjectWrap': the symbol to the left of a '::' must be a type [C:\Users\Jonny\ AppData\Roaming\npm\node_modules\swagger2blueprint\node_modules\fury\node_modules\robotskirt\build\robotskirt. vcxproj]
c:\users\jonny\appdata\roaming\npm\node_modules\swagger2blueprint\node_modules\fury\node_modules\robotskirt\sr c\version.hpp(68): error C2039: 'Unwrap' : is not a member of 'node' [C:\Users\Jonny\AppData\Roaming\npm\node_ modules\swagger2blueprint\node_modules\fury\node_modules\robotskirt\build\robotskirt.vcxproj]
c:\users\jonny\appdata\roaming\npm\node_modules\swagger2blueprint\node_modules\fury\node_modules\robotskirt\sr c\version.hpp(68): error C2065: 'Unwrap' : undeclared identifier [C:\Users\Jonny\AppData\Roaming\npm\node_modu les\swagger2blueprint\node_modules\fury\node_modules\robotskirt\build\robotskirt.vcxproj]
c:\users\jonny\appdata\roaming\npm\node_modules\swagger2blueprint\node_modules\fury\node_modules\robotskirt\sr c\version.hpp(68): fatal error C1003: error count exceeds 100; stopping compilation [C:\Users\Jonny\AppData\Ro aming\npm\node_modules\swagger2blueprint\node_modules\fury\node_modules\robotskirt\build\robotskirt.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:269:23)
gyp ERR! stack at ChildProcess.emit (events.js:110:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:1074:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Jonny\AppData\Roaming\npm\node_modules\swagger2blueprint\node_modules\fury\node_modules\robotskirt
gyp ERR! node -v v0.12.6
gyp ERR! node-gyp -v v2.0.1
gyp ERR! not ok
npm version: 2.11.2
I think this may be expected with Node 0.12 since the APIs are no longer compatible with those of 0.10.
Some research indicates that Robotskirt is now deprecated as Sundown is dead, and it has several security bugs.
Can you advise please.
When running the converter, the Body part of the blueprint is not pupolated.
Given the uber.yml swagger file the converted blueprint is missing action / endpoints descriptions. For example "The Products endpoint returns information about the Uber product.." description is missing from the "GET /product" action.
The output of parsing uber.yml swagger file is illegal blueprint:
+ Response 200
+ Response default
The word default
isn't allowed in API Blueprint only HTTP status codes are expected.
Furthermore the response is missing any body – is this intended?
Note same issues apply to the Pet Store example
Regression issue introduced with fury v0.8.2:
1) Swagger converter should read a URL:
Uncaught TypeError: Cannot read property 'request' of undefined
at index.js:29:10
at convert (index.js:24:8)
at Request._callback (index.js:62:7)
at _stream_readable.js:944:16
input file
{"swagger":"2.0","info":{"contact":{},"title":"home","version":"1.0.0","description":"home"},"basePath":"/","tags":[],"schemes":["http"],"securityDefinitions":{},"definitions":{},"paths":{"/api/team":{"delete":{"tags":["apicloud"],"summary":"delete team","description":"delete team","operationId":"","consumes":["application/json"],"produces":["application/json"],"deprecated":false,"parameters":[{"name":"id","in":"query","description":"identity","required":true,"type":"string"}],"responses":{"200":{"description":""}}}}}}
output file
FORMAT: 1A
# home
home
## Group apicloud
#### 删除团队 [DELETE /api/team]
删除团队
+ Parameters
+ id (required)
+ Request (application/json)
+ Headers
Accept: application/json
+ Body
+ Response 200 (application/json)
无
+ Body
The property description
of the id
is lost.
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.