Skip to content

Commit a136814

Browse files
committed
update documentation for new config flags
1 parent 2e20268 commit a136814

File tree

2 files changed

+132
-0
lines changed

2 files changed

+132
-0
lines changed

docs/configuration_file.md

+38
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ default_descriptions: true
5757

5858
## Enable/disable generation of default properties (description, id, label, and type) for each schema
5959
default_properties: true
60+
61+
## Enable/disable generation of arrays for property type(s) all the time, regardless of cardinality / restrictions
62+
always_generate_arrays: true
63+
64+
## Enable/disable generation of list of required properties for a schema, if the the cardinality indicates it is required (e.g. exactly 1)
65+
required_properties_from_cardinality: false
6066
```
6167
6268
## Supported settings
@@ -303,6 +309,38 @@ For more information, go to [filtering classes](filtering.md#default_properties)
303309
default_properties: false
304310
```
305311

312+
### always_generate_arrays
313+
314+
Enable/disable generation of arrays for property type(s) all the time, regardless of cardinality / restrictions.
315+
316+
| Field | Value |
317+
| ------------- | --------- |
318+
| **Required:** | `false` |
319+
| **Type:** | `Boolean` |
320+
| **Default:** | `True` |
321+
322+
For more information, go to [filtering classes](filtering.md#always_generate_arrays)
323+
324+
```yaml
325+
always_generate_arrays: true
326+
```
327+
328+
### required_properties_from_cardinality
329+
330+
Enable/disable generation of list of required properties for a schema, if the the cardinality indicates it is required (e.g. exactly 1).
331+
332+
| Field | Value |
333+
| ------------- | --------- |
334+
| **Required:** | `false` |
335+
| **Type:** | `Boolean` |
336+
| **Default:** | `False` |
337+
338+
For more information, go to [filtering classes](filtering.md#required_properties_from_cardinality)
339+
340+
```yaml
341+
required_properties_from_cardinality: true
342+
```
343+
306344
## auth
307345

308346
Add login to the API and add security to the following methods: `POST`, `PUT` and `DELETE`

docs/filtering.md

+94
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ default_descriptions: true
5050

5151
## Enable/disable generation of default properties (description, id, label, and type) for each schema
5252
default_properties: true
53+
54+
## Enable/disable generation of arrays for property type(s) all the time, regardless of cardinality / restrictions
55+
always_generate_arrays: true
56+
57+
## Enable/disable generation of list of required properties for a schema, if the the cardinality indicates it is required (e.g. exactly 1)
58+
required_properties_from_cardinality: false
5359
```
5460
5561
The result is available at: [DBPedia Music](https://app.swaggerhub.com/apis/mosoriob/dbpedia-music/v1.3.0)
@@ -231,3 +237,91 @@ components:
231237
type: integer
232238
type: object
233239
```
240+
241+
### Generating property types as array of items uniformly vs. non-array when cardinality/restrictions warrant it
242+
243+
When a property can have multiple items (e.g. a list of names), the property schema will always generate `type: array` with an `items:` key and sub-item types (e.g. `type: string`). However, in cases where the property is restricted by cardinality, the API spec can be generated so that the property is not an array but a single type (e.g. `type: string`). These cases include cardinality where the property is exactly 1 or is a maximum of 1.
244+
245+
The default is to treat everything as an array, such as:
246+
247+
```yaml
248+
components:
249+
schemas:
250+
YourClass:
251+
properties:
252+
propertyA:
253+
items:
254+
maxItems: 1
255+
minItems: 1
256+
type: string
257+
type: array
258+
propertyB:
259+
items:
260+
maxItems: 3
261+
type: string
262+
type: array
263+
type: object
264+
```
265+
266+
The option `always_generate_arrays` allows you to disable the generating all properties with an array of items, if the class restrictions warrant it (e.g. there is exactly one property value allowed). By setting the `always_generate_arrays` value to `false`, the above example becomes:
267+
268+
```yaml
269+
components:
270+
schemas:
271+
YourClass:
272+
properties:
273+
propertyA:
274+
type: array
275+
propertyB:
276+
items:
277+
maxItems: 3
278+
type: string
279+
type: array
280+
type: object
281+
```
282+
283+
### Generating list of required property/properties for a class, when cardinality/restrictions warrant it
284+
285+
When a property is known to be required based on class restrictions (e.g. exactly 1 or a minimum >= 1), OpenAPI specification supports a `required` key directly under the property. By default, OBA does not generate this required list of properties (for each class), for example:
286+
287+
```yaml
288+
components:
289+
schemas:
290+
YourClass:
291+
properties:
292+
propertyA:
293+
items:
294+
maxItems: 1
295+
minItems: 1
296+
type: string
297+
type: array
298+
propertyB:
299+
items:
300+
maxItems: 3
301+
type: string
302+
type: array
303+
type: object
304+
```
305+
306+
The option `required_properties_from_cardinality` allows you to generate this list based on class restrictions (e.g. there is exactly one property value or there is a minimum of 1 or more of the property value). By setting the `required_properties_from_cardinality` value to `true`, the above example becomes:
307+
308+
```yaml
309+
components:
310+
schemas:
311+
YourClass:
312+
properties:
313+
propertyA:
314+
items:
315+
maxItems: 1
316+
minItems: 1
317+
type: string
318+
type: array
319+
propertyB:
320+
items:
321+
maxItems: 3
322+
type: string
323+
type: array
324+
type: object
325+
required:
326+
- propertyA
327+
```

0 commit comments

Comments
 (0)