Skip to content

Commit 86da184

Browse files
authored
Merge pull request #1094 from scitran/swagger-fix-undocumented-codegen
Swagger changes for code generation
2 parents b1edeca + 1ee8ba1 commit 86da184

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+623
-158
lines changed

swagger/Gruntfile.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,16 @@ module.exports = function(grunt) {
8585
}
8686
},
8787

88+
/**
89+
* Simplify swagger for codegen
90+
*/
91+
simplifySwagger: {
92+
core: {
93+
src: 'build/swagger-ui.json',
94+
dst: 'build/swagger-codegen.json'
95+
}
96+
},
97+
8898
/**
8999
* Validate swagger
90100
*/
@@ -152,7 +162,8 @@ module.exports = function(grunt) {
152162
'createBuildDir',
153163
'flattenSwagger',
154164
'schemasToDefs',
155-
'validateSwagger'
165+
'validateSwagger',
166+
'simplifySwagger'
156167
]);
157168

158169
/**

swagger/paths/collections.yaml

+7-5
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,13 @@ $template_arguments:
2020
$ref: examples/output/collection-list.json
2121
post:
2222
summary: Create a collection
23-
operationId: create_collection
23+
operationId: add_collection
2424
tags:
2525
- collections
2626
parameters:
27-
- in: body
28-
name: body
27+
- name: body
28+
in: body
29+
required: true
2930
schema:
3031
$ref: schemas/input/collection.json
3132
responses:
@@ -79,8 +80,9 @@ $template_arguments:
7980
tags:
8081
- collections
8182
parameters:
82-
- in: body
83-
name: body
83+
- name: body
84+
in: body
85+
required: true
8486
schema:
8587
$ref: schemas/input/collection-update.json
8688
responses:

swagger/paths/dataexplorer.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
- name: simple
77
in: query
88
type: boolean
9+
x-sdk-default: 'true'
910
- name: limit
1011
in: query
1112
type: integer
13+
x-sdk-default: 100
1214
- name: body
1315
in: body
1416
required: true

swagger/paths/groups.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ $template_arguments:
2525
parameters:
2626
- name: body
2727
in: body
28+
required: true
2829
schema:
2930
$ref: schemas/input/group-new.json
3031
responses:
@@ -34,6 +35,7 @@ $template_arguments:
3435
$ref: schemas/output/group-new.json
3536
'400':
3637
$ref: '#/responses/400:invalid-body-json'
38+
3739
/groups/{GroupId}:
3840
parameters:
3941
- required: true
@@ -61,6 +63,7 @@ $template_arguments:
6163
parameters:
6264
- in: body
6365
name: body
66+
required: true
6467
schema:
6568
$ref: schemas/input/group-update.json
6669
responses:

swagger/paths/login.yaml

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
'200':
88
description: ''
99
schema:
10-
example:
11-
success: true
10+
$ref: schemas/output/login-output.json
1211
/logout:
1312
post:
1413
summary: Log Out
@@ -18,5 +17,4 @@
1817
'200':
1918
description: ''
2019
schema:
21-
example:
22-
auth_tokens_removed: 2
20+
$ref: schemas/output/logout-output.json

swagger/paths/users.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
parameters:
1818
- name: body
1919
in: body
20+
required: true
2021
schema:
2122
$ref: schemas/input/user-new.json
2223
responses:
@@ -79,6 +80,7 @@
7980
parameters:
8081
- name: body
8182
in: body
83+
required: true
8284
schema:
8385
$ref: schemas/input/user-update.json
8486
description: >

swagger/schemas/definitions/acquisition.json

+14-12
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
"$schema": "http://json-schema.org/draft-04/schema#",
33
"definitions":{
44
"acquisition-input":{
5-
"type": "object",
6-
"properties": {
7-
"public": {"$ref":"container.json#/definitions/public"},
8-
"label": {"$ref":"common.json#/definitions/label"},
9-
"info": {"$ref":"container.json#/definitions/info"},
10-
"session": {"$ref":"common.json#/definitions/objectid"},
11-
"uid": {"$ref":"container.json#/definitions/uid"},
12-
"timestamp": {"$ref":"container.json#/definitions/timestamp"},
13-
"timezone": {"$ref":"container.json#/definitions/timezone"}
14-
},
15-
"additionalProperties":false
5+
"type": "object",
6+
"properties": {
7+
"public": {"$ref":"container.json#/definitions/public"},
8+
"label": {"$ref":"common.json#/definitions/label"},
9+
"info": {"$ref":"container.json#/definitions/info"},
10+
"session": {"$ref":"common.json#/definitions/objectid"},
11+
"uid": {"$ref":"container.json#/definitions/uid"},
12+
"timestamp": {"$ref":"container.json#/definitions/timestamp"},
13+
"timezone": {"$ref":"container.json#/definitions/timezone"}
14+
},
15+
"additionalProperties":false,
16+
"x-sdk-model": "acquisition"
1617
},
1718
"acquisition-metadata-input": {
1819
"type": "object",
@@ -67,7 +68,8 @@
6768
"items":{"$ref":"analysis.json#/definitions/analysis-output"}
6869
}
6970
},
70-
"additionalProperties":false
71+
"additionalProperties":false,
72+
"x-sdk-model": "acquisition"
7173
}
7274
}
7375
}

swagger/schemas/definitions/analysis.json

+25-27
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"description": {"$ref":"common.json#/definitions/description"},
1313
"label": {"$ref":"common.json#/definitions/label"}
1414
},
15-
"additionalProperties": false
15+
"additionalProperties": false,
16+
"x-sdk-model": "analysis-input"
1617
},
1718
"analysis-input-job":{
1819
"type":"object",
@@ -22,7 +23,8 @@
2223
"description": {"$ref":"common.json#/definitions/description"},
2324
"label": {"$ref":"common.json#/definitions/label"}
2425
},
25-
"additionalProperties": false
26+
"additionalProperties": false,
27+
"x-sdk-model": "analysis-input"
2628
},
2729
"analysis-input-legacy":{
2830
"type":"object",
@@ -41,11 +43,14 @@
4143
},
4244
"additionalProperties": false
4345
},
44-
"analysis-input": {"anyOf": [
45-
{"$ref":"#/definitions/analysis-input-adhoc"},
46-
{"$ref":"#/definitions/analysis-input-job"},
47-
{"$ref":"#/definitions/analysis-input-legacy"}
48-
]},
46+
"analysis-input-any": {
47+
"anyOf": [
48+
{"$ref":"#/definitions/analysis-input-adhoc"},
49+
{"$ref":"#/definitions/analysis-input-job"},
50+
{"$ref":"#/definitions/analysis-input-legacy"}
51+
],
52+
"x-sdk-schema": {"$ref":"#/definitions/analysis-input-adhoc"}
53+
},
4954
"analysis-update":{
5055
"type":"object",
5156
"properties":{
@@ -59,33 +64,40 @@
5964
"_id":{"$ref":"common.json#/definitions/objectid"},
6065
"inputs":{
6166
"type":"array",
62-
"items": {"$ref":"file.json#/definitions/file"}
67+
"items": {"$ref":"file.json#/definitions/file-entry"}
6368
},
6469
"files":{
6570
"type":"array",
66-
"items": {"$ref":"file.json#/definitions/file"}
71+
"items":{"$ref":"file.json#/definitions/file-entry"}
6772
},
6873
"job":{
6974
"oneOf":[
7075
{"$ref":"common.json#/definitions/objectid"},
7176
{"$ref": "job.json#/definitions/job-output"}
72-
]
77+
],
78+
"x-sdk-schema": {
79+
"$ref": "job.json#/definitions/job-output"
80+
}
7381
},
7482
"notes": {"$ref":"note.json#/definitions/notes-list-output"},
7583
"description": {"$ref":"common.json#/definitions/description"},
7684
"label": {"$ref":"common.json#/definitions/label"},
7785
"created": {"$ref":"created-modified.json#/definitions/created"},
7886
"modified": {"$ref":"created-modified.json#/definitions/modified"}
7987
},
80-
"required":["_id", "files", "label", "created", "modified"]
88+
"required":["_id", "label", "created", "modified"]
8189
},
8290
"analysis-list-entry":{
8391
"type":"object",
8492
"properties":{
8593
"_id":{"$ref":"common.json#/definitions/objectid"},
94+
"inputs":{
95+
"type":"array",
96+
"items": {"$ref":"file.json#/definitions/file-entry"}
97+
},
8698
"files":{
8799
"type":"array",
88-
"items":{"$ref":"file.json#/definitions/file"}
100+
"items":{"$ref":"file.json#/definitions/file-entry"}
89101
},
90102
"job": {"$ref":"common.json#/definitions/objectid"},
91103
"notes": {"$ref":"note.json#/definitions/notes-list-output"},
@@ -94,22 +106,8 @@
94106
"created": {"$ref":"created-modified.json#/definitions/created"},
95107
"modified": {"$ref":"created-modified.json#/definitions/modified"}
96108
},
97-
"required":["_id", "files", "label", "created", "modified"]
109+
"required":["_id", "label", "created", "modified"]
98110
},
99-
"analysis-job": {
100-
"type": "object",
101-
"properties":{
102-
"analysis":{
103-
"type":"object",
104-
"allOf":[{"$ref":"#/definitions/analysis-input"}],
105-
"required":["label"]
106-
},
107-
"job":{
108-
"type":"object",
109-
"allOf":[{"$ref":"job.json#/definitions/job-input"}]
110-
}
111-
}
112-
},
113111
"analysis-files-create-ticket-output": {
114112
"type":"object",
115113
"properties":{

swagger/schemas/definitions/auth.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"definitions": {
4+
"login-output": {
5+
"type": "object",
6+
"properties": {
7+
"token": {"type": "string"}
8+
},
9+
"required": ["token"]
10+
},
11+
"logout-output": {
12+
"type": "object",
13+
"properties": {
14+
"tokens_removed": {"type": "integer"}
15+
},
16+
"required": ["tokens_removed"]
17+
}
18+
}
19+
}

swagger/schemas/definitions/batch.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"batch-proposal-detail": {
99
"type": "object",
1010
"properties": {
11-
"analysis": {"$ref": "analysis.json#/definitions/analysis-input"},
11+
"analysis": {"$ref": "analysis.json#/definitions/analysis-input-job"},
1212
"tags": {"$ref":"tag.json#/definitions/tag-list"}
1313
},
1414
"additionalProperties": false
@@ -60,7 +60,7 @@
6060
"gear_id": {"$ref":"job.json#/definitions/gear_id"},
6161
"config": {"$ref":"job.json#/definitions/config"},
6262
"tags": {"$ref":"tag.json#/definitions/tag-list"},
63-
"analysis": {"$ref": "analysis.json#/definitions/analysis-input"},
63+
"analysis": {"$ref": "analysis.json#/definitions/analysis-input-job"},
6464
"targets": {
6565
"type": "array",
6666
"items": {"$ref":"container.json#/definitions/container-reference"}

swagger/schemas/definitions/collection.json

+31-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,31 @@
11
{
22
"$schema": "http://json-schema.org/draft-04/schema#",
33
"definitions":{
4+
"collection-node": {
5+
"type": "object",
6+
"properties": {
7+
"level": {
8+
"type": "string",
9+
"enum": ["project", "session", "acquisition"]
10+
},
11+
"_id": { "$ref": "common.json#/definitions/objectid" }
12+
},
13+
"additionalProperties": false
14+
},
15+
"collection-operation": {
16+
"type": "object",
17+
"properties": {
18+
"operation": {
19+
"type": "string",
20+
"enum": ["add", "remove"]
21+
},
22+
"nodes": {
23+
"type": "array",
24+
"items": { "$ref": "#/definitions/collection-node" }
25+
}
26+
},
27+
"additionalProperties": false
28+
},
429
"collection-input":{
530
"type": "object",
631
"properties": {
@@ -9,6 +34,7 @@
934
"info": {"$ref": "container.json#/definitions/info"},
1035
"description": {"$ref": "common.json#/definitions/description"}
1136
},
37+
"x-sdk-model": "collection",
1238
"additionalProperties": false
1339
},
1440
"collection-input-with-contents":{
@@ -18,16 +44,18 @@
1844
"label": {"$ref": "common.json#/definitions/label"},
1945
"info": {"$ref": "container.json#/definitions/info"},
2046
"description": {"$ref": "common.json#/definitions/description"},
21-
"contents": { "type": "object" }
47+
"contents": {"$ref": "#/definitions/collection-operation"}
2248
},
49+
"x-sdk-model": "collection",
2350
"additionalProperties": false
2451
},
2552
"collection-new-output": {
2653
"type": "object",
2754
"properties": {
2855
"_id": {"$ref":"common.json#/definitions/objectid"}
2956
},
30-
"required": ["_id"]
57+
"required": ["_id"],
58+
"x-sdk-return": "_id"
3159
},
3260
"collection-output":{
3361
"type": "object",
@@ -56,6 +84,7 @@
5684
"items":{"$ref":"analysis.json#/definitions/analysis-output"}
5785
}
5886
},
87+
"x-sdk-model": "collection",
5988
"additionalProperties":false
6089
}
6190
}

swagger/schemas/definitions/common.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@
5252
"_id": {
5353
"type": "string"
5454
}
55-
}
55+
},
56+
"x-sdk-return": "_id"
5657
}
5758
}
5859
}

0 commit comments

Comments
 (0)