Skip to content

Commit 4decf36

Browse files
Add comprehensive feature metadata to schema version dataclasses (#2946)
* Add comprehensive feature metadata to schema version dataclasses * docs: update schema feature documentation 🤖 Generated by GitHub Actions * docs: update llms.txt files Generated by GitHub Actions --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent abac763 commit 4decf36

4 files changed

Lines changed: 234 additions & 0 deletions

File tree

docs/llms-full.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24161,13 +24161,33 @@ The following features are tracked in the codebase with their implementation sta
2416124161
| `definitions/$defs` | Draft 4 | ✅ Supported | Key for reusable schema definitions |
2416224162
| `exclusiveMinimum/Maximum as number` | Draft 6 | ✅ Supported | Numeric `exclusiveMinimum`/`exclusiveMaximum` (boolean in Draft 4) |
2416324163
| `readOnly/writeOnly` | Draft 7 | ✅ Supported | Field visibility hints for read-only and write-only properties |
24164+
| `const` | Draft 6 | ✅ Supported | Single constant value constraint |
24165+
| `propertyNames` | Draft 6 | ✅ Supported | Dict key type constraints via pattern, enum, or $ref |
24166+
| `contains` | Draft 6 | ❌ Not Supported | Array contains at least one matching item |
24167+
| `deprecated` | 2019-09 | ⚠️ Partial | Marks schema elements as deprecated |
24168+
| `if/then/else` | Draft 7 | ❌ Not Supported | Conditional schema validation |
24169+
| `contentMediaType/contentEncoding` | Draft 7 | ❌ Not Supported | Content type and encoding hints for strings |
24170+
| `$anchor` | 2019-09 | ❌ Not Supported | Location-independent schema references |
24171+
| `$vocabulary` | 2019-09 | ❌ Not Supported | Vocabulary declarations for meta-schemas |
24172+
| `unevaluatedProperties` | 2019-09 | ❌ Not Supported | Additional properties not evaluated by subschemas |
24173+
| `unevaluatedItems` | 2019-09 | ❌ Not Supported | Additional items not evaluated by subschemas |
24174+
| `dependentRequired` | 2019-09 | ❌ Not Supported | Conditional property requirements |
24175+
| `dependentSchemas` | 2019-09 | ❌ Not Supported | Conditional schema application based on property presence |
24176+
| `$dynamicRef/$dynamicAnchor` | 2020-12 | ❌ Not Supported | Dynamic reference resolution across schemas |
2416424177

2416524178
#### OpenAPI-Specific Features
2416624179

2416724180
| Feature | Introduced | Status | Description |
2416824181
|---------|------------|--------|-------------|
2416924182
| `nullable` | OAS 3.0 | ✅ Supported | Uses `nullable: true` for nullable types (deprecated in 3.1) |
2417024183
| `discriminator` | OAS 3.0 | ✅ Supported | Polymorphism support via `discriminator` keyword |
24184+
| `webhooks` | OAS 3.1 | ✅ Supported | Top-level webhooks object for incoming events |
24185+
| `$ref with sibling keywords` | OAS 3.1 | ⚠️ Partial | $ref can coexist with description, summary (no allOf workaround) |
24186+
| `xml` | OAS 3.0 | ❌ Not Supported | XML serialization metadata (name, namespace, prefix) |
24187+
| `externalDocs` | OAS 3.0 | ❌ Not Supported | Reference to external documentation |
24188+
| `links` | OAS 3.0 | ❌ Not Supported | Links between operations |
24189+
| `callbacks` | OAS 3.0 | ❌ Not Supported | Callback definitions for webhooks |
24190+
| `securitySchemes` | OAS 3.0 | ❌ Not Supported | API security mechanism definitions |
2417124191
<!-- END AUTO-GENERATED SUPPORTED FEATURES -->
2417224192

2417324193
## Data Format Support

docs/supported_formats.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,33 @@ The following features are tracked in the codebase with their implementation sta
107107
| `definitions/$defs` | Draft 4 | ✅ Supported | Key for reusable schema definitions |
108108
| `exclusiveMinimum/Maximum as number` | Draft 6 | ✅ Supported | Numeric `exclusiveMinimum`/`exclusiveMaximum` (boolean in Draft 4) |
109109
| `readOnly/writeOnly` | Draft 7 | ✅ Supported | Field visibility hints for read-only and write-only properties |
110+
| `const` | Draft 6 | ✅ Supported | Single constant value constraint |
111+
| `propertyNames` | Draft 6 | ✅ Supported | Dict key type constraints via pattern, enum, or $ref |
112+
| `contains` | Draft 6 | ❌ Not Supported | Array contains at least one matching item |
113+
| `deprecated` | 2019-09 | ⚠️ Partial | Marks schema elements as deprecated |
114+
| `if/then/else` | Draft 7 | ❌ Not Supported | Conditional schema validation |
115+
| `contentMediaType/contentEncoding` | Draft 7 | ❌ Not Supported | Content type and encoding hints for strings |
116+
| `$anchor` | 2019-09 | ❌ Not Supported | Location-independent schema references |
117+
| `$vocabulary` | 2019-09 | ❌ Not Supported | Vocabulary declarations for meta-schemas |
118+
| `unevaluatedProperties` | 2019-09 | ❌ Not Supported | Additional properties not evaluated by subschemas |
119+
| `unevaluatedItems` | 2019-09 | ❌ Not Supported | Additional items not evaluated by subschemas |
120+
| `dependentRequired` | 2019-09 | ❌ Not Supported | Conditional property requirements |
121+
| `dependentSchemas` | 2019-09 | ❌ Not Supported | Conditional schema application based on property presence |
122+
| `$dynamicRef/$dynamicAnchor` | 2020-12 | ❌ Not Supported | Dynamic reference resolution across schemas |
110123

111124
#### OpenAPI-Specific Features
112125

113126
| Feature | Introduced | Status | Description |
114127
|---------|------------|--------|-------------|
115128
| `nullable` | OAS 3.0 | ✅ Supported | Uses `nullable: true` for nullable types (deprecated in 3.1) |
116129
| `discriminator` | OAS 3.0 | ✅ Supported | Polymorphism support via `discriminator` keyword |
130+
| `webhooks` | OAS 3.1 | ✅ Supported | Top-level webhooks object for incoming events |
131+
| `$ref with sibling keywords` | OAS 3.1 | ⚠️ Partial | $ref can coexist with description, summary (no allOf workaround) |
132+
| `xml` | OAS 3.0 | ❌ Not Supported | XML serialization metadata (name, namespace, prefix) |
133+
| `externalDocs` | OAS 3.0 | ❌ Not Supported | Reference to external documentation |
134+
| `links` | OAS 3.0 | ❌ Not Supported | Links between operations |
135+
| `callbacks` | OAS 3.0 | ❌ Not Supported | Callback definitions for webhooks |
136+
| `securitySchemes` | OAS 3.0 | ❌ Not Supported | API security mechanism definitions |
117137
<!-- END AUTO-GENERATED SUPPORTED FEATURES -->
118138

119139
## Data Format Support

src/datamodel_code_generator/parser/schema_version.py

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,125 @@ class JsonSchemaFeatures:
118118
status="supported",
119119
),
120120
)
121+
# --- Partially supported features ---
122+
const_support: bool = field(
123+
default=True,
124+
metadata=FeatureMetadata(
125+
introduced="Draft 6",
126+
doc_name="const",
127+
description="Single constant value constraint",
128+
status="supported",
129+
),
130+
)
131+
property_names: bool = field(
132+
default=True,
133+
metadata=FeatureMetadata(
134+
introduced="Draft 6",
135+
doc_name="propertyNames",
136+
description="Dict key type constraints via pattern, enum, or $ref",
137+
status="supported",
138+
),
139+
)
140+
contains: bool = field(
141+
default=False,
142+
metadata=FeatureMetadata(
143+
introduced="Draft 6",
144+
doc_name="contains",
145+
description="Array contains at least one matching item",
146+
status="not_supported",
147+
),
148+
)
149+
deprecated_keyword: bool = field(
150+
default=False,
151+
metadata=FeatureMetadata(
152+
introduced="2019-09",
153+
doc_name="deprecated",
154+
description="Marks schema elements as deprecated",
155+
status="partial",
156+
),
157+
)
158+
# --- Unsupported features ---
159+
if_then_else: bool = field(
160+
default=False,
161+
metadata=FeatureMetadata(
162+
introduced="Draft 7",
163+
doc_name="if/then/else",
164+
description="Conditional schema validation",
165+
status="not_supported",
166+
),
167+
)
168+
content_encoding: bool = field(
169+
default=False,
170+
metadata=FeatureMetadata(
171+
introduced="Draft 7",
172+
doc_name="contentMediaType/contentEncoding",
173+
description="Content type and encoding hints for strings",
174+
status="not_supported",
175+
),
176+
)
177+
anchor: bool = field(
178+
default=False,
179+
metadata=FeatureMetadata(
180+
introduced="2019-09",
181+
doc_name="$anchor",
182+
description="Location-independent schema references",
183+
status="not_supported",
184+
),
185+
)
186+
vocabulary: bool = field(
187+
default=False,
188+
metadata=FeatureMetadata(
189+
introduced="2019-09",
190+
doc_name="$vocabulary",
191+
description="Vocabulary declarations for meta-schemas",
192+
status="not_supported",
193+
),
194+
)
195+
unevaluated_properties: bool = field(
196+
default=False,
197+
metadata=FeatureMetadata(
198+
introduced="2019-09",
199+
doc_name="unevaluatedProperties",
200+
description="Additional properties not evaluated by subschemas",
201+
status="not_supported",
202+
),
203+
)
204+
unevaluated_items: bool = field(
205+
default=False,
206+
metadata=FeatureMetadata(
207+
introduced="2019-09",
208+
doc_name="unevaluatedItems",
209+
description="Additional items not evaluated by subschemas",
210+
status="not_supported",
211+
),
212+
)
213+
dependent_required: bool = field(
214+
default=False,
215+
metadata=FeatureMetadata(
216+
introduced="2019-09",
217+
doc_name="dependentRequired",
218+
description="Conditional property requirements",
219+
status="not_supported",
220+
),
221+
)
222+
dependent_schemas: bool = field(
223+
default=False,
224+
metadata=FeatureMetadata(
225+
introduced="2019-09",
226+
doc_name="dependentSchemas",
227+
description="Conditional schema application based on property presence",
228+
status="not_supported",
229+
),
230+
)
231+
dynamic_ref: bool = field(
232+
default=False,
233+
metadata=FeatureMetadata(
234+
introduced="2020-12",
235+
doc_name="$dynamicRef/$dynamicAnchor",
236+
description="Dynamic reference resolution across schemas",
237+
status="not_supported",
238+
),
239+
)
121240

