Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export class CodeGenConfig {
extractResponseError = false;
extractResponses = false;
extractEnums = false;
doNotMatchUnnamedTypesByContent = false;
fileNames = {
dataContracts: "data-contracts",
routeTypes: "route-types",
Expand Down
23 changes: 19 additions & 4 deletions src/schema-routes/schema-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,7 @@ export class SchemaRoutes {
operationId,
defaultType,
typeName,
doNotMatchUnnamedTypesByContent,
}) => {
// TODO: make more flexible pick schema without content type
const schema = this.getSchemaFromRequestType(requestInfo);
Expand All @@ -364,9 +365,11 @@ export class SchemaRoutes {
(parsedSchema) =>
this.typeNameFormatter.format(parsedSchema.name) === content,
);
const foundSchemaByContent = parsedSchemas.find((parsedSchema) =>
lodash.isEqual(parsedSchema.content, content),
);
const foundSchemaByContent = doNotMatchUnnamedTypesByContent
? null
: parsedSchemas.find((parsedSchema) =>
lodash.isEqual(parsedSchema.content, content),
);

const foundSchema = foundedSchemaByName || foundSchemaByContent;

Expand Down Expand Up @@ -412,6 +415,7 @@ export class SchemaRoutes {
parsedSchemas,
operationId,
defaultType,
doNotMatchUnnamedTypesByContent,
}) =>
lodash.reduce(
requestInfos,
Expand All @@ -432,6 +436,7 @@ export class SchemaRoutes {
parsedSchemas,
operationId,
defaultType,
doNotMatchUnnamedTypesByContent,
}),
),
description:
Expand Down Expand Up @@ -460,6 +465,8 @@ export class SchemaRoutes {
parsedSchemas,
operationId,
defaultType: this.config.defaultResponseType,
doNotMatchUnnamedTypesByContent:
this.config.doNotMatchUnnamedTypesByContent,
});

const successResponse = responseInfos.find(
Expand Down Expand Up @@ -538,7 +545,13 @@ export class SchemaRoutes {
);
};

getRequestBodyInfo = (routeInfo, routeParams, parsedSchemas, routeName) => {
getRequestBodyInfo = (
routeInfo,
routeParams,
parsedSchemas,
routeName,
doNotMatchUnnamedTypesByContent,
) => {
const { requestBody, consumes, requestBodyName, operationId } = routeInfo;
let schema = null;
let content = null;
Expand Down Expand Up @@ -583,6 +596,7 @@ export class SchemaRoutes {
parsedSchemas,
operationId,
typeName,
doNotMatchUnnamedTypesByContent,
}),
);

Expand Down Expand Up @@ -943,6 +957,7 @@ export class SchemaRoutes {
routeParams,
parsedSchemas,
routeName,
this.config.doNotMatchUnnamedTypesByContent,
);

const requestParamsSchema = this.createRequestParamsSchema({
Expand Down