Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit 834b21b

Browse files
authored
Refactors schema class templates (#217)
* Breaks up composed schema template * Removes dict partial * Partial sample regen * Switches dict schema info order back to original * Refactos some lines into const and enum templates * Template tweaks * Extracts unique items template * Creates max_length template * Extracts template for minLength * Simplifies schema_cls template * Adds max and min items templates * Makes and uses templates for max/minProperties * Adds and uses max and min templates * Removes validation template * Deprecates hasValidation, adds default and format templates * Adds and uses template for boolean schema class * Adds templates for number and string * Renames template to _schema_anytype_or_multitype * Samples and docs regenerated * Changes min max value detection to use not equal to null * Fixes bug where extra const was written * Samples regen
1 parent b04e9f3 commit 834b21b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+429
-279
lines changed

samples/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/anyof_with_base_schema.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,3 @@ class AnyofWithBaseSchema(
4747
str,
4848
})
4949
any_of: AnyOf = dataclasses.field(default_factory=lambda: schemas.tuple_to_instance(AnyOf)) # type: ignore
50-

samples/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/oneof_with_base_schema.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,3 @@ class OneofWithBaseSchema(
4747
str,
4848
})
4949
one_of: OneOf = dataclasses.field(default_factory=lambda: schemas.tuple_to_instance(OneOf)) # type: ignore
50-

samples/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/oneof_with_required.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -178,16 +178,14 @@ class _1(
178178

179179
@dataclasses.dataclass(frozen=True)
180180
class OneofWithRequired(
181-
schemas.Schema[schemas.immutabledict, tuple]
181+
schemas.Schema[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], tuple]
182182
):
183183
"""NOTE: This class is auto generated by OpenAPI JSON Schema Generator.
184184
Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator
185185
186186
Do not edit the class manually.
187187
"""
188-
types: typing.FrozenSet[typing.Type] = frozenset({
189-
schemas.immutabledict,
190-
})
188+
types: typing.FrozenSet[typing.Type] = frozenset({schemas.immutabledict})
191189
one_of: OneOf = dataclasses.field(default_factory=lambda: schemas.tuple_to_instance(OneOf)) # type: ignore
192190

193191
@classmethod

samples/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/the_default_keyword_does_not_do_anything_if_the_property_is_missing.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ class Alpha(
2121
int,
2222
})
2323
inclusive_maximum: typing.Union[int, float] = 3
24-
default: typing.Union[int, float] = 5
2524
Properties = typing.TypedDict(
2625
'Properties',
2726
{

samples/client/3_0_3_unit_test/python/src/unit_test_api/components/schema/uniqueitems_false_validation.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,4 @@
1010
from __future__ import annotations
1111
from unit_test_api.shared_imports.schema_imports import * # pyright: ignore [reportWildcardImportFromLibrary]
1212

13-
14-
15-
@dataclasses.dataclass(frozen=True)
16-
class UniqueitemsFalseValidation(
17-
schemas.AnyTypeSchema[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], typing.Tuple[schemas.OUTPUT_BASE_TYPES, ...]],
18-
):
19-
"""NOTE: This class is auto generated by OpenAPI JSON Schema Generator.
20-
Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator
21-
22-
Do not edit the class manually.
23-
"""
24-
# any type
25-
unique_items: bool = False
26-
13+
UniqueitemsFalseValidation: typing_extensions.TypeAlias = schemas.AnyTypeSchema

samples/client/petstore/python/src/petstore_api/components/schema/abstract_step_message.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@ class AbstractStepMessage(
101101
102102
Abstract Step
103103
"""
104-
types: typing.FrozenSet[typing.Type] = frozenset({
105-
schemas.immutabledict,
106-
})
104+
types: typing.FrozenSet[typing.Type] = frozenset({schemas.immutabledict})
107105
required: typing.FrozenSet[str] = frozenset({
108106
"description",
109107
"discriminator",
@@ -123,7 +121,7 @@ class AbstractStepMessage(
123121
typing.Type
124122
] = dataclasses.field(
125123
default_factory=lambda: {
126-
schemas.immutabledict: AbstractStepMessageDict,
124+
schemas.immutabledict: AbstractStepMessageDict
127125
}
128126
)
129127

samples/client/petstore/python/src/petstore_api/components/schema/additional_properties_validator.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,16 +257,14 @@ def validate(
257257

258258
@dataclasses.dataclass(frozen=True)
259259
class AdditionalPropertiesValidator(
260-
schemas.Schema[schemas.immutabledict, tuple]
260+
schemas.Schema[schemas.immutabledict[str, schemas.OUTPUT_BASE_TYPES], tuple]
261261
):
262262
"""NOTE: This class is auto generated by OpenAPI JSON Schema Generator.
263263
Ref: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator
264264
265265
Do not edit the class manually.
266266
"""
267-
types: typing.FrozenSet[typing.Type] = frozenset({
268-
schemas.immutabledict,
269-
})
267+
types: typing.FrozenSet[typing.Type] = frozenset({schemas.immutabledict})
270268
all_of: AllOf = dataclasses.field(default_factory=lambda: schemas.tuple_to_instance(AllOf)) # type: ignore
271269

272270
@classmethod

samples/client/petstore/python/src/petstore_api/components/schema/composed_bool.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,3 @@ class ComposedBool(
2929
schemas.Bool,
3030
})
3131
all_of: AllOf = dataclasses.field(default_factory=lambda: schemas.tuple_to_instance(AllOf)) # type: ignore
32-

samples/client/petstore/python/src/petstore_api/components/schema/composed_none.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,3 @@ class ComposedNone(
2929
type(None),
3030
})
3131
all_of: AllOf = dataclasses.field(default_factory=lambda: schemas.tuple_to_instance(AllOf)) # type: ignore
32-

samples/client/petstore/python/src/petstore_api/components/schema/composed_number.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,3 @@ class ComposedNumber(
3030
int,
3131
})
3232
all_of: AllOf = dataclasses.field(default_factory=lambda: schemas.tuple_to_instance(AllOf)) # type: ignore
33-

0 commit comments

Comments
 (0)