Skip to content

Commit 6f7a4a8

Browse files
authored
Merge pull request #42 from dschmidt/feat/create-folder
feat(spec): driveItem creation under drives/items/children + recursive paths
2 parents 9049451 + 6f12841 commit 6f7a4a8

1 file changed

Lines changed: 126 additions & 3 deletions

File tree

api/openapi-spec/v1.0.yaml

Lines changed: 126 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,23 @@ paths:
468468
post:
469469
tags:
470470
- drives.root
471-
summary: Create a drive item
471+
summary: Create a new DriveItem at the drive root
472472
operationId: CreateDriveItem
473473
description: |
474-
You can use the root childrens endpoint to mount a remoteItem in the share jail. The `@client.synchronize` property of the `driveItem` in the [sharedWithMe](#/me.drive/ListSharedWithMe) endpoint will change to true.
474+
Create a new folder or DriveItem in a Drive with the drive root as the parent.
475+
476+
Modeled on the MS Graph create driveItem endpoint
477+
(https://learn.microsoft.com/en-us/graph/api/driveitem-post-children).
478+
479+
The request body must specify exactly one of `folder` (set to `{}` to create a folder), `file` (to create a file item), or `remoteItem` (to mount a shared item; see [sharedWithMe](#/me.drive/ListSharedWithMe) for obtaining the source `remoteItem.id`). Requests with none of these, or with more than one, return 400. Mounting a share changes the `@client.synchronize` property of the `driveItem` in [sharedWithMe](#/me.drive/ListSharedWithMe) to true.
480+
481+
The `@libre.graph.conflictBehavior` query parameter controls what happens if a child with the same name already exists.
482+
483+
This endpoint also accepts the MS Graph colon-syntax URL form:
484+
485+
POST /v1beta1/drives/{drive-id}/root:/{path}:/children
486+
487+
OpenAPI cannot express the colon-delimited path segment, so this URL form is not represented as a separate operation in this specification. The server still accepts it, resolves `:/{path}:` as the parent of the new item, and applies `@libre.graph.missingParentsBehavior` to decide whether to create missing intermediate folders.
475488
parameters:
476489
- name: drive-id
477490
in: path
@@ -481,13 +494,41 @@ paths:
481494
type: string
482495
example: a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668
483496
x-ms-docs-key-type: drive
497+
- name: '@libre.graph.conflictBehavior'
498+
in: query
499+
description: |
500+
Controls what happens when a child with the same name already exists. `fail` (default) returns 409; `replace` overwrites the existing item. MS Graph's `rename` value is not supported.
501+
schema:
502+
type: string
503+
enum:
504+
- fail
505+
- replace
506+
default: fail
507+
- name: '@libre.graph.missingParentsBehavior'
508+
in: query
509+
description: |
510+
Controls what happens when a colon-syntax URL refers to a path whose intermediate folders don't all exist yet. `fail` (default) returns 404; `create` creates the missing intermediate folders before creating the final item. Only meaningful for colon-syntax URLs; ignored otherwise.
511+
schema:
512+
type: string
513+
enum:
514+
- fail
515+
- create
516+
default: fail
484517
requestBody:
485-
description: In the request body, provide a JSON object with the following parameters. For mounting a share the necessary remoteItem id and permission id can be taken from the [sharedWithMe](#/me.drive/ListSharedWithMe) endpoint.
518+
description: In the request body, provide a JSON object describing the new driveItem. Must specify exactly one of `folder`, `file`, or `remoteItem`. For mount-share, see [sharedWithMe](#/me.drive/ListSharedWithMe) for obtaining the source `remoteItem.id` and `permission` id.
486519
content:
487520
application/json:
488521
schema:
489522
$ref: '#/components/schemas/driveItem'
490523
examples:
524+
create a folder:
525+
value:
526+
name: Project Reports
527+
folder: {}
528+
create a file:
529+
value:
530+
name: notes.txt
531+
file: {}
491532
mount a shared remoteId:
492533
value:
493534
name: Einsteins project share
@@ -1310,6 +1351,88 @@ paths:
13101351
default:
13111352
$ref: '#/components/responses/error'
13121353
x-ms-docs-operation-type: operation
1354+
'/v1beta1/drives/{drive-id}/items/{item-id}/children':
1355+
post:
1356+
tags:
1357+
- driveItem
1358+
summary: Create a new DriveItem under a parent item
1359+
operationId: CreateChildDriveItem
1360+
description: |
1361+
Create a new folder or DriveItem in a Drive with the specified parent item. The parent must exist and be a folder.
1362+
1363+
Modeled on the MS Graph create driveItem endpoint
1364+
(https://learn.microsoft.com/en-us/graph/api/driveitem-post-children).
1365+
Identical request and response shape to the [drive-root variant](#/drives.root/CreateDriveItem), just with an explicit parent item id rather than the drive root.
1366+
1367+
The request body must specify exactly one of `folder` (set to `{}` to create a folder) or `file` (to create a file item). Requests with none of these, or with both, return 400. The `@libre.graph.conflictBehavior` query parameter controls what happens if a child with the same name already exists.
1368+
1369+
This endpoint also accepts the MS Graph colon-syntax URL form:
1370+
1371+
POST /v1beta1/drives/{drive-id}/items/{item-id}:/{path}:/children
1372+
1373+
OpenAPI cannot express the colon-delimited path segment, so this URL form is not represented as a separate operation in this specification. The server still accepts it, resolves `:/{path}:` as the parent of the new item (relative to `item-id`), and applies `@libre.graph.missingParentsBehavior` to decide whether to create missing intermediate folders.
1374+
parameters:
1375+
- name: drive-id
1376+
in: path
1377+
description: 'key: id of drive'
1378+
required: true
1379+
schema:
1380+
type: string
1381+
example: a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668
1382+
x-ms-docs-key-type: drive
1383+
- name: item-id
1384+
in: path
1385+
description: 'key: id of item'
1386+
required: true
1387+
schema:
1388+
type: string
1389+
example: a0ca6a90-a365-4782-871e-d44447bbc668$a0ca6a90-a365-4782-871e-d44447bbc668!share-id
1390+
x-ms-docs-key-type: item
1391+
- name: '@libre.graph.conflictBehavior'
1392+
in: query
1393+
description: |
1394+
Controls what happens when a child with the same name already exists. `fail` (default) returns 409; `replace` overwrites the existing item. MS Graph's `rename` value is not supported.
1395+
schema:
1396+
type: string
1397+
enum:
1398+
- fail
1399+
- replace
1400+
default: fail
1401+
- name: '@libre.graph.missingParentsBehavior'
1402+
in: query
1403+
description: |
1404+
Controls what happens when a colon-syntax URL refers to a path whose intermediate folders don't all exist yet. `fail` (default) returns 404; `create` creates the missing intermediate folders before creating the final item. Only meaningful for colon-syntax URLs; ignored otherwise.
1405+
schema:
1406+
type: string
1407+
enum:
1408+
- fail
1409+
- create
1410+
default: fail
1411+
requestBody:
1412+
description: In the request body, provide a JSON object describing the new driveItem. Must specify exactly one of `folder` or `file`.
1413+
required: true
1414+
content:
1415+
application/json:
1416+
schema:
1417+
$ref: '#/components/schemas/driveItem'
1418+
responses:
1419+
'200':
1420+
description: The created DriveItem.
1421+
content:
1422+
application/json:
1423+
schema:
1424+
$ref: '#/components/schemas/driveItem'
1425+
'400':
1426+
$ref: '#/components/responses/error'
1427+
'403':
1428+
$ref: '#/components/responses/error'
1429+
'404':
1430+
$ref: '#/components/responses/error'
1431+
'409':
1432+
$ref: '#/components/responses/error'
1433+
default:
1434+
$ref: '#/components/responses/error'
1435+
x-ms-docs-operation-type: operation
13131436
'/v1beta1/drives/{drive-id}/items/{item-id}/content':
13141437
get:
13151438
tags:

0 commit comments

Comments
 (0)