Wrong type of examples?
#1697
-
|
I combine typia with oRPC OpenAPI and have a typescript error: Typia: const typiaSchemas = json.schemas<[MyType1, MyType2]>();oRPC: new OpenAPIReferencePlugin({
docsProvider: "scalar",
schemaConverters: [new TypiaToJsonSchemaConverter()],
specPath: "/spec.json",
docsPath: "/documentation",
specGenerateOptions: {
info: {
title: "My API",
version: "1.0.0",
},
components: {
schemas: typiaSchemas.components.schemas, // <------ type error
},
},
})Is it a bug or the problem is in my code? |
Beta Was this translation helpful? Give feedback.
Answered by
ismaildasci
Jan 17, 2026
Replies: 1 comment
-
|
this is type mismatch between typia IJsonSchema and OpenAPI SchemaObject. typia uses quick fix - transform the schemas: const typiaSchemas = json.schemas<[MyType1, MyType2]>();
const convertedSchemas = Object.fromEntries(
Object.entries(typiaSchemas.components.schemas).map(([key, schema]) => [
key,
{
...schema,
examples: schema.examples
? Object.values(schema.examples)
: undefined,
},
])
);
new OpenAPIReferencePlugin({
// ...
specGenerateOptions: {
components: {
schemas: convertedSchemas,
},
},
})or use type assertion if you dont use examples: schemas: typiaSchemas.components.schemas as Record<string, SchemaObject>,its not a bug - just different OpenAPI spec versions between libraries |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
zdila
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is type mismatch between typia IJsonSchema and OpenAPI SchemaObject.
typia uses
examplesasRecord<string, any>(OpenAPI 3.0 style) but oRPC expectsany[](OpenAPI 3.1 style).quick fix - transform the schemas:
or use type assertion if you d…