122241
@classmethod
123242
def from_version(cls, version: JsonSchemaVersion) -> JsonSchemaFeatures:
@@ -133,6 +252,8 @@ def from_version(cls, version: JsonSchemaVersion) -> JsonSchemaFeatures:
133252
definitions_key="definitions",
134253
exclusive_as_number=False,
135254
read_only_write_only=False,
255+
const_support=False,
256+
property_names=False,
136257
)
137258
case JsonSchemaVersion.Draft6:
138259
return cls(
@@ -208,6 +329,71 @@ class OpenAPISchemaFeatures(JsonSchemaFeatures):
208329
status="supported",
209330
),
210331
)
332+
webhooks: bool = field(
333+
default=False,
334+
metadata=FeatureMetadata(
335+
introduced="OAS 3.1",
336+
doc_name="webhooks",
337+
description="Top-level webhooks object for incoming events",
338+
status="supported",
339+
),
340+
)
341+
# --- Partially supported features ---
342+
ref_sibling_keywords: bool = field(
343+
default=False,
344+
metadata=FeatureMetadata(
345+
introduced="OAS 3.1",
346+
doc_name="$ref with sibling keywords",
347+
description="$ref can coexist with description, summary (no allOf workaround)",
348+
status="partial",
349+
),
350+
)
351+
# --- Unsupported features ---
352+
xml_support: bool = field(
353+
default=False,
354+
metadata=FeatureMetadata(
355+
introduced="OAS 3.0",
356+
doc_name="xml",
357+
description="XML serialization metadata (name, namespace, prefix)",
358+
status="not_supported",
359+
),
360+
)
361+
external_docs: bool = field(
362+
default=False,
363+
metadata=FeatureMetadata(
364+
introduced="OAS 3.0",
365+
doc_name="externalDocs",
366+
description="Reference to external documentation",
367+
status="not_supported",
368+
),
369+
)
370+
links: bool = field(
371+
default=False,
372+
metadata=FeatureMetadata(
373+
introduced="OAS 3.0",
374+
doc_name="links",
375+
description="Links between operations",
376+
status="not_supported",
377+
),
378+
)
379+
callbacks: bool = field(
380+
default=False,
381+
metadata=FeatureMetadata(
382+
introduced="OAS 3.0",
383+
doc_name="callbacks",
384+
description="Callback definitions for webhooks",
385+
status="not_supported",
386+
),
387+
)
388+
security_schemes: bool = field(
389+
default=False,
390+
metadata=FeatureMetadata(
391+
introduced="OAS 3.0",
392+
doc_name="securitySchemes",
393+
description="API security mechanism definitions",
394+
status="not_supported",
395+
),
396+
)
211397

