diff --git a/dist/compatible/schemas/instruction.yaml b/dist/compatible/schemas/instruction.yaml index 7d6e0a8..11f755c 100644 --- a/dist/compatible/schemas/instruction.yaml +++ b/dist/compatible/schemas/instruction.yaml @@ -46,7 +46,6 @@ components: content: $ref: ./content.yaml#/components/schemas/ContentUnion entryId: - pattern: ^[a-z\-]+[0-9]+$ type: string sortIndex: pattern: '[0-9]+$' diff --git a/dist/docs/schemas/instruction.yaml b/dist/docs/schemas/instruction.yaml index 7d6e0a8..11f755c 100644 --- a/dist/docs/schemas/instruction.yaml +++ b/dist/docs/schemas/instruction.yaml @@ -46,7 +46,6 @@ components: content: $ref: ./content.yaml#/components/schemas/ContentUnion entryId: - pattern: ^[a-z\-]+[0-9]+$ type: string sortIndex: pattern: '[0-9]+$' diff --git a/src/openapi/schemas/instruction.yaml b/src/openapi/schemas/instruction.yaml index 5531961..7ec2e67 100644 --- a/src/openapi/schemas/instruction.yaml +++ b/src/openapi/schemas/instruction.yaml @@ -162,7 +162,7 @@ components: $ref: "./content.yaml#/components/schemas/ContentUnion" entryId: type: string - pattern: '^[a-z\-]+[0-9]+$' + # pattern: '^[a-z\-]+[0-9]+$' sortIndex: type: string pattern: "[0-9]+$" diff --git a/tools/hooks.py b/tools/hooks.py index 00bbdb8..03effcb 100644 --- a/tools/hooks.py +++ b/tools/hooks.py @@ -109,6 +109,23 @@ class RemoveDiscriminator(SchemasHookBase): return value +class ReplaceLegacyDiscriminator(SchemasHookBase): + def hook(self, value: dict): + if value.get("oneOf") is not None: + value = { + "type": "object", + "example": ",".join( + list(x["$ref"].split("/")[-1] for x in value["oneOf"]) + ), + # "required": [value["discriminator"]["propertyName"]], + "properties": { + f"oneOf_schema_{x}_validator": y + for x, y in enumerate(value["oneOf"]) + }, + } + return value + + # RequestHookBase extends