Skip to content

Commit

Permalink
Merge pull request #1094 from scitran/swagger-fix-undocumented-codegen
Browse files Browse the repository at this point in the history
Swagger changes for code generation
  • Loading branch information
ehlertjd authored Mar 15, 2018
2 parents b1edeca + 1ee8ba1 commit 86da184
Show file tree
Hide file tree
Showing 49 changed files with 623 additions and 158 deletions.
13 changes: 12 additions & 1 deletion swagger/Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ module.exports = function(grunt) {
}
},

/**
* Simplify swagger for codegen
*/
simplifySwagger: {
core: {
src: 'build/swagger-ui.json',
dst: 'build/swagger-codegen.json'
}
},

/**
* Validate swagger
*/
Expand Down Expand Up @@ -152,7 +162,8 @@ module.exports = function(grunt) {
'createBuildDir',
'flattenSwagger',
'schemasToDefs',
'validateSwagger'
'validateSwagger',
'simplifySwagger'
]);

/**
Expand Down
12 changes: 7 additions & 5 deletions swagger/paths/collections.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ $template_arguments:
$ref: examples/output/collection-list.json
post:
summary: Create a collection
operationId: create_collection
operationId: add_collection
tags:
- collections
parameters:
- in: body
name: body
- name: body
in: body
required: true
schema:
$ref: schemas/input/collection.json
responses:
Expand Down Expand Up @@ -79,8 +80,9 @@ $template_arguments:
tags:
- collections
parameters:
- in: body
name: body
- name: body
in: body
required: true
schema:
$ref: schemas/input/collection-update.json
responses:
Expand Down
2 changes: 2 additions & 0 deletions swagger/paths/dataexplorer.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
- name: simple
in: query
type: boolean
x-sdk-default: 'true'
- name: limit
in: query
type: integer
x-sdk-default: 100
- name: body
in: body
required: true
Expand Down
3 changes: 3 additions & 0 deletions swagger/paths/groups.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ $template_arguments:
parameters:
- name: body
in: body
required: true
schema:
$ref: schemas/input/group-new.json
responses:
Expand All @@ -34,6 +35,7 @@ $template_arguments:
$ref: schemas/output/group-new.json
'400':
$ref: '#/responses/400:invalid-body-json'

/groups/{GroupId}:
parameters:
- required: true
Expand Down Expand Up @@ -61,6 +63,7 @@ $template_arguments:
parameters:
- in: body
name: body
required: true
schema:
$ref: schemas/input/group-update.json
responses:
Expand Down
6 changes: 2 additions & 4 deletions swagger/paths/login.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
'200':
description: ''
schema:
example:
success: true
$ref: schemas/output/login-output.json
/logout:
post:
summary: Log Out
Expand All @@ -18,5 +17,4 @@
'200':
description: ''
schema:
example:
auth_tokens_removed: 2
$ref: schemas/output/logout-output.json
2 changes: 2 additions & 0 deletions swagger/paths/users.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
parameters:
- name: body
in: body
required: true
schema:
$ref: schemas/input/user-new.json
responses:
Expand Down Expand Up @@ -79,6 +80,7 @@
parameters:
- name: body
in: body
required: true
schema:
$ref: schemas/input/user-update.json
description: >
Expand Down
26 changes: 14 additions & 12 deletions swagger/schemas/definitions/acquisition.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions":{
"acquisition-input":{
"type": "object",
"properties": {
"public": {"$ref":"container.json#/definitions/public"},
"label": {"$ref":"common.json#/definitions/label"},
"info": {"$ref":"container.json#/definitions/info"},
"session": {"$ref":"common.json#/definitions/objectid"},
"uid": {"$ref":"container.json#/definitions/uid"},
"timestamp": {"$ref":"container.json#/definitions/timestamp"},
"timezone": {"$ref":"container.json#/definitions/timezone"}
},
"additionalProperties":false
"type": "object",
"properties": {
"public": {"$ref":"container.json#/definitions/public"},
"label": {"$ref":"common.json#/definitions/label"},
"info": {"$ref":"container.json#/definitions/info"},
"session": {"$ref":"common.json#/definitions/objectid"},
"uid": {"$ref":"container.json#/definitions/uid"},
"timestamp": {"$ref":"container.json#/definitions/timestamp"},
"timezone": {"$ref":"container.json#/definitions/timezone"}
},
"additionalProperties":false,
"x-sdk-model": "acquisition"
},
"acquisition-metadata-input": {
"type": "object",
Expand Down Expand Up @@ -67,7 +68,8 @@
"items":{"$ref":"analysis.json#/definitions/analysis-output"}
}
},
"additionalProperties":false
"additionalProperties":false,
"x-sdk-model": "acquisition"
}
}
}
52 changes: 25 additions & 27 deletions swagger/schemas/definitions/analysis.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"description": {"$ref":"common.json#/definitions/description"},
"label": {"$ref":"common.json#/definitions/label"}
},
"additionalProperties": false
"additionalProperties": false,
"x-sdk-model": "analysis-input"
},
"analysis-input-job":{
"type":"object",
Expand All @@ -22,7 +23,8 @@
"description": {"$ref":"common.json#/definitions/description"},
"label": {"$ref":"common.json#/definitions/label"}
},
"additionalProperties": false
"additionalProperties": false,
"x-sdk-model": "analysis-input"
},
"analysis-input-legacy":{
"type":"object",
Expand All @@ -41,11 +43,14 @@
},
"additionalProperties": false
},
"analysis-input": {"anyOf": [
{"$ref":"#/definitions/analysis-input-adhoc"},
{"$ref":"#/definitions/analysis-input-job"},
{"$ref":"#/definitions/analysis-input-legacy"}
]},
"analysis-input-any": {
"anyOf": [
{"$ref":"#/definitions/analysis-input-adhoc"},
{"$ref":"#/definitions/analysis-input-job"},
{"$ref":"#/definitions/analysis-input-legacy"}
],
"x-sdk-schema": {"$ref":"#/definitions/analysis-input-adhoc"}
},
"analysis-update":{
"type":"object",
"properties":{
Expand All @@ -59,33 +64,40 @@
"_id":{"$ref":"common.json#/definitions/objectid"},
"inputs":{
"type":"array",
"items": {"$ref":"file.json#/definitions/file"}
"items": {"$ref":"file.json#/definitions/file-entry"}
},
"files":{
"type":"array",
"items": {"$ref":"file.json#/definitions/file"}
"items":{"$ref":"file.json#/definitions/file-entry"}
},
"job":{
"oneOf":[
{"$ref":"common.json#/definitions/objectid"},
{"$ref": "job.json#/definitions/job-output"}
]
],
"x-sdk-schema": {
"$ref": "job.json#/definitions/job-output"
}
},
"notes": {"$ref":"note.json#/definitions/notes-list-output"},
"description": {"$ref":"common.json#/definitions/description"},
"label": {"$ref":"common.json#/definitions/label"},
"created": {"$ref":"created-modified.json#/definitions/created"},
"modified": {"$ref":"created-modified.json#/definitions/modified"}
},
"required":["_id", "files", "label", "created", "modified"]
"required":["_id", "label", "created", "modified"]
},
"analysis-list-entry":{
"type":"object",
"properties":{
"_id":{"$ref":"common.json#/definitions/objectid"},
"inputs":{
"type":"array",
"items": {"$ref":"file.json#/definitions/file-entry"}
},
"files":{
"type":"array",
"items":{"$ref":"file.json#/definitions/file"}
"items":{"$ref":"file.json#/definitions/file-entry"}
},
"job": {"$ref":"common.json#/definitions/objectid"},
"notes": {"$ref":"note.json#/definitions/notes-list-output"},
Expand All @@ -94,22 +106,8 @@
"created": {"$ref":"created-modified.json#/definitions/created"},
"modified": {"$ref":"created-modified.json#/definitions/modified"}
},
"required":["_id", "files", "label", "created", "modified"]
"required":["_id", "label", "created", "modified"]
},
"analysis-job": {
"type": "object",
"properties":{
"analysis":{
"type":"object",
"allOf":[{"$ref":"#/definitions/analysis-input"}],
"required":["label"]
},
"job":{
"type":"object",
"allOf":[{"$ref":"job.json#/definitions/job-input"}]
}
}
},
"analysis-files-create-ticket-output": {
"type":"object",
"properties":{
Expand Down
19 changes: 19 additions & 0 deletions swagger/schemas/definitions/auth.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"login-output": {
"type": "object",
"properties": {
"token": {"type": "string"}
},
"required": ["token"]
},
"logout-output": {
"type": "object",
"properties": {
"tokens_removed": {"type": "integer"}
},
"required": ["tokens_removed"]
}
}
}
4 changes: 2 additions & 2 deletions swagger/schemas/definitions/batch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"batch-proposal-detail": {
"type": "object",
"properties": {
"analysis": {"$ref": "analysis.json#/definitions/analysis-input"},
"analysis": {"$ref": "analysis.json#/definitions/analysis-input-job"},
"tags": {"$ref":"tag.json#/definitions/tag-list"}
},
"additionalProperties": false
Expand Down Expand Up @@ -60,7 +60,7 @@
"gear_id": {"$ref":"job.json#/definitions/gear_id"},
"config": {"$ref":"job.json#/definitions/config"},
"tags": {"$ref":"tag.json#/definitions/tag-list"},
"analysis": {"$ref": "analysis.json#/definitions/analysis-input"},
"analysis": {"$ref": "analysis.json#/definitions/analysis-input-job"},
"targets": {
"type": "array",
"items": {"$ref":"container.json#/definitions/container-reference"}
Expand Down
33 changes: 31 additions & 2 deletions swagger/schemas/definitions/collection.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions":{
"collection-node": {
"type": "object",
"properties": {
"level": {
"type": "string",
"enum": ["project", "session", "acquisition"]
},
"_id": { "$ref": "common.json#/definitions/objectid" }
},
"additionalProperties": false
},
"collection-operation": {
"type": "object",
"properties": {
"operation": {
"type": "string",
"enum": ["add", "remove"]
},
"nodes": {
"type": "array",
"items": { "$ref": "#/definitions/collection-node" }
}
},
"additionalProperties": false
},
"collection-input":{
"type": "object",
"properties": {
Expand All @@ -9,6 +34,7 @@
"info": {"$ref": "container.json#/definitions/info"},
"description": {"$ref": "common.json#/definitions/description"}
},
"x-sdk-model": "collection",
"additionalProperties": false
},
"collection-input-with-contents":{
Expand All @@ -18,16 +44,18 @@
"label": {"$ref": "common.json#/definitions/label"},
"info": {"$ref": "container.json#/definitions/info"},
"description": {"$ref": "common.json#/definitions/description"},
"contents": { "type": "object" }
"contents": {"$ref": "#/definitions/collection-operation"}
},
"x-sdk-model": "collection",
"additionalProperties": false
},
"collection-new-output": {
"type": "object",
"properties": {
"_id": {"$ref":"common.json#/definitions/objectid"}
},
"required": ["_id"]
"required": ["_id"],
"x-sdk-return": "_id"
},
"collection-output":{
"type": "object",
Expand Down Expand Up @@ -56,6 +84,7 @@
"items":{"$ref":"analysis.json#/definitions/analysis-output"}
}
},
"x-sdk-model": "collection",
"additionalProperties":false
}
}
Expand Down
3 changes: 2 additions & 1 deletion swagger/schemas/definitions/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"_id": {
"type": "string"
}
}
},
"x-sdk-return": "_id"
}
}
}
Loading

0 comments on commit 86da184

Please sign in to comment.