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

Commit 18a6a66

Browse files
authored
Fixes python generator bug where quote is omitted from typeddict property (#413)
* Adds fix for python generator * Updates samples
1 parent 59ed43c commit 18a6a66

File tree

6 files changed

+546
-30
lines changed

6 files changed

+546
-30
lines changed

samples/client/petstore/java/docs/components/schemas/ObjectWithOnlyOptionalProps.md

+145-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ A class that contains necessary nested
66
- schema classes (which validate payloads), extends JsonSchema
77
- sealed interfaces which store validated payloads, java version of a sum type
88
- boxed classes which store validated payloads, sealed permits class implementations
9+
- classes to store validated list payloads, extends FrozenList
10+
- classes to build inputs for list payloads
911
- classes to store validated map payloads, extends FrozenMap
1012
- classes to build inputs for map payloads
1113

@@ -17,6 +19,12 @@ A class that contains necessary nested
1719
| static class | [ObjectWithOnlyOptionalProps.ObjectWithOnlyOptionalProps1](#objectwithonlyoptionalprops1)<br> schema class |
1820
| static class | [ObjectWithOnlyOptionalProps.ObjectWithOnlyOptionalPropsMapBuilder](#objectwithonlyoptionalpropsmapbuilder)<br> builder for Map payloads |
1921
| static class | [ObjectWithOnlyOptionalProps.ObjectWithOnlyOptionalPropsMap](#objectwithonlyoptionalpropsmap)<br> output class for Map payloads |
22+
| sealed interface | [ObjectWithOnlyOptionalProps.ArrayPropertyBoxed](#arraypropertyboxed)<br> sealed interface for validated payloads |
23+
| record | [ObjectWithOnlyOptionalProps.ArrayPropertyBoxedVoid](#arraypropertyboxedvoid)<br> boxed class to store validated null payloads |
24+
| record | [ObjectWithOnlyOptionalProps.ArrayPropertyBoxedList](#arraypropertyboxedlist)<br> boxed class to store validated List payloads |
25+
| static class | [ObjectWithOnlyOptionalProps.ArrayProperty](#arrayproperty)<br> schema class |
26+
| static class | [ObjectWithOnlyOptionalProps.ArrayPropertyListBuilder](#arraypropertylistbuilder)<br> builder for List payloads |
27+
| static class | [ObjectWithOnlyOptionalProps.ArrayPropertyList](#arraypropertylist)<br> output class for List payloads |
2028
| sealed interface | [ObjectWithOnlyOptionalProps.BBoxed](#bboxed)<br> sealed interface for validated payloads |
2129
| record | [ObjectWithOnlyOptionalProps.BBoxedNumber](#bboxednumber)<br> boxed class to store validated Number payloads |
2230
| static class | [ObjectWithOnlyOptionalProps.B](#b)<br> schema class |
@@ -86,6 +94,8 @@ ObjectWithOnlyOptionalProps.ObjectWithOnlyOptionalPropsMap validatedPayload =
8694
8795
.b(1)
8896
97+
.ArrayProperty(null)
98+
8999
.build(),
90100
configuration
91101
);
@@ -95,7 +105,7 @@ ObjectWithOnlyOptionalProps.ObjectWithOnlyOptionalPropsMap validatedPayload =
95105
| Modifier and Type | Field and Description |
96106
| ----------------- | ---------------------- |
97107
| Set<Class<?>> | type = Set.of(Map.class) |
98-
| Map<String, Class<? extends JsonSchema>> | properties = Map.ofEntries(<br>&nbsp;&nbsp;&nbsp;&nbsp;new PropertyEntry("a", [A.class](#a))),<br>&nbsp;&nbsp;&nbsp;&nbsp;new PropertyEntry("b", [B.class](#b)))<br>)<br> |
108+
| Map<String, Class<? extends JsonSchema>> | properties = Map.ofEntries(<br>&nbsp;&nbsp;&nbsp;&nbsp;new PropertyEntry("a", [A.class](#a))),<br>&nbsp;&nbsp;&nbsp;&nbsp;new PropertyEntry("b", [B.class](#b))),<br>&nbsp;&nbsp;&nbsp;&nbsp;new PropertyEntry("ArrayProperty", [ArrayProperty.class](#arrayproperty)))<br>)<br> |
99109
| Class<? extends JsonSchema> | additionalProperties = [AdditionalProperties.class](#additionalproperties) |
100110

101111
### Method Summary
@@ -108,7 +118,7 @@ ObjectWithOnlyOptionalProps.ObjectWithOnlyOptionalPropsMap validatedPayload =
108118

109119
## ObjectWithOnlyOptionalPropsMapBuilder
110120
public class ObjectWithOnlyOptionalPropsMapBuilder<br>
111-
builder for `Map<String, Object>`
121+
builder for `Map<String, @Nullable Object>`
112122

113123
A class that builds the Map input type
114124

@@ -120,25 +130,155 @@ A class that builds the Map input type
120130
### Method Summary
121131
| Modifier and Type | Method and Description |
122132
| ----------------- | ---------------------- |
123-
| Map<String, Object> | build()<br>Returns map input that should be used with Schema.validate |
133+
| Map<String, @Nullable Object> | build()<br>Returns map input that should be used with Schema.validate |
124134
| [ObjectWithOnlyOptionalPropsMapBuilder](#objectwithonlyoptionalpropsmapbuilder) | a(String value) |
125135
| [ObjectWithOnlyOptionalPropsMapBuilder](#objectwithonlyoptionalpropsmapbuilder) | b(int value) |
126136
| [ObjectWithOnlyOptionalPropsMapBuilder](#objectwithonlyoptionalpropsmapbuilder) | b(float value) |
127137
| [ObjectWithOnlyOptionalPropsMapBuilder](#objectwithonlyoptionalpropsmapbuilder) | b(long value) |
128138
| [ObjectWithOnlyOptionalPropsMapBuilder](#objectwithonlyoptionalpropsmapbuilder) | b(double value) |
139+
| [ObjectWithOnlyOptionalPropsMapBuilder](#objectwithonlyoptionalpropsmapbuilder) | ArrayProperty(Void value) |
140+
| [ObjectWithOnlyOptionalPropsMapBuilder](#objectwithonlyoptionalpropsmapbuilder) | ArrayProperty(List<String> value) |
129141

130142
## ObjectWithOnlyOptionalPropsMap
131143
public static class ObjectWithOnlyOptionalPropsMap<br>
132-
extends FrozenMap<String, Object>
144+
extends FrozenMap<String, @Nullable Object>
133145

134146
A class to store validated Map payloads
135147

136148
### Method Summary
137149
| Modifier and Type | Method and Description |
138150
| ----------------- | ---------------------- |
139-
| static [ObjectWithOnlyOptionalPropsMap](#objectwithonlyoptionalpropsmap) | of([Map<String, Object>](#objectwithonlyoptionalpropsmapbuilder) arg, SchemaConfiguration configuration) |
151+
| static [ObjectWithOnlyOptionalPropsMap](#objectwithonlyoptionalpropsmap) | of([Map<String, ? extends @Nullable Object>](#objectwithonlyoptionalpropsmapbuilder) arg, SchemaConfiguration configuration) |
140152
| String | a()<br>[optional] |
141153
| Number | b()<br>[optional] |
154+
| [ArrayPropertyList](#arraypropertylist) | ArrayProperty()<br>[optional] |
155+
156+
## ArrayPropertyBoxed
157+
public sealed interface ArrayPropertyBoxed<br>
158+
permits<br>
159+
[ArrayPropertyBoxedVoid](#arraypropertyboxedvoid),
160+
[ArrayPropertyBoxedList](#arraypropertyboxedlist)
161+
162+
sealed interface that stores validated payloads using boxed classes
163+
164+
## ArrayPropertyBoxedVoid
165+
public record ArrayPropertyBoxedVoid<br>
166+
implements [ArrayPropertyBoxed](#arraypropertyboxed)
167+
168+
record that stores validated null payloads, sealed permits implementation
169+
170+
### Constructor Summary
171+
| Constructor and Description |
172+
| --------------------------- |
173+
| ArrayPropertyBoxedVoid(Void data)<br>Creates an instance, private visibility |
174+
175+
### Method Summary
176+
| Modifier and Type | Method and Description |
177+
| ----------------- | ---------------------- |
178+
| Void | data()<br>validated payload |
179+
| @Nullable Object | getData()<br>validated payload |
180+
181+
## ArrayPropertyBoxedList
182+
public record ArrayPropertyBoxedList<br>
183+
implements [ArrayPropertyBoxed](#arraypropertyboxed)
184+
185+
record that stores validated List payloads, sealed permits implementation
186+
187+
### Constructor Summary
188+
| Constructor and Description |
189+
| --------------------------- |
190+
| ArrayPropertyBoxedList([ArrayPropertyList](#arraypropertylist) data)<br>Creates an instance, private visibility |
191+
192+
### Method Summary
193+
| Modifier and Type | Method and Description |
194+
| ----------------- | ---------------------- |
195+
| [ArrayPropertyList](#arraypropertylist) | data()<br>validated payload |
196+
| @Nullable Object | getData()<br>validated payload |
197+
198+
## ArrayProperty
199+
public static class ArrayProperty<br>
200+
extends JsonSchema
201+
202+
A schema class that validates payloads
203+
204+
### Code Sample
205+
```
206+
import org.openapijsonschematools.client.configurations.JsonSchemaKeywordFlags;
207+
import org.openapijsonschematools.client.configurations.SchemaConfiguration;
208+
import org.openapijsonschematools.client.exceptions.ValidationException;
209+
import org.openapijsonschematools.client.schemas.validation.MapUtils;
210+
import org.openapijsonschematools.client.schemas.validation.FrozenList;
211+
import org.openapijsonschematools.client.schemas.validation.FrozenMap;
212+
import org.openapijsonschematools.client.components.schemas.ObjectWithOnlyOptionalProps;
213+
214+
import java.util.Arrays;
215+
import java.util.List;
216+
import java.util.AbstractMap;
217+
218+
static final SchemaConfiguration configuration = new SchemaConfiguration(JsonSchemaKeywordFlags.ofNone());
219+
220+
// null validation
221+
Void validatedPayload = ObjectWithOnlyOptionalProps.ArrayProperty.validate(
222+
(Void) null,
223+
configuration
224+
);
225+
226+
// List validation
227+
ObjectWithOnlyOptionalProps.ArrayPropertyList validatedPayload =
228+
ObjectWithOnlyOptionalProps.ArrayProperty.validate(
229+
new ObjectWithOnlyOptionalProps.ArrayPropertyListBuilder()
230+
.add("_abc")
231+
232+
.build(),
233+
configuration
234+
);
235+
```
236+
237+
### Field Summary
238+
| Modifier and Type | Field and Description |
239+
| ----------------- | ---------------------- |
240+
| Set<Class<?>> | type = Set.of(<br/>&nbsp;&nbsp;&nbsp;&nbsp;Void.class,<br/>&nbsp;&nbsp;&nbsp;&nbsp;List.class<br/>)<br/> |
241+
| Class<? extends JsonSchema> | items = [EnumClass.EnumClass1.class](../../components/schemas/EnumClass.md#enumclass1) |
242+
243+
### Method Summary
244+
| Modifier and Type | Method and Description |
245+
| ----------------- | ---------------------- |
246+
| Void | validate(Void arg, SchemaConfiguration configuration) |
247+
| [ArrayPropertyBoxedVoid](#arraypropertyboxedvoid) | validateAndBox(Void arg, SchemaConfiguration configuration) |
248+
| [ArrayPropertyList](#arraypropertylist) | validate([List<?>](#arraypropertylistbuilder) arg, SchemaConfiguration configuration) |
249+
| [ArrayPropertyBoxedList](#arraypropertyboxedlist) | validateAndBox([List<?>](#arraypropertylistbuilder) arg, SchemaConfiguration configuration) |
250+
| [ArrayPropertyBoxed](#arraypropertyboxed) | validateAndBox(@Nullable Object arg, SchemaConfiguration configuration) |
251+
| @Nullable Object | validate(@Nullable Object arg, SchemaConfiguration configuration) |
252+
253+
## ArrayPropertyListBuilder
254+
public class ArrayPropertyListBuilder<br>
255+
builder for `List<String>`
256+
257+
A class that builds the List input type
258+
259+
### Constructor Summary
260+
| Constructor and Description |
261+
| --------------------------- |
262+
| ArrayPropertyListBuilder()<br>Creates an empty list |
263+
| ArrayPropertyListBuilder(List<String> items)<br>Stores the items in a list |
264+
265+
### Method Summary
266+
| Modifier and Type | Method and Description |
267+
| ----------------- | ---------------------- |
268+
| ArrayPropertyListBuilder | add(String item) |
269+
| ArrayPropertyListBuilder | add([EnumClass.StringEnumClassEnums](../../components/schemas/EnumClass.md#stringenumclassenums) item) |
270+
| List<String> | build()<br>Returns list input that should be used with Schema.validate |
271+
272+
## ArrayPropertyList
273+
public class ArrayPropertyList<br>
274+
extends `FrozenList<String>`
275+
276+
A class to store validated List payloads
277+
278+
### Method Summary
279+
| Modifier and Type | Method and Description |
280+
| ----------------- | ---------------------- |
281+
| static [ArrayPropertyList](#arraypropertylist) | of([List<String>](#arraypropertylistbuilder) arg, SchemaConfiguration configuration) |
142282

143283
## BBoxed
144284
public sealed interface BBoxed<br>

0 commit comments

Comments
 (0)