Skip to content

Commit 172f350

Browse files
authored
Merge pull request #7 from gotchazipc/master
fixed copy & move api
2 parents aae2ded + 0cb00c2 commit 172f350

File tree

10 files changed

+137
-169
lines changed

10 files changed

+137
-169
lines changed

README-API.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This SDK Contains automatically generated sources & documents with the [Swagger
44

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

1010
## Getting Started
@@ -55,7 +55,7 @@ Class | Method | HTTP request | Description
5555
*WebidaRestfulApi.WfsApi* | [**copy**](docs/WfsApi.md#copy) | **PUT** /wfs/{wfsId}/any/{wfsPath} |
5656
*WebidaRestfulApi.WfsApi* | [**createDir**](docs/WfsApi.md#createDir) | **PUT** /wfs/{wfsId}/dir/{wfsPath} |
5757
*WebidaRestfulApi.WfsApi* | [**dirTree**](docs/WfsApi.md#dirTree) | **GET** /wfs/{wfsId}/dir/{wfsPath} |
58-
*WebidaRestfulApi.WfsApi* | [**move**](docs/WfsApi.md#move) | **POST** /wfs/{wfsId}/dir/{wfsPath} |
58+
*WebidaRestfulApi.WfsApi* | [**move**](docs/WfsApi.md#move) | **POST** /wfs/{wfsId}/any/{wfsPath} |
5959
*WebidaRestfulApi.WfsApi* | [**readFile**](docs/WfsApi.md#readFile) | **GET** /wfs/{wfsId}/file/{wfsPath} |
6060
*WebidaRestfulApi.WfsApi* | [**remove**](docs/WfsApi.md#remove) | **DELETE** /wfs/{wfsId}/any/{wfsPath} |
6161
*WebidaRestfulApi.WfsApi* | [**rename**](docs/WfsApi.md#rename) | **POST** /wfs/{wfsId}/file/{wfsPath} |

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ For Windows, use bash from git-for-windows binary to run build.sh
5656

5757
### Editing swagger spec & templates
5858

59-
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.
59+
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.
6060

6161
To change package.json generated, edit template files, especially package.mustache. You also need to change
6262
build.sh to set codegen configurations. Since current template has some fixes on several issues, starting

api-bundle.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api-bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api-spec/swagger.json

Lines changed: 55 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -349,10 +349,10 @@
349349
} ],
350350
"x-handler" : "handlers/wfs/stat.js"
351351
},
352-
"put" : {
352+
"post" : {
353353
"tags" : [ "wfs" ],
354-
"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",
355-
"operationId" : "copy",
354+
"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",
355+
"operationId" : "move",
356356
"parameters" : [ {
357357
"name" : "wfsId",
358358
"in" : "path",
@@ -373,30 +373,73 @@
373373
"required" : true,
374374
"type" : "string"
375375
}, {
376-
"name" : "ensurePath",
376+
"name" : "noOverwrite",
377377
"in" : "query",
378-
"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",
378+
"description" : "does not overwrites any existing file while copying or moving",
379379
"required" : false,
380380
"type" : "boolean",
381381
"default" : false
382+
} ],
383+
"responses" : {
384+
"200" : {
385+
"description" : "OK",
386+
"schema" : {
387+
"$ref" : "#/definitions/RestOK"
388+
}
389+
},
390+
"default" : {
391+
"description" : "Error",
392+
"schema" : {
393+
"$ref" : "#/definitions/RestError"
394+
}
395+
}
396+
},
397+
"security" : [ {
398+
"webida-simple-auth" : [ ]
399+
} ],
400+
"x-handler" : "handlers/wfs/move.js"
401+
},
402+
"put" : {
403+
"tags" : [ "wfs" ],
404+
"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",
405+
"operationId" : "copy",
406+
"parameters" : [ {
407+
"name" : "wfsId",
408+
"in" : "path",
409+
"description" : "webida file system id (same to workspace id) to access.",
410+
"required" : true,
411+
"type" : "string"
412+
}, {
413+
"name" : "wfsPath",
414+
"in" : "path",
415+
"description" : "webida file system path to access. without heading /. should be placed at the end of path arguments\n",
416+
"required" : true,
417+
"type" : "string",
418+
"pattern" : ".*"
419+
}, {
420+
"name" : "srcPath",
421+
"in" : "query",
422+
"description" : "source data path of some operations, with have heading /",
423+
"required" : true,
424+
"type" : "string"
382425
}, {
383-
"name" : "removeExisting",
426+
"name" : "noOverwrite",
384427
"in" : "query",
385-
"description" : "remove any existing file/dir before writing.",
428+
"description" : "does not overwrites any existing file while copying or moving",
386429
"required" : false,
387430
"type" : "boolean",
388431
"default" : false
389432
}, {
390433
"name" : "followSymbolicLinks",
391434
"in" : "query",
392-
"description" : "dereference symlinks or not",
435+
"description" : "dereference symlinks in source.",
393436
"required" : false,
394437
"type" : "boolean",
395438
"default" : false
396439
}, {
397440
"name" : "preserveTimestamps",
398441
"in" : "query",
399-
"description" : "to change default behavior, keep mtime/atime of source files in destination",
442+
"description" : "keep mtime/atime of source file(s) in destination.",
400443
"required" : false,
401444
"type" : "boolean",
402445
"default" : false
@@ -509,63 +552,6 @@
509552
} ],
510553
"x-handler" : "handlers/wfs/dirTree.js"
511554
},
512-
"post" : {
513-
"tags" : [ "wfs" ],
514-
"description" : "move file or directory to given path. works like mv -r command",
515-
"operationId" : "move",
516-
"parameters" : [ {
517-
"name" : "wfsId",
518-
"in" : "path",
519-
"description" : "webida file system id (same to workspace id) to access.",
520-
"required" : true,
521-
"type" : "string"
522-
}, {
523-
"name" : "wfsPath",
524-
"in" : "path",
525-
"description" : "webida file system path to access. without heading /. should be placed at the end of path arguments\n",
526-
"required" : true,
527-
"type" : "string",
528-
"pattern" : ".*"
529-
}, {
530-
"name" : "srcPath",
531-
"in" : "query",
532-
"description" : "source data path of some operations, with have heading /",
533-
"required" : true,
534-
"type" : "string"
535-
}, {
536-
"name" : "ensurePath",
537-
"in" : "query",
538-
"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",
539-
"required" : false,
540-
"type" : "boolean",
541-
"default" : false
542-
}, {
543-
"name" : "removeExisting",
544-
"in" : "query",
545-
"description" : "remove any existing file/dir before writing.",
546-
"required" : false,
547-
"type" : "boolean",
548-
"default" : false
549-
} ],
550-
"responses" : {
551-
"200" : {
552-
"description" : "OK",
553-
"schema" : {
554-
"$ref" : "#/definitions/RestOK"
555-
}
556-
},
557-
"default" : {
558-
"description" : "Error",
559-
"schema" : {
560-
"$ref" : "#/definitions/RestError"
561-
}
562-
}
563-
},
564-
"security" : [ {
565-
"webida-simple-auth" : [ ]
566-
} ],
567-
"x-handler" : "handlers/wfs/move.js"
568-
},
569555
"put" : {
570556
"tags" : [ "wfs" ],
571557
"description" : "create a directory at the path. returns error when wfsPath exists and not empty\nthis API always creates parent directories if needed.\n",
@@ -1695,18 +1681,10 @@
16951681
"type" : "boolean",
16961682
"default" : false
16971683
},
1698-
"ensurePath" : {
1699-
"name" : "ensurePath",
1700-
"in" : "query",
1701-
"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",
1702-
"required" : false,
1703-
"type" : "boolean",
1704-
"default" : false
1705-
},
1706-
"removeExisting" : {
1707-
"name" : "removeExisting",
1684+
"noOverwrite" : {
1685+
"name" : "noOverwrite",
17081686
"in" : "query",
1709-
"description" : "remove any existing file/dir before writing.",
1687+
"description" : "does not overwrites any existing file while copying or moving",
17101688
"required" : false,
17111689
"type" : "boolean",
17121690
"default" : false

api-spec/swagger.yaml

Lines changed: 55 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,13 @@ paths:
154154
# /file/{wfsPath} file CRUD C,U is PUT, not POST
155155
# GET - read file
156156
# PUT - write file
157-
# POST?{src} - rename to (supports dir too)
158157
# /dir/{wfsPath} directory CRUD
159158
# GET - list (read) dir
160159
# PUT - create (can be expanded to import, later)
161-
# POST?{src} - move to dir (supports file too)
162160
# /any/{wfsPath}
163161
# GET?{ignoreError} - stat / exists
164162
# PUT?{src} - copy
163+
# POST?{src} - move
165164
# DELETE - delete
166165
# /ops/search/{wfsPath} for search (GET) and replace (POST)
167166
# /ops/replace?{wfsPath} for search (GET) and replace (POST)
@@ -316,31 +315,6 @@ paths:
316315
schema:
317316
$ref: "#/definitions/RestError"
318317

319-
# move
320-
post:
321-
x-handler: handlers/wfs/move.js
322-
tags: ["wfs"]
323-
description: move file or directory to given path. works like mv -r command
324-
operationId: move
325-
security:
326-
- webida-simple-auth: []
327-
parameters:
328-
- $ref: "#/parameters/wfsId"
329-
- $ref: "#/parameters/wfsPath"
330-
- $ref: "#/parameters/srcPath"
331-
- $ref: "#/parameters/ensurePath"
332-
- $ref: "#/parameters/removeExisting"
333-
responses:
334-
"200":
335-
description: OK
336-
schema:
337-
$ref: "#/definitions/RestOK"
338-
default:
339-
description: Error
340-
schema:
341-
$ref: "#/definitions/RestError"
342-
343-
344318
/wfs/{wfsId}/any/{wfsPath}:
345319
# stat
346320
get:
@@ -386,31 +360,36 @@ paths:
386360
x-handler: handlers/wfs/copy.js
387361
tags: ["wfs"]
388362
description: |
389-
Copy to given path. Works like cp -r command, with some funny options. That means,
390-
if destination is a directory, result will be put 'in' the directory with same base name
391-
to the source.
363+
Creates a copy of source to given path. Unlike cp command, wfsPath always denotes an exact
364+
path of the resource to be created. So, copying a file to directory always returns error
365+
and vice versa.
366+
367+
this operation creates the parents dir of destination path always, and does not
368+
roll-back the creation when operation failed. So, clients should roll-back if needed.
369+
370+
When destination path exists already,
371+
1) copying file to file : follows noOverwrite flag. (does not return error)
372+
2) copying file to dir : returns 409 error
373+
3) copying dir to file : returns 409 error
374+
4) copying dir to dir : merge srcPath/* to wfsPath, following noOverwite flag.
392375
393-
If removeExisting option is false, copying a directory onto a file will return error.
394-
Or, destination path will be 'clobbed' before copying file, regardless wheather the path
395-
is file or not.
396376
operationId: copy
397377
security:
398378
- webida-simple-auth: []
399379
parameters:
400380
- $ref: "#/parameters/wfsId"
401381
- $ref: "#/parameters/wfsPath"
402382
- $ref: "#/parameters/srcPath"
403-
- $ref: "#/parameters/ensurePath"
404-
- $ref: "#/parameters/removeExisting"
383+
- $ref: "#/parameters/noOverwrite"
405384
- name: followSymbolicLinks
406385
in: query
407-
description: dereference symlinks or not
386+
description: dereference symlinks in source.
408387
required: false
409388
type: boolean
410389
default: false
411390
- name: preserveTimestamps
412391
in: query
413-
description: to change default behavior, keep mtime/atime of source files in destination
392+
description: keep mtime/atime of source file(s) in destination.
414393
required: false
415394
type: boolean
416395
default: false
@@ -424,6 +403,42 @@ paths:
424403
schema:
425404
$ref: "#/definitions/RestError"
426405

406+
# move
407+
post:
408+
x-handler: handlers/wfs/move.js
409+
tags: ["wfs"]
410+
description: |
411+
Moves source resource to given path. Unlike mv command, wfsPath always denotes an exact
412+
path of the resource to be created. So, moving a file to existing directory always
413+
returns error and vice versa. (So, This API works like 'rename' rather than 'mv' command)
414+
415+
Like copy(), this operation creates parent path of destination, and does not roll-back
416+
when operation failes.
417+
418+
When destination path exists already,
419+
1) moving file to file : follows noOverwrite flag.
420+
2) moving file to dir : returns 409 error
421+
3) moving dir to file : returns 409 error
422+
4) moving dir to dir : merge srcPath/* to wfsPath, following noOverwite flag.
423+
424+
operationId: move
425+
security:
426+
- webida-simple-auth: []
427+
parameters:
428+
- $ref: "#/parameters/wfsId"
429+
- $ref: "#/parameters/wfsPath"
430+
- $ref: "#/parameters/srcPath"
431+
- $ref: "#/parameters/noOverwrite"
432+
responses:
433+
"200":
434+
description: OK
435+
schema:
436+
$ref: "#/definitions/RestOK"
437+
default:
438+
description: Error
439+
schema:
440+
$ref: "#/definitions/RestError"
441+
427442

428443
# remove / delete
429444
delete:
@@ -1021,27 +1036,10 @@ parameters:
10211036
required: false
10221037
default: false
10231038

1024-
ensurePath:
1025-
name: ensurePath
1026-
in: query
1027-
description: |
1028-
Create a directory if wfsPath denotes unexisting path. Unlike 'ensure' parameter, this flag
1029-
creates entire path as a directory. If there's a existing file in the path, this flag will
1030-
not work and the operation will return error.
1031-
1032-
While copying or moving, 'ensure' option can make same operation to have 2 possible results,
1033-
depending on the existence of wfsPath. (e.g. Moving to some/path from some/source
1034-
with ensure canm create some/source or some/path/source. With ensurePath option, the result
1035-
can be fixed to some/path/source) If client does now know the actual directory structure or
1036-
has false directory structure cache, that ambiguity can be a really painful bug.
1037-
type: boolean
1038-
required: false
1039-
default: false
1040-
1041-
removeExisting:
1042-
name: removeExisting
1039+
noOverwrite:
1040+
name: noOverwrite
10431041
in: query
1044-
description: remove any existing file/dir before writing.
1042+
description: does not overwrites any existing file while copying or moving
10451043
required: false
10461044
type: boolean
10471045
default: false

builder/templates/package.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "webida-restful-api",
3-
"version": "0.3.0",
3+
"version": "0.4.0",
44
"description": "Webida Restful API Spec & generated clients",
55
"license": "Apache-2.0",
66
"main": "{{sourceFolder}}{{#invokerPackage}}/{{invokerPackage}}{{/invokerPackage}}/index.js",

0 commit comments

Comments
 (0)