-
-
Notifications
You must be signed in to change notification settings - Fork 264
Open
Labels
bug 🔥Something isn't workingSomething isn't workingfeature 🚀New feature or requestNew feature or request
Description
Description
We are trying to combine oneOf + discriminator with transformers, but it seems the transformer code doesn't support it?
Are there any plans to support this combination?
Reproducible example or configuration
openapi-ts --file openapi-ts.config.ts --input openapi.json
openapi-ts.config.ts:
import { defineConfig } from "@hey-api/openapi-ts";
export default defineConfig({
input: "openapi.json",
output: "src/openapi",
plugins: [
"@tanstack/react-query",
{
name: "@hey-api/typescript",
enums: "typescript"
},
{
name: "@hey-api/sdk",
transformer: true
},
{
bigInt: true,
dates: true,
name: "@hey-api/transformers"
}
]
});OpenAPI specification
Without AllOf
{
"openapi": "3.0.4",
"info": {
"title": "pets",
"version": "1.0.0"
},
"paths": {
"/api/pets/{id}": {
"get": {
"operationId": "getPetById",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Animal"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Animal": {
"type": "object",
"oneOf": [{
"$ref": "#/components/schemas/Dog"
}, {
"$ref": "#/components/schemas/Cat"
}
],
"properties": {
"type": {
"type": "string"
}
},
"discriminator": {
"propertyName": "type",
"mapping": {
"dog": "#/components/schemas/Dog",
"cat": "#/components/schemas/Cat"
}
}
},
"Dog": {
"type": "object",
"required": ["type"],
"properties": {
"type": {
"type": "string"
},
"barkVolume": {
"type": "integer"
},
"firstBark": {
"type": "string",
"format": "date-time"
}
}
},
"Cat": {
"type": "object",
"required": ["type"],
"properties": {
"type": {
"type": "string"
},
"whiskerLength": {
"type": "integer"
},
"firstMeow": {
"type": "string",
"format": "date-time"
}
}
}
}
}
}With AllOf
{
"openapi": "3.0.4",
"info": {
"title": "pets",
"version": "1.0.0"
},
"paths": {
"/api/pets/{id}": {
"get": {
"operationId": "getPetById",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Animal"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"Animal": {
"type": "object",
"required": ["type"],
"discriminator": {
"propertyName": "type",
"mapping": {
"dog": "#/components/schemas/Dog",
"cat": "#/components/schemas/Cat"
}
}
},
"Dog": {
"allOf": [
{
"$ref": "#/components/schemas/Animal"
},
{
"type": "object",
"properties": {
"type": {
"type": "string"
},
"barkVolume": {
"type": "integer"
},
"firstBark": {
"type": "string",
"format": "date-time"
}
}
}
]
},
"Cat": {
"allOf": [
{
"$ref": "#/components/schemas/Animal"
},
{
"type": "object",
"properties": {
"type": {
"type": "string"
},
"whiskerLength": {
"type": "integer"
},
"firstMeow": {
"type": "string",
"format": "date-time"
}
}
}
]
}
}
}
}System information (optional)
@hey-api/openapi-ts: 0.86.0
node: 24.10.0
Carr99Copilot
Metadata
Metadata
Assignees
Labels
bug 🔥Something isn't workingSomething isn't workingfeature 🚀New feature or requestNew feature or request