apib2swagger 1.14.2 → 1.14.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -51,11 +51,11 @@ function convert(mson, options) {
|
|
|
51
51
|
schema.required = [];
|
|
52
52
|
schema.properties = {};
|
|
53
53
|
for (var j = 0; mson.content && j < mson.content.length; j++) {
|
|
54
|
-
|
|
54
|
+
const member = mson.content[j];
|
|
55
55
|
if (member.element !== "member") continue;
|
|
56
|
-
|
|
56
|
+
var propertySchema = convert(member.content.value, options);
|
|
57
57
|
if (member.meta && member.meta.description) {
|
|
58
|
-
|
|
58
|
+
propertySchema.description = member.meta.description;
|
|
59
59
|
}
|
|
60
60
|
var fixedType = false;
|
|
61
61
|
if (member.attributes && member.attributes.typeAttributes) {
|
|
@@ -68,14 +68,19 @@ function convert(mson, options) {
|
|
|
68
68
|
schema.required.push(member.content.key.content);
|
|
69
69
|
break;
|
|
70
70
|
case 'nullable':
|
|
71
|
-
|
|
71
|
+
if (propertySchema.$ref) {
|
|
72
|
+
propertySchema = {oneOf: [propertySchema, {type: 'null'}]};
|
|
73
|
+
} else {
|
|
74
|
+
propertySchema.type = [propertySchema.type, 'null']
|
|
75
|
+
}
|
|
72
76
|
break;
|
|
73
77
|
}
|
|
74
78
|
});
|
|
75
79
|
}
|
|
76
|
-
if (
|
|
77
|
-
|
|
80
|
+
if (propertySchema.type === 'array' && !fixedType) {
|
|
81
|
+
propertySchema.items = {}; // reset item schema
|
|
78
82
|
}
|
|
83
|
+
schema.properties[member.content.key.content] = propertySchema;
|
|
79
84
|
}
|
|
80
85
|
|
|
81
86
|
// According to schema definition, required is a stringArray, which must be non-empty
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"openapi": "3.0.3",
|
|
3
|
+
"info": {
|
|
4
|
+
"title": "",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"description": ""
|
|
7
|
+
},
|
|
8
|
+
"paths": {},
|
|
9
|
+
"components": {
|
|
10
|
+
"schemas": {
|
|
11
|
+
"ImagesType": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"properties": {
|
|
14
|
+
"name": {
|
|
15
|
+
"type": "string"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"BodyType": {
|
|
20
|
+
"type": "object",
|
|
21
|
+
"required": [
|
|
22
|
+
"images"
|
|
23
|
+
],
|
|
24
|
+
"properties": {
|
|
25
|
+
"images": {
|
|
26
|
+
"oneOf": [
|
|
27
|
+
{
|
|
28
|
+
"$ref": "#/components/schemas/ImagesType"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"nullable": true
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"tags": []
|
|
40
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"openapi": "3.0.3",
|
|
3
|
+
"info": {
|
|
4
|
+
"title": "",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"description": ""
|
|
7
|
+
},
|
|
8
|
+
"paths": {},
|
|
9
|
+
"components": {
|
|
10
|
+
"schemas": {
|
|
11
|
+
"ImagesType": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"properties": {
|
|
14
|
+
"name": {
|
|
15
|
+
"type": "string"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"BodyType": {
|
|
20
|
+
"type": "object",
|
|
21
|
+
"required": [
|
|
22
|
+
"images"
|
|
23
|
+
],
|
|
24
|
+
"properties": {
|
|
25
|
+
"images": {
|
|
26
|
+
"oneOf": [
|
|
27
|
+
{
|
|
28
|
+
"$ref": "#/components/schemas/ImagesType"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"nullable": true
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"tags": []
|
|
40
|
+
}
|
package/test/test.js
CHANGED
|
@@ -55,7 +55,8 @@ var remote = 'https://raw.githubusercontent.com/apiaryio/api-blueprint/format-1A
|
|
|
55
55
|
'OpenAPI3_headers.md',
|
|
56
56
|
'OpenAPI3_includes.md',
|
|
57
57
|
'OpenAPI3_attributes.md',
|
|
58
|
-
'OpenAPI3_Issue-#58.md'
|
|
58
|
+
'OpenAPI3_Issue-#58.md',
|
|
59
|
+
'OpenAPI3_Issue-#66.md'
|
|
59
60
|
];
|
|
60
61
|
|
|
61
62
|
var fetch = function (file) {
|