Skip to content

Commit

Permalink
fix: support inline bigint type (query, params)
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Jun 29, 2023
1 parent e259371 commit 6f2ec41
Showing 1 changed file with 21 additions and 14 deletions.
35 changes: 21 additions & 14 deletions lib/services/schema-object-factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ export class SchemaObjectFactory {
type: 'string'
};
}
if (this.isBigInt(param.type as Function)) {
return {
format: 'int64',
...param,
type: 'integer'
};
}
if (isFunction(param.type)) {
const propertiesWithType = this.extractPropertiesFromType(
param.type,
Expand Down Expand Up @@ -249,10 +256,10 @@ export class SchemaObjectFactory {
if (!(enumName in schemas)) {
const _enum = param.enum
? param.enum
: param.schema ?
(param.schema['items']
? param.schema['items']['enum']
: param.schema['enum'])
: param.schema
? param.schema['items']
? param.schema['items']['enum']
: param.schema['enum']
: param.isArray && param.items
? param.items.enum
: undefined;
Expand Down Expand Up @@ -469,28 +476,28 @@ export class SchemaObjectFactory {
pendingSchemaRefs: string[],
nestedArrayType?: unknown
) {
const trueType = nestedArrayType || metadata.type;
if (this.isObjectLiteral(trueType as Record<string, any>)) {
const typeRef = nestedArrayType || metadata.type;
if (this.isObjectLiteral(typeRef as Record<string, any>)) {
return this.createFromObjectLiteral(
key,
trueType as Record<string, any>,
typeRef as Record<string, any>,
schemas
);
}
if (isString(trueType)) {
if (isString(typeRef)) {
if (isEnumMetadata(metadata)) {
return this.createEnumSchemaType(key, metadata, schemas);
}
if (metadata.isArray) {
return this.transformToArraySchemaProperty(metadata, key, trueType);
return this.transformToArraySchemaProperty(metadata, key, typeRef);
}

return {
...metadata,
name: metadata.name || key
};
}
if (isDateCtor(trueType as Function)) {
if (isDateCtor(typeRef as Function)) {
if (metadata.isArray) {
return this.transformToArraySchemaProperty(metadata, key, {
format: metadata.format || 'date-time',
Expand All @@ -504,24 +511,24 @@ export class SchemaObjectFactory {
name: metadata.name || key
};
}
if (this.isBigInt(trueType as Function)) {
if (this.isBigInt(typeRef as Function)) {
return {
format: 'int64',
...metadata,
type: 'integer',
name: metadata.name || key
};
}
if (!isBuiltInType(trueType as Function)) {
if (!isBuiltInType(typeRef as Function)) {
return this.createNotBuiltInTypeReference(
key,
metadata,
trueType,
typeRef,
schemas,
pendingSchemaRefs
);
}
const typeName = this.getTypeName(trueType as Type<unknown>);
const typeName = this.getTypeName(typeRef as Type<unknown>);
const itemType = this.swaggerTypesMapper.mapTypeToOpenAPIType(typeName);
if (metadata.isArray) {
return this.transformToArraySchemaProperty(metadata, key, {
Expand Down

0 comments on commit 6f2ec41

Please sign in to comment.