Comments (4)
Actually the drafter generated JSON AST for Element Object is wrong
Why do you say that? Please give an example blueprint, the AST generated out of it and what you think the AST should be.
from api-blueprint-ast.
@pksunkara I have given a code snippet in my first comment. I generated AST using drafter for almost all the examples present in github and found out Element Object AST is not what it should be...
Explanation : for the Element Object there are three properties "element (enum)", "attributes", "content". If the "element" is category the "content" property is List of Element Objects, but the AST is generated as List of different objects (ex Resource Object, DataStructure Object)
example AST for Advanced Action API
Note : Not considering the resouceGroup for shortening the AST
paste the both ASTs in JSON Editor would be easy to differentiate
Generated AST
{
"_version": "4.0",
"metadata": [
{
"name": "FORMAT",
"value": "1A"
}
],
"name": "Advanced Action API",
"description": "Description",
"element": "category",
"resourceGroups": [ ],
"content": [
{
"element": "category",
"content": [
{
"element": "resource",
"name": "Tasks",
"description": "",
"uriTemplate": "/tasks/tasks{?status,priority}",
"model": {},
"parameters": [
{
"name": "status",
"description": "",
"type": "string",
"required": true,
"default": "",
"example": "",
"values": []
},
{
"name": "priority",
"description": "",
"type": "number",
"required": true,
"default": "",
"example": "",
"values": []
}
],
"actions": [
{
"name": "List All Tasks",
"description": "",
"method": "GET",
"parameters": [],
"attributes": {
"relation": "",
"uriTemplate": ""
},
"content": [],
"examples": [
{
"name": "",
"description": "",
"requests": [],
"responses": [
{
"name": "200",
"description": "",
"headers": [
{
"name": "Content-Type",
"value": "application/json"
}
],
"body": "[\n {\n \"id\": 123,\n \"name\": \"Exercise in gym\",\n \"done\": false,\n \"type\": \"task\"\n },\n {\n \"id\": 124,\n \"name\": \"Shop for groceries\",\n \"done\": true,\n \"type\": \"task\"\n }\n]\n",
"schema": "",
"content": [
{
"element": "asset",
"attributes": {
"role": "bodyExample"
},
"content": "[\n {\n \"id\": 123,\n \"name\": \"Exercise in gym\",\n \"done\": false,\n \"type\": \"task\"\n },\n {\n \"id\": 124,\n \"name\": \"Shop for groceries\",\n \"done\": true,\n \"type\": \"task\"\n }\n]\n"
}
]
}
]
}
]
},
{
"name": "Retrieve Task",
"description": "This is a state transition to another resource\n\n",
"method": "GET",
"parameters": [
{
"name": "id",
"description": "",
"type": "string",
"required": true,
"default": "",
"example": "",
"values": []
}
],
"attributes": {
"relation": "",
"uriTemplate": "/task/{id}"
},
"content": [],
"examples": [
{
"name": "",
"description": "",
"requests": [],
"responses": [
{
"name": "200",
"description": "",
"headers": [
{
"name": "Content-Type",
"value": "application/json"
}
],
"body": "{\n \"id\": 123,\n \"name\": \"Go to gym\",\n \"done\": false,\n \"type\": \"task\"\n}\n",
"schema": "",
"content": [
{
"element": "asset",
"attributes": {
"role": "bodyExample"
},
"content": "{\n \"id\": 123,\n \"name\": \"Go to gym\",\n \"done\": false,\n \"type\": \"task\"\n}\n"
}
]
}
]
}
]
},
{
"name": "Delete Task",
"description": "",
"method": "DELETE",
"parameters": [
{
"name": "id",
"description": "",
"type": "string",
"required": true,
"default": "",
"example": "",
"values": []
}
],
"attributes": {
"relation": "",
"uriTemplate": "/task/{id}"
},
"content": [],
"examples": [
{
"name": "",
"description": "",
"requests": [],
"responses": [
{
"name": "204",
"description": "",
"headers": [],
"body": "",
"schema": "",
"content": []
}
]
}
]
}
],
"content": []
}
]
}
]
}
The AST should be as
{
"_version": "4.0",
"metadata": [
{
"name": "FORMAT",
"value": "1A"
}
],
"name": "Advanced Action API",
"description": " Description ",
"element": "category",
"resourceGroups": [],
"content": [
{
"element": "category",
"attributes" : {
"name" : "element object"
},
"content": [
{
"element" : "resource",
"attributes" : {
"name" : "element object"
},
"content" : {
"element": "resource",
"name": "Tasks",
"description": "",
"uriTemplate": "/tasks/tasks{?status,priority}",
"model": {},
"parameters": [
{
"name": "status",
"description": "",
"type": "string",
"required": true,
"default": "",
"example": "",
"values": []
},
{
"name": "priority",
"description": "",
"type": "number",
"required": true,
"default": "",
"example": "",
"values": []
}
],
"actions": [
{
"name": "List All Tasks",
"description": "",
"method": "GET",
"parameters": [],
"attributes": {
"relation": "",
"uriTemplate": ""
},
"content": [],
"examples": [
{
"name": "",
"description": "",
"requests": [],
"responses": [
{
"name": "200",
"description": "",
"headers": [
{
"name": "Content-Type",
"value": "application/json"
}
],
"body": "[\n {\n \"id\": 123,\n \"name\": \"Exercise in gym\",\n \"done\": false,\n \"type\": \"task\"\n },\n {\n \"id\": 124,\n \"name\": \"Shop for groceries\",\n \"done\": true,\n \"type\": \"task\"\n }\n]\n",
"schema": "",
"content": [
{
"element": "asset",
"attributes": {
"role": "bodyExample"
},
"content": "[\n {\n \"id\": 123,\n \"name\": \"Exercise in gym\",\n \"done\": false,\n \"type\": \"task\"\n },\n {\n \"id\": 124,\n \"name\": \"Shop for groceries\",\n \"done\": true,\n \"type\": \"task\"\n }\n]\n"
}
]
}
]
}
]
},
{
"name": "Retrieve Task",
"description": "This is a state transition to another resource\n\n",
"method": "GET",
"parameters": [
{
"name": "id",
"description": "",
"type": "string",
"required": true,
"default": "",
"example": "",
"values": []
}
],
"attributes": {
"relation": "",
"uriTemplate": "/task/{id}"
},
"content": [],
"examples": [
{
"name": "",
"description": "",
"requests": [],
"responses": [
{
"name": "200",
"description": "",
"headers": [
{
"name": "Content-Type",
"value": "application/json"
}
],
"body": "{\n \"id\": 123,\n \"name\": \"Go to gym\",\n \"done\": false,\n \"type\": \"task\"\n}\n",
"schema": "",
"content": [
{
"element": "asset",
"attributes": {
"role": "bodyExample"
},
"content": "{\n \"id\": 123,\n \"name\": \"Go to gym\",\n \"done\": false,\n \"type\": \"task\"\n}\n"
}
]
}
]
}
]
},
{
"name": "Delete Task",
"description": "",
"method": "DELETE",
"parameters": [
{
"name": "id",
"description": "",
"type": "string",
"required": true,
"default": "",
"example": "",
"values": []
}
],
"attributes": {
"relation": "",
"uriTemplate": "/task/{id}"
},
"content": [],
"examples": [
{
"name": "",
"description": "",
"requests": [],
"responses": [
{
"name": "204",
"description": "",
"headers": [],
"body": "",
"schema": "",
"content": []
}
]
}
]
}
],
"content": []
}
}
]
}
]
}
from api-blueprint-ast.
@pksunkara any update? Hoping you guys found the issue and it is resolved in refract since, Api Blueprint ast is not maintained anymore
from api-blueprint-ast.
As of 2015-12-02 the API Blueprint AST is deprecated and should not be used for new development. The API Blueprint AST has been superseded by API Description Refract Namespace.
You can still get the API Blueprint AST from the parser by passing the appropriate option but please understand that we will not be maintaining it anymore.
from api-blueprint-ast.
Related Issues (11)
- Use ordered arrays instead of maps HOT 2
- Missing symbol reference HOT 2
- Remove header sections deprecated in 1B
- Use object for parameter values
- Resource Groups deprecation/removal HOT 2
- Payload attributes (format 1A8) question HOT 1
- `element` causing confusion HOT 13
- parameters' enumerated values are missing description property in AST HOT 4
- My suggestion for parameter object HOT 4
- Model 1:1 {Headers, Body} HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from api-blueprint-ast.