Skip to content

Commit

Permalink
Rest API Swagger doc QA - importer
Browse files Browse the repository at this point in the history
  • Loading branch information
tbarsballe authored and jodygarnett committed Oct 5, 2017
1 parent a07699b commit e9edc94
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 34 deletions.
13 changes: 11 additions & 2 deletions doc/en/api/1.0.0/importer.yaml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ paths:
- application/json - application/json
- text/html - text/html
parameters: parameters:
- $ref: "#/parameters/ExpandParameter" - $ref: "#/parameters/ExpandParameterNone"
responses: responses:
200: 200:
description: OK description: OK
Expand Down Expand Up @@ -149,11 +149,20 @@ parameters:
in: query in: query
type: boolean type: boolean
required: false required: false
#This parameter is handled at the converter level, and applies to all endpoints which return content. Default is 1 (self), unless otherwise specified in the controller method.
ExpandParameter: ExpandParameter:
name: expand name: expand
type: string type: string
in: query in: query
description: 'What level to expand the response object to. Can be "self" (expand only the response object and its immediate children), "all" (expand all children), "none" (don''t include any children), or a nonnegative integer, indicating the depth of children to expand to. Defaults to "self" or "none", depending on the request.' description: 'What level to expand the response object to. Can be "self" (expand only the response object and its immediate children), "all" (expand all children), "none" (don''t include any children), or a nonnegative integer, indicating the depth of children to expand to.'
default: self
required: false
ExpandParameterNone:
name: expand
type: string
in: query
description: 'What level to expand the response object to. Can be "self" (expand only the response object and its immediate children), "all" (expand all children), "none" (don''t include any children), or a nonnegative integer, indicating the depth of children to expand to.'
default: none
required: false required: false
ContextParameter: ContextParameter:
name: importBody name: importBody
Expand Down
7 changes: 4 additions & 3 deletions doc/en/api/1.0.0/importerData.yaml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ paths:
operationId: deleteImportDataFile operationId: deleteImportDataFile
summary: Remove a specific file with id {filename} from the import with id {importId}. Only applies to file/directory imports. summary: Remove a specific file with id {filename} from the import with id {importId}. Only applies to file/directory imports.
responses: responses:
202: 204:
description: No Content description: No Content
/imports/{importId}/tasks/{taskId}/data/files: /imports/{importId}/tasks/{taskId}/data/files:
get: get:
Expand Down Expand Up @@ -112,15 +112,16 @@ paths:
operationId: deleteTaskDataFile operationId: deleteTaskDataFile
summary: Remove a specific file with id {filename} from the task with id {taskId} within import with id {importId}. Only applies to file/directory imports. summary: Remove a specific file with id {filename} from the task with id {taskId} within import with id {importId}. Only applies to file/directory imports.
responses: responses:
202: 204:
description: No Content description: No Content


