Skip to content

Commit adc64d3

Browse files
authored
DOC-764 | Fix description of Import HTTP API and improve OpenAPI rendering (#717)
* Fix /_api/import request body media type and description * Add missing parameters and defaults to Import API * Fix rendering of OpenAPI parameter defaults * Render Possible values of OpenAPI enum for parameters and move it above the description * Apply to 3.11 and 3.12 * Point from request body to type param
1 parent c7ea42f commit adc64d3

File tree

4 files changed

+196
-99
lines changed

4 files changed

+196
-99
lines changed

site/content/3.11/develop/http-api/import.md

Lines changed: 62 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,21 @@ paths:
1515
description: |
1616
Load JSON data and store it as documents into the specified collection.
1717
18-
The request body can have different JSON formats:
19-
- One JSON object per line (JSONL)
20-
- A JSON array of objects
21-
- One JSON array per line (CSV-like)
22-
2318
If you import documents into edge collections, all documents require a `_from`
2419
and a `_to` attribute.
2520
requestBody:
2621
content:
27-
application/json:
22+
'text/plain; charset=utf-8':
2823
schema:
29-
type: object
30-
required:
31-
- documents
32-
properties:
33-
documents:
34-
description: |
35-
The body must either be a JSON-encoded array of objects or a string with
36-
multiple JSON objects separated by newlines.
37-
type: string
24+
description: |
25+
The request body can have different JSON formats depending on
26+
the `type` parameter:
27+
- One JSON object per line (JSONL)
28+
- A JSON array of objects
29+
- One JSON array per line (CSV-like)
3830
parameters:
31+
# Purposefully undocumented:
32+
# line (compensate for arangoimport --skip-lines in error messages)
3933
- name: database-name
4034
in: path
4135
required: true
@@ -86,8 +80,8 @@ paths:
8680
8781
- `auto`: automatically determines the type (either `documents` or `array`).
8882
89-
- Omit the `type` parameter entirely to import JSON arrays of tabular data,
90-
similar to CSV.
83+
- Omit the `type` parameter entirely (or set it to an empty string)
84+
to import JSON arrays of tabular data, similar to CSV.
9185
9286
The first line is an array of strings that defines the attribute keys. The
9387
subsequent lines are arrays with the attribute values. The keys and values
@@ -102,40 +96,72 @@ paths:
10296
```
10397
schema:
10498
type: string
99+
enum: ["", documents, array, auto]
100+
default: ""
101+
- name: ignoreMissing
102+
in: query
103+
required: false
104+
description: |
105+
When importing JSON arrays of tabular data (`type` parameter is omitted),
106+
the first line of the request body defines the attribute keys and the
107+
subsequent lines the attribute values for each document. Subsequent lines
108+
with a different number of elements than the first line are not imported
109+
by default.
110+
111+
```js
112+
["attr1", "attr2"]
113+
[1, 2] // matching number of elements
114+
[1] // misses 2nd element
115+
[1, 2, 3] // excess 3rd element
116+
```
117+
118+
You can enable this option to import them anyway. For the missing elements,
119+
the document attributes are omitted. Excess elements are ignored.
120+
schema:
121+
type: boolean
122+
default: false
105123
- name: fromPrefix
106124
in: query
107125
required: false
108126
description: |
109-
An optional prefix for the values in `_from` attributes. If specified, the
110-
value is automatically prepended to each `_from` input value. This allows
111-
specifying just the keys for `_from`.
127+
The collection name prefix to prepend to all values in the `_from`
128+
attribute that only specify a document key.
112129
schema:
113130
type: string
114131
- name: toPrefix
115132
in: query
116133
required: false
117134
description: |
118-
An optional prefix for the values in `_to` attributes. If specified, the
119-
value is automatically prepended to each `_to` input value. This allows
120-
specifying just the keys for `_to`.
135+
The collection name prefix to prepend to all values in the `_to`
136+
attribute that only specify a document key.
121137
schema:
122138
type: string
139+
- name: overwriteCollectionPrefix
140+
in: query
141+
required: false
142+
description: |
143+
Force the `fromPrefix` and `toPrefix`, possibly replacing existing
144+
collection name prefixes.
145+
schema:
146+
type: boolean
147+
default: false
123148
- name: overwrite
124149
in: query
125150
required: false
126151
description: |
127-
If this parameter has a value of `true` or `yes`, then all data in the
128-
collection will be removed prior to the import. Note that any existing
129-
index definitions will be preserved.
152+
If enabled, then all data in the collection is removed prior to the
153+
import. Any existing index definitions are preserved.
130154
schema:
131155
type: boolean
156+
default: false
132157
- name: waitForSync
133158
in: query
134159
required: false
135160
description: |
136161
Wait until documents have been synced to disk before returning.
137162
schema:
138163
type: boolean
164+
default: false
139165
- name: onDuplicate
140166
in: query
141167
required: false
@@ -159,6 +185,7 @@ paths:
159185
schema:
160186
type: string
161187
enum: [error, update, replace, ignore]
188+
default: error
162189
- name: complete
163190
in: query
164191
required: false
@@ -168,6 +195,7 @@ paths:
168195
skipping the problematic documents.
169196
schema:
170197
type: boolean
198+
default: false
171199
- name: details
172200
in: query
173201
required: false
@@ -176,6 +204,7 @@ paths:
176204
about documents that could not be imported.
177205
schema:
178206
type: boolean
207+
default: false
179208
responses:
180209
'201':
181210
description: |
@@ -225,21 +254,22 @@ paths:
225254
type: string
226255
'400':
227256
description: |
228-
is returned if `type` contains an invalid value, no `collection` is
257+
The `type` contains an invalid value, no `collection` is
229258
specified, the documents are incorrectly encoded, or the request
230259
is malformed.
231260
'404':
232261
description: |
233-
is returned if `collection` or the `_from` or `_to` attributes of an
262+
The `collection` parameter or the `_from` or `_to` attributes of an
234263
imported edge refer to an unknown collection.
235264
'409':
236265
description: |
237-
is returned if the import would trigger a unique key violation and
238-
`complete` is set to `true`.
266+
The `complete` option is enabled and the import triggers a
267+
unique key violation.
239268
'500':
240269
description: |
241-
is returned if the server cannot auto-generate a document key (out of keys
242-
error) for a document with no user-defined key.
270+
The `complete` option is enabled and the input is invalid,
271+
or the server cannot auto-generate a document key (out of keys error)
272+
for a document with no user-defined key.
243273
tags:
244274
- Import
245275
```

site/content/3.12/develop/http-api/import.md

Lines changed: 62 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,21 @@ paths:
1515
description: |
1616
Load JSON data and store it as documents into the specified collection.
1717
18-
The request body can have different JSON formats:
19-
- One JSON object per line (JSONL)
20-
- A JSON array of objects
21-
- One JSON array per line (CSV-like)
22-
2318
If you import documents into edge collections, all documents require a `_from`
2419
and a `_to` attribute.
2520
requestBody:
2621
content:
27-
application/json:
22+
'text/plain; charset=utf-8':
2823
schema:
29-
type: object
30-
required:
31-
- documents
32-
properties:
33-
documents:
34-
description: |
35-
The body must either be a JSON-encoded array of objects or a string with
36-
multiple JSON objects separated by newlines.
37-
type: string
24+
description: |
25+
The request body can have different JSON formats depending on
26+
the `type` parameter:
27+
- One JSON object per line (JSONL)
28+
- A JSON array of objects
29+
- One JSON array per line (CSV-like)
3830
parameters:
31+
# Purposefully undocumented:
32+
# line (compensate for arangoimport --skip-lines in error messages)
3933
- name: database-name
4034
in: path
4135
required: true
@@ -86,8 +80,8 @@ paths:
8680
8781
- `auto`: automatically determines the type (either `documents` or `array`).
8882
89-
- Omit the `type` parameter entirely to import JSON arrays of tabular data,
90-
similar to CSV.
83+
- Omit the `type` parameter entirely (or set it to an empty string)
84+
to import JSON arrays of tabular data, similar to CSV.
9185
9286
The first line is an array of strings that defines the attribute keys. The
9387
subsequent lines are arrays with the attribute values. The keys and values
@@ -102,40 +96,72 @@ paths:
10296
```
10397
schema:
10498
type: string
99+
enum: ["", documents, array, auto]
100+
default: ""
101+
- name: ignoreMissing
102+
in: query
103+
required: false
104+
description: |
105+
When importing JSON arrays of tabular data (`type` parameter is omitted),
106+
the first line of the request body defines the attribute keys and the
107+
subsequent lines the attribute values for each document. Subsequent lines
108+
with a different number of elements than the first line are not imported
109+
by default.
110+
111+
```js
112+
["attr1", "attr2"]
113+
[1, 2] // matching number of elements
114+
[1] // misses 2nd element
115+
[1, 2, 3] // excess 3rd element
116+
```
117+
118+
You can enable this option to import them anyway. For the missing elements,
119+
the document attributes are omitted. Excess elements are ignored.
120+
schema:
121+
type: boolean
122+
default: false
105123
- name: fromPrefix
106124
in: query
107125
required: false
108126
description: |
109-
An optional prefix for the values in `_from` attributes. If specified, the
110-
value is automatically prepended to each `_from` input value. This allows
111-
specifying just the keys for `_from`.
127+
The collection name prefix to prepend to all values in the `_from`
128+
attribute that only specify a document key.
112129
schema:
113130
type: string
114131
- name: toPrefix
115132
in: query
116133
required: false
117134
description: |
118-
An optional prefix for the values in `_to` attributes. If specified, the
119-
value is automatically prepended to each `_to` input value. This allows
120-
specifying just the keys for `_to`.
135+
The collection name prefix to prepend to all values in the `_to`
136+
attribute that only specify a document key.
121137
schema:
122138
type: string
139+
- name: overwriteCollectionPrefix
140+
in: query
141+
required: false
142+
description: |
143+
Force the `fromPrefix` and `toPrefix`, possibly replacing existing
144+
collection name prefixes.
145+
schema:
146+
type: boolean
147+
default: false
123148
- name: overwrite
124149
in: query
125150
required: false
126151
description: |
127-
If this parameter has a value of `true` or `yes`, then all data in the
128-
collection will be removed prior to the import. Note that any existing
129-
index definitions will be preserved.
152+
If enabled, then all data in the collection is removed prior to the
153+
import. Any existing index definitions are preserved.
130154
schema:
131155
type: boolean
156+
default: false
132157
- name: waitForSync
133158
in: query
134159
required: false
135160
description: |
136161
Wait until documents have been synced to disk before returning.
137162
schema:
138163
type: boolean
164+
default: false
139165
- name: onDuplicate
140166
in: query
141167
required: false
@@ -159,6 +185,7 @@ paths:
159185
schema:
160186
type: string
161187
enum: [error, update, replace, ignore]
188+
default: error
162189
- name: complete
163190
in: query
164191
required: false
@@ -168,6 +195,7 @@ paths:
168195
skipping the problematic documents.
169196
schema:
170197
type: boolean
198+
default: false
171199
- name: details
172200
in: query
173201
required: false
@@ -176,6 +204,7 @@ paths:
176204
about documents that could not be imported.
177205
schema:
178206
type: boolean
207+
default: false
179208
responses:
180209
'201':
181210
description: |
@@ -225,21 +254,22 @@ paths:
225254
type: string
226255
'400':
227256
description: |
228-
is returned if `type` contains an invalid value, no `collection` is
257+
The `type` contains an invalid value, no `collection` is
229258
specified, the documents are incorrectly encoded, or the request
230259
is malformed.
231260
'404':
232261
description: |
233-
is returned if `collection` or the `_from` or `_to` attributes of an
262+
The `collection` parameter or the `_from` or `_to` attributes of an
234263
imported edge refer to an unknown collection.
235264
'409':
236265
description: |
237-
is returned if the import would trigger a unique key violation and
238-
`complete` is set to `true`.
266+
The `complete` option is enabled and the import triggers a
267+
unique key violation.
239268
'500':
240269
description: |
241-
is returned if the server cannot auto-generate a document key (out of keys
242-
error) for a document with no user-defined key.
270+
The `complete` option is enabled and the input is invalid,
271+
or the server cannot auto-generate a document key (out of keys error)
272+
for a document with no user-defined key.
243273
tags:
244274
- Import
245275
```

0 commit comments

Comments
 (0)