UNPKG

@techntools/sequelize-to-openapi

Version:
72 lines (71 loc) 2.4 kB
import { Model, Association, type ModelAttributeColumnOptions } from 'sequelize'; import OpenApiStrategy from './strategies/openapi'; export type ModelContainer = { type: string; properties?: {}; required?: string[]; additionalProperties: boolean; }; export type ModelOptions = { include?: string[]; exclude?: string[]; associations?: boolean; includeAssociations?: string[]; excludeAssociations?: string[]; }; export default class SchemaManager { generate(model: typeof Model, strategy: OpenApiStrategy, options?: ModelOptions): ModelContainer; private verifyStrategy; private verifyModelOptions; private verifyModel; private getAttributes; private getModelContainer; private getAttributeContainer; isRequiredProperty(attributeProperties: ModelAttributeColumnOptions): boolean; getAttributeExamples(attributeProperties: ModelAttributeColumnOptions): { example: any[]; }; getPropertyReadOrWriteOnly(attributeName: string, attributeProperties: ModelAttributeColumnOptions): { readOnly: boolean; writeOnly?: undefined; } | { writeOnly: boolean; readOnly?: undefined; }; getAttributePropertyDescription(attributeName: string, attributeProperties: ModelAttributeColumnOptions): { description: any; }; getCustomPropertyValue(propertyName: string, attributeProperties: ModelAttributeColumnOptions): any; getAttributePropertyTypeOverride(attributeName: string, attributeProperties: ModelAttributeColumnOptions): ModelContainer; getModelPropertyForAssociation(associationName: string, association: Association): { [x: string]: { $ref: string; }; } | { [x: string]: { type: string; items: { $ref: string; }; }; } | { [x: string]: { type: string; items: { allOf: ({ $ref: string; type?: undefined; properties?: undefined; } | { type: string; properties: { [x: number]: { $ref: string; }; }; $ref?: undefined; })[]; }; }; }; }