parameters: parameters:
ExpandParameter: ExpandParameter:
name: expand name: expand
type: string type: string
in: query in: query
description: 'What level to expand the response object to. Can be "self" (expand only the response object and its immediate children), "all" (expand all children), "none" (don''t include any children), or a nonnegative integer, indicating the depth of children to expand to. Defaults to "self" or "none", depending on the request.' description: 'What level to expand the response object to. Can be "self" (expand only the response object and its immediate children), "all" (expand all children), "none" (don''t include any children), or a nonnegative integer, indicating the depth of children to expand to.'
default: self
required: false required: false
ImportId: ImportId:
name: importId name: importId
Expand Down
35 changes: 26 additions & 9 deletions doc/en/api/1.0.0/importerTasks.yaml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ paths:
- text/html - text/html
parameters: parameters:
- $ref: "#/parameters/ImportId" - $ref: "#/parameters/ImportId"
- $ref: "#/parameters/ExpandParameter" - $ref: "#/parameters/ExpandParameterNone"
responses: responses:
200: 200:
description: OK description: OK
Expand Down Expand Up @@ -46,7 +46,8 @@ paths:
- application/json - application/json
- text/htm - text/htm
parameters: parameters:
- $ref: "#/parameters/ExpandParameter" - $ref: "#/parameters/ImportId"
- $ref: "#/parameters/ExpandParameterNone"
- $ref: "#/parameters/TaskParameter" - $ref: "#/parameters/TaskParameter"
responses: responses:
201: 201:
Expand Down Expand Up @@ -121,12 +122,18 @@ paths:
- $ref: "#/parameters/ImportId" - $ref: "#/parameters/ImportId"
- $ref: "#/parameters/TaskId" - $ref: "#/parameters/TaskId"
- $ref: "#/parameters/TaskParameter" - $ref: "#/parameters/TaskParameter"
- $ref: "#/parameters/ExpandParameter"
responses: responses:
200: 200:
description: OK description: OK
schema:
$ref: "#/definitions/Task"
delete: delete:
operationId: deleteTask operationId: deleteTask
summary: Remove task with id {taskId} within import with id {importId} summary: Remove task with id {taskId} within import with id {importId}
parameters:
- $ref: "#/parameters/ImportId"
- $ref: "#/parameters/TaskId"
responses: responses:
200: 200:
description: OK description: OK
Expand All @@ -141,6 +148,13 @@ paths:
- $ref: "#/parameters/ImportId" - $ref: "#/parameters/ImportId"
- $ref: "#/parameters/Filename" - $ref: "#/parameters/Filename"
- $ref: "#/parameters/ExpandParameter" - $ref: "#/parameters/ExpandParameter"
- name: fileBody
in: body
required: true
description: The file contents to upload.
schema:
type: string
format: binary
responses: responses:
201: 201:
description: Created description: Created
Expand Down Expand Up @@ -183,9 +197,6 @@ paths:
consumes: consumes:
- application/json - application/json
- text/json - text/json
produces:
- application/json
- text/html
parameters: parameters:
- $ref: "#/parameters/ImportId" - $ref: "#/parameters/ImportId"
- $ref: "#/parameters/TaskId" - $ref: "#/parameters/TaskId"
Expand Down Expand Up @@ -234,8 +245,14 @@ parameters:
name: expand name: expand
type: string type: string
in: query in: query
description: 'What level to expand the response object to. Can be "self" (expand only the response object and its immediate children), "all" (expand all children), "none" (don''t include any children), or a nonnegative integer, indicating the depth of children to expand to. Defaults to "self" or "none", depending on the request.' description: 'What level to expand the response object to. Can be "self" (expand only the response object and its immediate children), "all" (expand all children), "none" (don''t include any children), or a nonnegative integer, indicating the depth of children to expand to.'
required: false default: self
ExpandParameterNone:
name: expand
type: string
in: query
description: 'What level to expand the response object to. Can be "self" (expand only the response object and its immediate children), "all" (expand all children), "none" (don''t include any children), or a nonnegative integer, indicating the depth of children to expand to.'
default: none
ImportId: ImportId:
name: importId name: importId
in: path in: path
Expand Down Expand Up @@ -267,14 +284,14 @@ parameters:
in: body in: body
required: true required: true
schema: schema:
$ref: "#/definitions/Task" $ref: "#/definitions/Store"
LayerParameter: LayerParameter:
name: layerBody name: layerBody
description: The layer to modify description: The layer to modify
in: body in: body
required: true required: true
schema: schema:
$ref: "#/definitions/Task" $ref: "#/definitions/Layer"


definitions: definitions:
Progress: Progress:
Expand Down
32 changes: 20 additions & 12 deletions doc/en/api/1.0.0/importerTransforms.yaml
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
swagger: '2.0' swagger: '2.0'
info: info:
version: 1.0.0 version: 1.0.0
title: GeoServer Importer Extension - Main title: GeoServer Importer Extension - Transforms
description: The Importer extension gives a GeoServer administrator an alternate, more-streamlined method for uploading and configuring new layers. The main endpoint manages individual import jobs. The importer extension is an optional install and may not be available on all deployments of GeoServer description: The Importer extension gives a GeoServer administrator an alternate, more-streamlined method for uploading and configuring new layers. The transforms endpoint manages data transforms applied to sindividual import jobs. The importer extension is an optional install and may not be available on all deployments of GeoServer


paths: paths:
/imports/{importId}/tasks/{taskId}/transforms: /imports/{importId}/tasks/{taskId}/transforms:
Expand All @@ -16,7 +16,7 @@ paths:
- text/html - text/html
parameters: parameters:
- $ref: "#/parameters/ImportId" - $ref: "#/parameters/ImportId"
- $ref: "#/parameters/TaskId" - $ref: "#/parameters/TaskId"
- $ref: "#/parameters/ExpandParameter" - $ref: "#/parameters/ExpandParameter"
responses: responses:
200: 200:
Expand Down Expand Up @@ -48,10 +48,9 @@ paths:
consumes: consumes:
- application/json - application/json
- text/json - text/json
produces:
- application/json
- text/html
parameters: parameters:
- $ref: "#/parameters/ImportId"
- $ref: "#/parameters/TaskId"
- $ref: "#/parameters/ExpandParameter" - $ref: "#/parameters/ExpandParameter"
- $ref: "#/parameters/TransformParameter" - $ref: "#/parameters/TransformParameter"
responses: responses:
Expand All @@ -72,12 +71,8 @@ paths:
parameters: parameters:
- $ref: "#/parameters/ImportId" - $ref: "#/parameters/ImportId"
- $ref: "#/parameters/TaskId" - $ref: "#/parameters/TaskId"
- $ref: "#/parameters/TransformId"
- $ref: "#/parameters/ExpandParameter" - $ref: "#/parameters/ExpandParameter"
- name: transformId
type: string
required: true
in: path
description: The transform ID
responses: responses:
200: 200:
description: OK description: OK
Expand All @@ -94,6 +89,9 @@ paths:
- application/json - application/json
- text/html - text/html
parameters: parameters:
- $ref: "#/parameters/ImportId"
- $ref: "#/parameters/TaskId"
- $ref: "#/parameters/TransformId"
- $ref: "#/parameters/ExpandParameter" - $ref: "#/parameters/ExpandParameter"
- $ref: "#/parameters/TransformParameter" - $ref: "#/parameters/TransformParameter"
responses: responses:
Expand All @@ -105,6 +103,10 @@ paths:
operationId: deleteTransform operationId: deleteTransform
summary: Removes the transformation summary: Removes the transformation
description: Removes the transformation identified by {transformId} inside a task with id {taskId} within import with id {importId} description: Removes the transformation identified by {transformId} inside a task with id {taskId} within import with id {importId}
parameters:
- $ref: "#/parameters/ImportId"
- $ref: "#/parameters/TaskId"
- $ref: "#/parameters/TransformId"
responses: responses:
200: 200:
description: OK description: OK
Expand All @@ -120,7 +122,7 @@ parameters:
name: transformBody name: transformBody
description: The transform to add. description: The transform to add.
in: body in: body
required: true required: true
schema: schema:
$ref: "#/definitions/Transform" $ref: "#/definitions/Transform"
ImportId: ImportId:
Expand All @@ -134,6 +136,12 @@ parameters:
in: path in: path
description: The ID of the task description: The ID of the task
required: true required: true
type: string
TransformId:
name: transformId
in: path
description: The ID of the transform
required: true
type: string type: string