212398
@classmethod
213399
def from_openapi_version(cls, version: OpenAPIVersion) -> OpenAPISchemaFeatures:
@@ -238,6 +424,8 @@ def from_openapi_version(cls, version: OpenAPIVersion) -> OpenAPISchemaFeatures:
238424
read_only_write_only=True,
239425
nullable_keyword=False,
240426
discriminator_support=True,
427+
webhooks=True,
428+
ref_sibling_keywords=True,
241429
)
242430

243431

tests/parser/test_schema_version.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ def test_jsonschema_features_draft4() -> None:
110110
JsonSchemaFeatures(
111111
null_in_type_array=False,
112112
defs_not_definitions=False,
113+
const_support=False,
114+
property_names=False,
113115
prefix_items=False,
114116
boolean_schemas=False,
115117
id_field="id",
@@ -235,6 +237,8 @@ def test_openapi_features_v31() -> None:
235237
boolean_schemas=True,
236238
id_field="$id",
237239
definitions_key="$defs",
240+
webhooks=True,
241+
ref_sibling_keywords=True,
238242
exclusive_as_number=True,
239243
read_only_write_only=True,
240244
nullable_keyword=False,
@@ -253,6 +257,8 @@ def test_openapi_features_auto() -> None:
253257
boolean_schemas=True,
254258
id_field="$id",
255259
definitions_key="$defs",
260+
webhooks=True,
261+
ref_sibling_keywords=True,
256262
exclusive_as_number=True,
257263
read_only_write_only=True,
258264
nullable_keyword=False,

0 commit comments

Comments
 (0)