Skip to content

Commit 5fefbcc

Browse files
authored
fix: remove an instance of double normalization (#391)
wasn't causing issues yet, but will do once `IRModel` is no longer compatible with `Schema`, split from #386
1 parent 43cfe2b commit 5fefbcc

File tree

4 files changed

+12
-3
lines changed

4 files changed

+12
-3
lines changed

packages/openapi-code-generator/src/core/input.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,10 @@ export class Input {
8888

8989
return Object.fromEntries(
9090
Object.entries(schemas).map(([name, maybeSchema]) => {
91-
// TODO: double normalization?
92-
return [name, this.schema(this.schemaNormalizer.normalize(maybeSchema))]
91+
const schema = this.schemaNormalizer.normalize(
92+
this.loader.schema(maybeSchema),
93+
)
94+
return [name, schema]
9395
}),
9496
)
9597
}

packages/openapi-code-generator/src/typescript/server/server-operation-builder.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ export class ServerOperationBuilder {
274274
)
275275

276276
const isRequired = Boolean(requestBody?.parameter?.required)
277+
const isSupported = Boolean(requestBody?.isSupported)
277278

278279
const schema = requestBody?.parameter
279280
? this.schemaBuilder.fromModel(
@@ -312,7 +313,7 @@ export class ServerOperationBuilder {
312313
}
313314

314315
return {
315-
isSupported: Boolean(requestBody?.isSupported),
316+
isSupported,
316317
contentType: requestBody?.contentType,
317318
schema,
318319
type,

packages/openapi-code-generator/src/typescript/server/typescript-express/typescript-express-router-builder.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,17 @@ export class ExpressRouterBuilder extends AbstractRouterBuilder {
9494
if (params.path.schema) {
9595
statements.push(constStatement(symbols.paramSchema, params.path.schema))
9696
}
97+
9798
if (params.query.schema) {
9899
statements.push(constStatement(symbols.querySchema, params.query.schema))
99100
}
101+
100102
if (params.header.schema) {
101103
statements.push(
102104
constStatement(symbols.requestHeaderSchema, params.header.schema),
103105
)
104106
}
107+
105108
if (params.body.schema) {
106109
if (!params.body.isSupported) {
107110
statements.push(

packages/openapi-code-generator/src/typescript/server/typescript-koa/typescript-koa-router-builder.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,17 @@ export class KoaRouterBuilder extends AbstractRouterBuilder {
9191
if (params.path.schema) {
9292
statements.push(constStatement(symbols.paramSchema, params.path.schema))
9393
}
94+
9495
if (params.query.schema) {
9596
statements.push(constStatement(symbols.querySchema, params.query.schema))
9697
}
98+
9799
if (params.header.schema) {
98100
statements.push(
99101
constStatement(symbols.requestHeaderSchema, params.header.schema),
100102
)
101103
}
104+
102105
if (params.body.schema) {
103106
if (!params.body.isSupported) {
104107
statements.push(

0 commit comments

Comments
 (0)