definitions: definitions:
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public ImportWrapper getImports(@RequestParam(required=false) String expand) {
// this means a specific lookup failed // this means a specific lookup failed
throw new RestException("Failed to find import context", HttpStatus.NOT_FOUND); throw new RestException("Failed to find import context", HttpStatus.NOT_FOUND);
} else { } else {
//For ImportContext, the expand parameter is handled at the converter level. Here, we are listing contexts, and use a different (more succinct) default
return (writer, builder, converter) -> converter.contexts(builder,(Iterator<ImportContext>)lookupContext, converter.expand(expand, 0)); return (writer, builder, converter) -> converter.contexts(builder,(Iterator<ImportContext>)lookupContext, converter.expand(expand, 0));
} }
} }
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -157,20 +157,24 @@ PutIgnoringExtensionContentNegotiationStrategy importTaskPutContentNegotiationSt
Arrays.asList(MediaType.APPLICATION_JSON, MediaType.TEXT_HTML)); Arrays.asList(MediaType.APPLICATION_JSON, MediaType.TEXT_HTML));
} }
} }

/**
* Uploads a file as a new import task.
*
* @param id The import id
* @param filename The destination name of the file
*/
@PutMapping(path = "/{taskId:.+}") @PutMapping(path = "/{taskId:.+}")
public Object taskPutFile( public Object taskPutFile(
@PathVariable Long id, @PathVariable Long id,
@PathVariable Object taskId, @PathVariable(name="taskId") Object filename,
@RequestParam(required=false) String expand, @RequestParam(required=false) String expand,
HttpServletRequest request, HttpServletResponse response) { HttpServletRequest request, HttpServletResponse response) {


ImportContext context = context(id); ImportContext context = context(id);
//TODO: Task id is the file name here. This functionality is completely undocumented return acceptData(handleFileUpload(context, filename, request), context, response, expand);
return acceptData(handleFileUpload(context, taskId, request), context, response, expand);
} }




@PutMapping(path = "/{taskId}/target") @PutMapping(path = "/{taskId}/target")
@ResponseStatus(HttpStatus.NO_CONTENT) @ResponseStatus(HttpStatus.NO_CONTENT)
public void targetPut( public void targetPut(
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ protected ImportTransformController(Importer importer) {
public ResponseEntity postTransform( public ResponseEntity postTransform(
@PathVariable Long importId, @PathVariable Long importId,
@PathVariable Integer taskId, @PathVariable Integer taskId,
@RequestParam(value = "expand", required = false) String expand,
@RequestBody ImportTransform importTransform, @RequestBody ImportTransform importTransform,
UriComponentsBuilder builder) { UriComponentsBuilder builder) {


Expand Down Expand Up @@ -104,8 +103,7 @@ public ImportWrapper putTransform(
public ResponseEntity deleteTransform( public ResponseEntity deleteTransform(
@PathVariable Long importId, @PathVariable Long importId,
@PathVariable Integer taskId, @PathVariable Integer taskId,
@PathVariable Integer transformId, @PathVariable Integer transformId) {
@RequestParam(value = "expand", required = false) String expand) {


ImportTask task = task(importId, taskId); ImportTask task = task(importId, taskId);
ImportTransform tx = transform(importId, taskId, transformId); ImportTransform tx = transform(importId, taskId, transformId);
Expand Down

0 comments on commit e9edc94

Please sign in to comment.