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? |
Answered by
ismaildasci
Jan 17, 2026
Replies: 2 comments
|
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 |
0 replies
Answer selected by
zdila
|
Thanks for the report. This is a valid boundary mismatch between typia's emended schema representation and raw OpenAPI SchemaObject typing. I opened a fix in #2001:
I will leave this discussion open until the PR is merged. |
0 replies
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…