File: extras_in_oneof.py

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 (45 lines) | stat: -rw-r--r-- 1,304 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
# generated by datamodel-codegen:
#   filename:  extras_in_oneof.json
#   timestamp: 2019-07-26T00:00:00+00:00

from __future__ import annotations

from typing import Optional, Union

from pydantic import BaseModel, Field


class OneofProp(BaseModel):
    shared_prop: Optional[str] = Field(
        None, json_schema_extra={'x-shared': 'shared_value'}
    )
    variant_a_prop: Optional[str] = Field(
        None, json_schema_extra={'x-variant': 'variant_a_value'}
    )


class OneofProp1(BaseModel):
    shared_prop: Optional[str] = Field(
        None, json_schema_extra={'x-shared': 'shared_value'}
    )
    variant_b_prop: Optional[int] = Field(
        None, json_schema_extra={'x-variant': 'variant_b_value'}
    )


class AnyofProp(BaseModel):
    any_a_prop: Optional[str] = Field(None, json_schema_extra={'x-any': 'any_a_value'})


class AnyofProp1(BaseModel):
    any_b_prop: Optional[bool] = Field(None, json_schema_extra={'x-any': 'any_b_value'})


class ExtrasInOneOf(BaseModel):
    simple_prop: Optional[str] = Field(
        None, json_schema_extra={'x-custom': 'simple_value'}
    )
    oneof_prop: Optional[Union[OneofProp, OneofProp1]] = Field(
        None, json_schema_extra={'x-parent-custom': 'parent_value'}
    )
    anyof_prop: Optional[Union[AnyofProp, AnyofProp1]] = None