File: union_default_object.yaml

package info (click to toggle)
python-datamodel-code-generator 0.45.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 9,052 kB
  • sloc: python: 29,621; makefile: 15
file content (47 lines) | stat: -rw-r--r-- 1,232 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
openapi: 3.1.0
info:
  title: Union Default Object Test
  version: 0.1.0
servers:
- url: http://example.com
paths:
  /test:
    get:
      responses:
        '200':
          description: OK
components:
  schemas:
    Interval:
      type: object
      properties:
        start:
          type: integer
        end:
          type: integer
    Container:
      type: object
      properties:
        # Union[Interval, str] with dict default - should use default_factory
        interval_or_string:
          anyOf:
            - $ref: '#/components/schemas/Interval'
            - type: string
          default:
            start: 2009
            end: 2019
        # Union[Interval, str] with string default - should NOT use default_factory
        string_or_interval:
          anyOf:
            - $ref: '#/components/schemas/Interval'
            - type: string
          default: "some string value"
        # Union[Dict, Interval] with dict default - should NOT use default_factory (dict arm)
        dict_or_interval:
          anyOf:
            - type: object
              additionalProperties:
                type: string
            - $ref: '#/components/schemas/Interval'
          default:
            key: "value"