diff --git a/docs/llms-full.txt b/docs/llms-full.txt index 18eb32f88..879227140 100644 --- a/docs/llms-full.txt +++ b/docs/llms-full.txt @@ -24161,6 +24161,19 @@ The following features are tracked in the codebase with their implementation sta | `definitions/$defs` | Draft 4 | ✅ Supported | Key for reusable schema definitions | | `exclusiveMinimum/Maximum as number` | Draft 6 | ✅ Supported | Numeric `exclusiveMinimum`/`exclusiveMaximum` (boolean in Draft 4) | | `readOnly/writeOnly` | Draft 7 | ✅ Supported | Field visibility hints for read-only and write-only properties | +| `const` | Draft 6 | ✅ Supported | Single constant value constraint | +| `propertyNames` | Draft 6 | ✅ Supported | Dict key type constraints via pattern, enum, or $ref | +| `contains` | Draft 6 | ❌ Not Supported | Array contains at least one matching item | +| `deprecated` | 2019-09 | ⚠️ Partial | Marks schema elements as deprecated | +| `if/then/else` | Draft 7 | ❌ Not Supported | Conditional schema validation | +| `contentMediaType/contentEncoding` | Draft 7 | ❌ Not Supported | Content type and encoding hints for strings | +| `$anchor` | 2019-09 | ❌ Not Supported | Location-independent schema references | +| `$vocabulary` | 2019-09 | ❌ Not Supported | Vocabulary declarations for meta-schemas | +| `unevaluatedProperties` | 2019-09 | ❌ Not Supported | Additional properties not evaluated by subschemas | +| `unevaluatedItems` | 2019-09 | ❌ Not Supported | Additional items not evaluated by subschemas | +| `dependentRequired` | 2019-09 | ❌ Not Supported | Conditional property requirements | +| `dependentSchemas` | 2019-09 | ❌ Not Supported | Conditional schema application based on property presence | +| `$dynamicRef/$dynamicAnchor` | 2020-12 | ❌ Not Supported | Dynamic reference resolution across schemas | #### OpenAPI-Specific Features @@ -24168,6 +24181,13 @@ The following features are tracked in the codebase with their implementation sta |---------|------------|--------|-------------| | `nullable` | OAS 3.0 | ✅ Supported | Uses `nullable: true` for nullable types (deprecated in 3.1) | | `discriminator` | OAS 3.0 | ✅ Supported | Polymorphism support via `discriminator` keyword | +| `webhooks` | OAS 3.1 | ✅ Supported | Top-level webhooks object for incoming events | +| `$ref with sibling keywords` | OAS 3.1 | ⚠️ Partial | $ref can coexist with description, summary (no allOf workaround) | +| `xml` | OAS 3.0 | ❌ Not Supported | XML serialization metadata (name, namespace, prefix) | +| `externalDocs` | OAS 3.0 | ❌ Not Supported | Reference to external documentation | +| `links` | OAS 3.0 | ❌ Not Supported | Links between operations | +| `callbacks` | OAS 3.0 | ❌ Not Supported | Callback definitions for webhooks | +| `securitySchemes` | OAS 3.0 | ❌ Not Supported | API security mechanism definitions | ## Data Format Support diff --git a/docs/supported_formats.md b/docs/supported_formats.md index ed8e6b039..90e0a5c3f 100644 --- a/docs/supported_formats.md +++ b/docs/supported_formats.md @@ -107,6 +107,19 @@ The following features are tracked in the codebase with their implementation sta | `definitions/$defs` | Draft 4 | ✅ Supported | Key for reusable schema definitions | | `exclusiveMinimum/Maximum as number` | Draft 6 | ✅ Supported | Numeric `exclusiveMinimum`/`exclusiveMaximum` (boolean in Draft 4) | | `readOnly/writeOnly` | Draft 7 | ✅ Supported | Field visibility hints for read-only and write-only properties | +| `const` | Draft 6 | ✅ Supported | Single constant value constraint | +| `propertyNames` | Draft 6 | ✅ Supported | Dict key type constraints via pattern, enum, or $ref | +| `contains` | Draft 6 | ❌ Not Supported | Array contains at least one matching item | +| `deprecated` | 2019-09 | ⚠️ Partial | Marks schema elements as deprecated | +| `if/then/else` | Draft 7 | ❌ Not Supported | Conditional schema validation | +| `contentMediaType/contentEncoding` | Draft 7 | ❌ Not Supported | Content type and encoding hints for strings | +| `$anchor` | 2019-09 | ❌ Not Supported | Location-independent schema references | +| `$vocabulary` | 2019-09 | ❌ Not Supported | Vocabulary declarations for meta-schemas | +| `unevaluatedProperties` | 2019-09 | ❌ Not Supported | Additional properties not evaluated by subschemas | +| `unevaluatedItems` | 2019-09 | ❌ Not Supported | Additional items not evaluated by subschemas | +| `dependentRequired` | 2019-09 | ❌ Not Supported | Conditional property requirements | +| `dependentSchemas` | 2019-09 | ❌ Not Supported | Conditional schema application based on property presence | +| `$dynamicRef/$dynamicAnchor` | 2020-12 | ❌ Not Supported | Dynamic reference resolution across schemas | #### OpenAPI-Specific Features @@ -114,6 +127,13 @@ The following features are tracked in the codebase with their implementation sta |---------|------------|--------|-------------| | `nullable` | OAS 3.0 | ✅ Supported | Uses `nullable: true` for nullable types (deprecated in 3.1) | | `discriminator` | OAS 3.0 | ✅ Supported | Polymorphism support via `discriminator` keyword | +| `webhooks` | OAS 3.1 | ✅ Supported | Top-level webhooks object for incoming events | +| `$ref with sibling keywords` | OAS 3.1 | ⚠️ Partial | $ref can coexist with description, summary (no allOf workaround) | +| `xml` | OAS 3.0 | ❌ Not Supported | XML serialization metadata (name, namespace, prefix) | +| `externalDocs` | OAS 3.0 | ❌ Not Supported | Reference to external documentation | +| `links` | OAS 3.0 | ❌ Not Supported | Links between operations | +| `callbacks` | OAS 3.0 | ❌ Not Supported | Callback definitions for webhooks | +| `securitySchemes` | OAS 3.0 | ❌ Not Supported | API security mechanism definitions | ## Data Format Support diff --git a/src/datamodel_code_generator/parser/schema_version.py b/src/datamodel_code_generator/parser/schema_version.py index 240e029d6..f7afc8fbe 100644 --- a/src/datamodel_code_generator/parser/schema_version.py +++ b/src/datamodel_code_generator/parser/schema_version.py @@ -118,6 +118,125 @@ class JsonSchemaFeatures: status="supported", ), ) + # --- Partially supported features --- + const_support: bool = field( + default=True, + metadata=FeatureMetadata( + introduced="Draft 6", + doc_name="const", + description="Single constant value constraint", + status="supported", + ), + ) + property_names: bool = field( + default=True, + metadata=FeatureMetadata( + introduced="Draft 6", + doc_name="propertyNames", + description="Dict key type constraints via pattern, enum, or $ref", + status="supported", + ), + ) + contains: bool = field( + default=False, + metadata=FeatureMetadata( + introduced="Draft 6", + doc_name="contains", + description="Array contains at least one matching item", + status="not_supported", + ), + ) + deprecated_keyword: bool = field( + default=False, + metadata=FeatureMetadata( + introduced="2019-09", + doc_name="deprecated", + description="Marks schema elements as deprecated", + status="partial", + ), + ) + # --- Unsupported features --- + if_then_else: bool = field( + default=False, + metadata=FeatureMetadata( + introduced="Draft 7", + doc_name="if/then/else", + description="Conditional schema validation", + status="not_supported", + ), + ) + content_encoding: bool = field( + default=False, + metadata=FeatureMetadata( + introduced="Draft 7", + doc_name="contentMediaType/contentEncoding", + description="Content type and encoding hints for strings", + status="not_supported", + ), + ) + anchor: bool = field( + default=False, + metadata=FeatureMetadata( + introduced="2019-09", + doc_name="$anchor", + description="Location-independent schema references", + status="not_supported", + ), + ) + vocabulary: bool = field( + default=False, + metadata=FeatureMetadata( + introduced="2019-09", + doc_name="$vocabulary", + description="Vocabulary declarations for meta-schemas", + status="not_supported", + ), + ) + unevaluated_properties: bool = field( + default=False, + metadata=FeatureMetadata( + introduced="2019-09", + doc_name="unevaluatedProperties", + description="Additional properties not evaluated by subschemas", + status="not_supported", + ), + ) + unevaluated_items: bool = field( + default=False, + metadata=FeatureMetadata( + introduced="2019-09", + doc_name="unevaluatedItems", + description="Additional items not evaluated by subschemas", + status="not_supported", + ), + ) + dependent_required: bool = field( + default=False, + metadata=FeatureMetadata( + introduced="2019-09", + doc_name="dependentRequired", + description="Conditional property requirements", + status="not_supported", + ), + ) + dependent_schemas: bool = field( + default=False, + metadata=FeatureMetadata( + introduced="2019-09", + doc_name="dependentSchemas", + description="Conditional schema application based on property presence", + status="not_supported", + ), + ) + dynamic_ref: bool = field( + default=False, + metadata=FeatureMetadata( + introduced="2020-12", + doc_name="$dynamicRef/$dynamicAnchor", + description="Dynamic reference resolution across schemas", + status="not_supported", + ), + ) @classmethod def from_version(cls, version: JsonSchemaVersion) -> JsonSchemaFeatures: @@ -133,6 +252,8 @@ def from_version(cls, version: JsonSchemaVersion) -> JsonSchemaFeatures: definitions_key="definitions", exclusive_as_number=False, read_only_write_only=False, + const_support=False, + property_names=False, ) case JsonSchemaVersion.Draft6: return cls( @@ -208,6 +329,71 @@ class OpenAPISchemaFeatures(JsonSchemaFeatures): status="supported", ), ) + webhooks: bool = field( + default=False, + metadata=FeatureMetadata( + introduced="OAS 3.1", + doc_name="webhooks", + description="Top-level webhooks object for incoming events", + status="supported", + ), + ) + # --- Partially supported features --- + ref_sibling_keywords: bool = field( + default=False, + metadata=FeatureMetadata( + introduced="OAS 3.1", + doc_name="$ref with sibling keywords", + description="$ref can coexist with description, summary (no allOf workaround)", + status="partial", + ), + ) + # --- Unsupported features --- + xml_support: bool = field( + default=False, + metadata=FeatureMetadata( + introduced="OAS 3.0", + doc_name="xml", + description="XML serialization metadata (name, namespace, prefix)", + status="not_supported", + ), + ) + external_docs: bool = field( + default=False, + metadata=FeatureMetadata( + introduced="OAS 3.0", + doc_name="externalDocs", + description="Reference to external documentation", + status="not_supported", + ), + ) + links: bool = field( + default=False, + metadata=FeatureMetadata( + introduced="OAS 3.0", + doc_name="links", + description="Links between operations", + status="not_supported", + ), + ) + callbacks: bool = field( + default=False, + metadata=FeatureMetadata( + introduced="OAS 3.0", + doc_name="callbacks", + description="Callback definitions for webhooks", + status="not_supported", + ), + ) + security_schemes: bool = field( + default=False, + metadata=FeatureMetadata( + introduced="OAS 3.0", + doc_name="securitySchemes", + description="API security mechanism definitions", + status="not_supported", + ), + ) @classmethod def from_openapi_version(cls, version: OpenAPIVersion) -> OpenAPISchemaFeatures: @@ -238,6 +424,8 @@ def from_openapi_version(cls, version: OpenAPIVersion) -> OpenAPISchemaFeatures: read_only_write_only=True, nullable_keyword=False, discriminator_support=True, + webhooks=True, + ref_sibling_keywords=True, ) diff --git a/tests/parser/test_schema_version.py b/tests/parser/test_schema_version.py index eb99402b5..3745435d9 100644 --- a/tests/parser/test_schema_version.py +++ b/tests/parser/test_schema_version.py @@ -110,6 +110,8 @@ def test_jsonschema_features_draft4() -> None: JsonSchemaFeatures( null_in_type_array=False, defs_not_definitions=False, + const_support=False, + property_names=False, prefix_items=False, boolean_schemas=False, id_field="id", @@ -235,6 +237,8 @@ def test_openapi_features_v31() -> None: boolean_schemas=True, id_field="$id", definitions_key="$defs", + webhooks=True, + ref_sibling_keywords=True, exclusive_as_number=True, read_only_write_only=True, nullable_keyword=False, @@ -253,6 +257,8 @@ def test_openapi_features_auto() -> None: boolean_schemas=True, id_field="$id", definitions_key="$defs", + webhooks=True, + ref_sibling_keywords=True, exclusive_as_number=True, read_only_write_only=True, nullable_keyword=False,