Skip to content

Commit

Permalink
Merge pull request #7 from gotchazipc/master
Browse files Browse the repository at this point in the history
fixed copy & move api
  • Loading branch information
gotchazipc authored Jul 10, 2016
2 parents aae2ded + 0cb00c2 commit 172f350
Show file tree
Hide file tree
Showing 10 changed files with 137 additions and 169 deletions.
4 changes: 2 additions & 2 deletions README-API.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This SDK Contains automatically generated sources & documents with the [Swagger

- API version: 0.3.0
- Package version: 0.3.0
- Build date: 2016-07-08T19:42:15.316+09:00
- Build date: 2016-07-10T23:35:06.325+09:00
- Build package: class io.swagger.codegen.languages.JavascriptClientCodegen

## Getting Started
Expand Down Expand Up @@ -55,7 +55,7 @@ Class | Method | HTTP request | Description
*WebidaRestfulApi.WfsApi* | [**copy**](docs/WfsApi.md#copy) | **PUT** /wfs/{wfsId}/any/{wfsPath} |
*WebidaRestfulApi.WfsApi* | [**createDir**](docs/WfsApi.md#createDir) | **PUT** /wfs/{wfsId}/dir/{wfsPath} |
*WebidaRestfulApi.WfsApi* | [**dirTree**](docs/WfsApi.md#dirTree) | **GET** /wfs/{wfsId}/dir/{wfsPath} |
*WebidaRestfulApi.WfsApi* | [**move**](docs/WfsApi.md#move) | **POST** /wfs/{wfsId}/dir/{wfsPath} |
*WebidaRestfulApi.WfsApi* | [**move**](docs/WfsApi.md#move) | **POST** /wfs/{wfsId}/any/{wfsPath} |
*WebidaRestfulApi.WfsApi* | [**readFile**](docs/WfsApi.md#readFile) | **GET** /wfs/{wfsId}/file/{wfsPath} |
*WebidaRestfulApi.WfsApi* | [**remove**](docs/WfsApi.md#remove) | **DELETE** /wfs/{wfsId}/any/{wfsPath} |
*WebidaRestfulApi.WfsApi* | [**rename**](docs/WfsApi.md#rename) | **POST** /wfs/{wfsId}/file/{wfsPath} |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ For Windows, use bash from git-for-windows binary to run build.sh

### Editing swagger spec & templates

We recommend you to use swagger-editor[swagger-editor](https://github.com/swagger-api/swagger-editor) to edit swagger file & on-the-fly validation. Always be sure that swagger.yaml is validated before building. Or, swagger-codegen-cli will produce very weird errors, hard to find why & where. Do not edit swagger.json file directly, for it's generated from yaml file by build.sh. You may need to add some host, port information in api spec for on-the-fly testing with editor UI, but it's not recommended to publish your spec with 'fixed' api endpoint url, in the view point of devops.
We recommend you to use swagger-editor[swagger-editor](https://github.com/swagger-api/swagger-editor) to edit swagger file & on-the-fly validation. Always be sure that swagger.yaml is validated before building. Or, swagger-codegen-cli will produce some weird errors, hard to find why & where. Do not edit swagger.json file directly, for it's generated from yaml file by build.sh. You may need to add some host, port information in api spec for on-the-fly testing with editor UI, but it's not recommended to publish your spec with 'fixed' api endpoint url, in the view point of devops.

To change package.json generated, edit template files, especially package.mustache. You also need to change
build.sh to set codegen configurations. Since current template has some fixes on several issues, starting
Expand Down
2 changes: 1 addition & 1 deletion api-bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion api-bundle.js.map

Large diffs are not rendered by default.

132 changes: 55 additions & 77 deletions api-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,10 @@
} ],
"x-handler" : "handlers/wfs/stat.js"
},
"put" : {
"post" : {
"tags" : [ "wfs" ],
"description" : "Copy to given path. Works like cp -r command, with some funny options. That means,\nif destination is a directory, result will be put 'in' the directory with same base name\nto the source.\n\nIf removeExisting option is false, copying a directory onto a file will return error.\nOr, destination path will be 'clobbed' before copying file, regardless wheather the path\nis file or not.\n",
"operationId" : "copy",
"description" : "Moves source resource to given path. Unlike mv command, wfsPath always denotes an exact\npath of the resource to be created. So, moving a file to existing directory always\nreturns error and vice versa. (So, This API works like 'rename' rather than 'mv' command)\n\nLike copy(), this operation creates parent path of destination, and does not roll-back\nwhen operation failes.\n\nWhen destination path exists already,\n1) moving file to file : follows noOverwrite flag.\n2) moving file to dir : returns 409 error\n3) moving dir to file : returns 409 error\n4) moving dir to dir : merge srcPath/* to wfsPath, following noOverwite flag.\n",
"operationId" : "move",
"parameters" : [ {
"name" : "wfsId",
"in" : "path",
Expand All @@ -373,30 +373,73 @@
"required" : true,
"type" : "string"
}, {
"name" : "ensurePath",
"name" : "noOverwrite",
"in" : "query",
"description" : "Create a directory if wfsPath denotes unexisting path. Unlike 'ensure' parameter, this flag\ncreates entire path as a directory. If there's a existing file in the path, this flag will\nnot work and the operation will return error.\n\nWhile copying or moving, 'ensure' option can make same operation to have 2 possible results,\ndepending on the existence of wfsPath. (e.g. Moving to some/path from some/source\nwith ensure canm create some/source or some/path/source. With ensurePath option, the result\ncan be fixed to some/path/source) If client does now know the actual directory structure or\nhas false directory structure cache, that ambiguity can be a really painful bug.\n",
"description" : "does not overwrites any existing file while copying or moving",
"required" : false,
"type" : "boolean",
"default" : false
} ],
"responses" : {
"200" : {
"description" : "OK",
"schema" : {
"$ref" : "#/definitions/RestOK"
}
},
"default" : {
"description" : "Error",
"schema" : {
"$ref" : "#/definitions/RestError"
}
}
},
"security" : [ {
"webida-simple-auth" : [ ]
} ],
"x-handler" : "handlers/wfs/move.js"
},
"put" : {
"tags" : [ "wfs" ],
"description" : "Creates a copy of source to given path. Unlike cp command, wfsPath always denotes an exact\npath of the resource to be created. So, copying a file to directory always returns error\nand vice versa.\n\nthis operation creates the parents dir of destination path always, and does not\nroll-back the creation when operation failed. So, clients should roll-back if needed.\n\nWhen destination path exists already,\n1) copying file to file : follows noOverwrite flag. (does not return error)\n2) copying file to dir : returns 409 error\n3) copying dir to file : returns 409 error\n4) copying dir to dir : merge srcPath/* to wfsPath, following noOverwite flag.\n",
"operationId" : "copy",
"parameters" : [ {
"name" : "wfsId",
"in" : "path",
"description" : "webida file system id (same to workspace id) to access.",
"required" : true,
"type" : "string"
}, {
"name" : "wfsPath",
"in" : "path",
"description" : "webida file system path to access. without heading /. should be placed at the end of path arguments\n",
"required" : true,
"type" : "string",
"pattern" : ".*"
}, {
"name" : "srcPath",
"in" : "query",
"description" : "source data path of some operations, with have heading /",
"required" : true,
"type" : "string"
}, {
"name" : "removeExisting",
"name" : "noOverwrite",
"in" : "query",
"description" : "remove any existing file/dir before writing.",
"description" : "does not overwrites any existing file while copying or moving",
"required" : false,
"type" : "boolean",
"default" : false
}, {
"name" : "followSymbolicLinks",
"in" : "query",
"description" : "dereference symlinks or not",
"description" : "dereference symlinks in source.",
"required" : false,
"type" : "boolean",
"default" : false
}, {
"name" : "preserveTimestamps",
"in" : "query",
"description" : "to change default behavior, keep mtime/atime of source files in destination",
"description" : "keep mtime/atime of source file(s) in destination.",
"required" : false,
"type" : "boolean",
"default" : false
Expand Down Expand Up @@ -509,63 +552,6 @@
} ],
"x-handler" : "handlers/wfs/dirTree.js"
},
"post" : {
"tags" : [ "wfs" ],
"description" : "move file or directory to given path. works like mv -r command",
"operationId" : "move",
"parameters" : [ {
"name" : "wfsId",
"in" : "path",
"description" : "webida file system id (same to workspace id) to access.",
"required" : true,
"type" : "string"
}, {
"name" : "wfsPath",
"in" : "path",
"description" : "webida file system path to access. without heading /. should be placed at the end of path arguments\n",
"required" : true,
"type" : "string",
"pattern" : ".*"
}, {
"name" : "srcPath",
"in" : "query",
"description" : "source data path of some operations, with have heading /",
"required" : true,
"type" : "string"
}, {
"name" : "ensurePath",
"in" : "query",
"description" : "Create a directory if wfsPath denotes unexisting path. Unlike 'ensure' parameter, this flag\ncreates entire path as a directory. If there's a existing file in the path, this flag will\nnot work and the operation will return error.\n\nWhile copying or moving, 'ensure' option can make same operation to have 2 possible results,\ndepending on the existence of wfsPath. (e.g. Moving to some/path from some/source\nwith ensure canm create some/source or some/path/source. With ensurePath option, the result\ncan be fixed to some/path/source) If client does now know the actual directory structure or\nhas false directory structure cache, that ambiguity can be a really painful bug.\n",
"required" : false,
"type" : "boolean",
"default" : false
}, {
"name" : "removeExisting",
"in" : "query",
"description" : "remove any existing file/dir before writing.",
"required" : false,
"type" : "boolean",
"default" : false
} ],
"responses" : {
"200" : {
"description" : "OK",
"schema" : {
"$ref" : "#/definitions/RestOK"
}
},
"default" : {
"description" : "Error",
"schema" : {
"$ref" : "#/definitions/RestError"
}
}
},
"security" : [ {
"webida-simple-auth" : [ ]
} ],
"x-handler" : "handlers/wfs/move.js"
},
"put" : {
"tags" : [ "wfs" ],
"description" : "create a directory at the path. returns error when wfsPath exists and not empty\nthis API always creates parent directories if needed.\n",
Expand Down Expand Up @@ -1695,18 +1681,10 @@
"type" : "boolean",
"default" : false
},
"ensurePath" : {
"name" : "ensurePath",
"in" : "query",
"description" : "Create a directory if wfsPath denotes unexisting path. Unlike 'ensure' parameter, this flag\ncreates entire path as a directory. If there's a existing file in the path, this flag will\nnot work and the operation will return error.\n\nWhile copying or moving, 'ensure' option can make same operation to have 2 possible results,\ndepending on the existence of wfsPath. (e.g. Moving to some/path from some/source\nwith ensure canm create some/source or some/path/source. With ensurePath option, the result\ncan be fixed to some/path/source) If client does now know the actual directory structure or\nhas false directory structure cache, that ambiguity can be a really painful bug.\n",
"required" : false,
"type" : "boolean",
"default" : false
},
"removeExisting" : {
"name" : "removeExisting",
"noOverwrite" : {
"name" : "noOverwrite",
"in" : "query",
"description" : "remove any existing file/dir before writing.",
"description" : "does not overwrites any existing file while copying or moving",
"required" : false,
"type" : "boolean",
"default" : false
Expand Down
112 changes: 55 additions & 57 deletions api-spec/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,13 @@ paths:
# /file/{wfsPath} file CRUD C,U is PUT, not POST
# GET - read file
# PUT - write file
# POST?{src} - rename to (supports dir too)
# /dir/{wfsPath} directory CRUD
# GET - list (read) dir
# PUT - create (can be expanded to import, later)
# POST?{src} - move to dir (supports file too)
# /any/{wfsPath}
# GET?{ignoreError} - stat / exists
# PUT?{src} - copy
# POST?{src} - move
# DELETE - delete
# /ops/search/{wfsPath} for search (GET) and replace (POST)
# /ops/replace?{wfsPath} for search (GET) and replace (POST)
Expand Down Expand Up @@ -316,31 +315,6 @@ paths:
schema:
$ref: "#/definitions/RestError"

# move
post:
x-handler: handlers/wfs/move.js
tags: ["wfs"]
description: move file or directory to given path. works like mv -r command
operationId: move
security:
- webida-simple-auth: []
parameters:
- $ref: "#/parameters/wfsId"
- $ref: "#/parameters/wfsPath"
- $ref: "#/parameters/srcPath"
- $ref: "#/parameters/ensurePath"
- $ref: "#/parameters/removeExisting"
responses:
"200":
description: OK
schema:
$ref: "#/definitions/RestOK"
default:
description: Error
schema:
$ref: "#/definitions/RestError"


/wfs/{wfsId}/any/{wfsPath}:
# stat
get:
Expand Down Expand Up @@ -386,31 +360,36 @@ paths:
x-handler: handlers/wfs/copy.js
tags: ["wfs"]
description: |
Copy to given path. Works like cp -r command, with some funny options. That means,
if destination is a directory, result will be put 'in' the directory with same base name
to the source.
Creates a copy of source to given path. Unlike cp command, wfsPath always denotes an exact
path of the resource to be created. So, copying a file to directory always returns error
and vice versa.
this operation creates the parents dir of destination path always, and does not
roll-back the creation when operation failed. So, clients should roll-back if needed.
When destination path exists already,
1) copying file to file : follows noOverwrite flag. (does not return error)
2) copying file to dir : returns 409 error
3) copying dir to file : returns 409 error
4) copying dir to dir : merge srcPath/* to wfsPath, following noOverwite flag.
If removeExisting option is false, copying a directory onto a file will return error.
Or, destination path will be 'clobbed' before copying file, regardless wheather the path
is file or not.
operationId: copy
security:
- webida-simple-auth: []
parameters:
- $ref: "#/parameters/wfsId"
- $ref: "#/parameters/wfsPath"
- $ref: "#/parameters/srcPath"
- $ref: "#/parameters/ensurePath"
- $ref: "#/parameters/removeExisting"
- $ref: "#/parameters/noOverwrite"
- name: followSymbolicLinks
in: query
description: dereference symlinks or not
description: dereference symlinks in source.
required: false
type: boolean
default: false
- name: preserveTimestamps
in: query
description: to change default behavior, keep mtime/atime of source files in destination
description: keep mtime/atime of source file(s) in destination.
required: false
type: boolean
default: false
Expand All @@ -424,6 +403,42 @@ paths:
schema:
$ref: "#/definitions/RestError"

# move
post:
x-handler: handlers/wfs/move.js
tags: ["wfs"]
description: |
Moves source resource to given path. Unlike mv command, wfsPath always denotes an exact
path of the resource to be created. So, moving a file to existing directory always
returns error and vice versa. (So, This API works like 'rename' rather than 'mv' command)
Like copy(), this operation creates parent path of destination, and does not roll-back
when operation failes.
When destination path exists already,
1) moving file to file : follows noOverwrite flag.
2) moving file to dir : returns 409 error
3) moving dir to file : returns 409 error
4) moving dir to dir : merge srcPath/* to wfsPath, following noOverwite flag.
operationId: move
security:
- webida-simple-auth: []
parameters:
- $ref: "#/parameters/wfsId"
- $ref: "#/parameters/wfsPath"
- $ref: "#/parameters/srcPath"
- $ref: "#/parameters/noOverwrite"
responses:
"200":
description: OK
schema:
$ref: "#/definitions/RestOK"
default:
description: Error
schema:
$ref: "#/definitions/RestError"


# remove / delete
delete:
Expand Down Expand Up @@ -1021,27 +1036,10 @@ parameters:
required: false
default: false

ensurePath:
name: ensurePath
in: query
description: |
Create a directory if wfsPath denotes unexisting path. Unlike 'ensure' parameter, this flag
creates entire path as a directory. If there's a existing file in the path, this flag will
not work and the operation will return error.
While copying or moving, 'ensure' option can make same operation to have 2 possible results,
depending on the existence of wfsPath. (e.g. Moving to some/path from some/source
with ensure canm create some/source or some/path/source. With ensurePath option, the result
can be fixed to some/path/source) If client does now know the actual directory structure or
has false directory structure cache, that ambiguity can be a really painful bug.
type: boolean
required: false
default: false

removeExisting:
name: removeExisting
noOverwrite:
name: noOverwrite
in: query
description: remove any existing file/dir before writing.
description: does not overwrites any existing file while copying or moving
required: false
type: boolean
default: false
Expand Down
2 changes: 1 addition & 1 deletion builder/templates/package.mustache
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "webida-restful-api",
"version": "0.3.0",
"version": "0.4.0",
"description": "Webida Restful API Spec & generated clients",
"license": "Apache-2.0",
"main": "{{sourceFolder}}{{#invokerPackage}}/{{invokerPackage}}{{/invokerPackage}}/index.js",
Expand Down
Loading

0 comments on commit 172f350

Please sign in to comment.