-
Notifications
You must be signed in to change notification settings - Fork 64
Closed
Description
Finding type issues while using routing-controllers-openapi:v4.0.0 with latest class-validator-jsonschema .
public buildSpec() {
const {defaultMetadataStorage} = require('class-transformer/cjs/storage');
const routingControllersOptions = {
routePrefix: '/api',
};
const storage = getMetadataArgsStorage();
const schemas = validationMetadatasToSchemas({
classTransformerMetadataStorage: defaultMetadataStorage,
refPointerPrefix: '#/components/schemas/',
});
// storage.controllers = storage.controllers.filter(c => this.isDisplayed(c.target));
// storage.actions = storage.actions.filter(c => this.isDisplayed(c.target));
const spec = routingControllersToSpec(storage, routingControllersOptions, {
components: {
schemas,
securitySchemes: {
basicAuth: {
scheme: 'basic',
type: 'http',
},
},
},
info: {
title: 'API schema',
version: 'v1',
},
});
return spec;
}
[ERROR] 17:41:10 ⨯ Unable to compile TypeScript:
src/service/OpenApi.ts(24,9): error TS2322: Type 'Record<string, SchemaObject>' is not assignable to type '{ [schema: string]: ReferenceObject | SchemaObject; }'.
'string' index signatures are incompatible.
Type 'SchemaObject' is not assignable to type 'ReferenceObject | SchemaObject'.
Type 'import("/Users/apple/work/byg/byg-admin-core/node_modules/class-validator-jsonschema/node_modules/openapi3-ts/dist/mjs/model/OpenApi").SchemaObject' is not assignable to type 'import("/Users/apple/work/byg/byg-admin-core/node_modules/openapi3-ts/dist/model/OpenApi").SchemaObject'.
Types of property 'type' are incompatible.
Type 'SchemaObjectType | SchemaObjectType[] | undefined' is not assignable to type '"string" | "number" | "boolean" | "object" | "integer" | "null" | "array" | undefined'.
Type 'SchemaObjectType[]' is not assignable to type '"string" | "number" | "boolean" | "object" | "integer" | "null" | "array" | undefined'.
I think, openapi3-ts dependency needs an upgrade, it currently conflicts with its counterpart in class-validator-jsonschema.
(ps: Type assertions are a workaround.)
Luccazx12, NilsBensmann, bhupesh-js, binura-g, TechQuery and 1 more
Metadata
Metadata
Assignees
Labels
No labels