Skip to content

Commit

Permalink
fix(express): support no optional properties (#4733)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsinghvi committed Sep 24, 2024
1 parent 3d27595 commit 08c0d1a
Show file tree
Hide file tree
Showing 232 changed files with 6,087 additions and 6 deletions.
7 changes: 5 additions & 2 deletions generators/typescript/express/cli/src/ExpressGeneratorCli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { NpmPackage, PersistedTypescriptProject } from "@fern-typescript/commons
import { GeneratorContext } from "@fern-typescript/contexts";
import { ExpressGenerator } from "@fern-typescript/express-generator";
import { camelCase, upperFirst } from "lodash-es";
import { custom } from "zod";
import { ExpressCustomConfig } from "./custom-config/ExpressCustomConfig";
import { ExpressCustomConfigSchema } from "./custom-config/schema/ExpressCustomConfigSchema";

Expand All @@ -27,7 +28,8 @@ export class ExpressGeneratorCli extends AbstractGeneratorCli<ExpressCustomConfi
allowExtraFields: parsed?.allowExtraFields ?? false,
skipRequestValidation: parsed?.skipRequestValidation ?? false,
skipResponseValidation: parsed?.skipResponseValidation ?? false,
useBigInt: parsed?.useBigInt ?? false
useBigInt: parsed?.useBigInt ?? false,
noOptionalProperties: parsed?.noOptionalProperties ?? false
};
}

Expand Down Expand Up @@ -65,7 +67,8 @@ export class ExpressGeneratorCli extends AbstractGeneratorCli<ExpressCustomConfi
skipRequestValidation: customConfig.skipRequestValidation,
skipResponseValidation: customConfig.skipResponseValidation,
requestValidationStatusCode: customConfig.requestValidationStatusCode,
useBigInt: customConfig.useBigInt
useBigInt: customConfig.useBigInt,
noOptionalProperties: customConfig.noOptionalProperties
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ export interface ExpressCustomConfig {
retainOriginalCasing: boolean;
allowExtraFields: boolean;
useBigInt: boolean;
noOptionalProperties: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const ExpressCustomConfigSchema = z.strictObject({
outputEsm: z.optional(z.boolean()),
requestValidationStatusCode: z.optional(z.number()),
useBigInt: z.optional(z.boolean()),
noOptionalProperties: z.optional(z.boolean()),

// beta (not in docs)
outputSourceFiles: z.optional(z.boolean()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export declare namespace ExpressGenerator {
skipResponseValidation: boolean;
requestValidationStatusCode: number;
useBigInt: boolean;
noOptionalProperties: boolean;
}
}

Expand Down Expand Up @@ -187,11 +188,11 @@ export class ExpressGenerator {
includeOtherInUnionTypes: config.includeOtherInUnionTypes,
includeSerdeLayer: config.includeSerdeLayer,
retainOriginalCasing: config.retainOriginalCasing,
noOptionalProperties: false
noOptionalProperties: config.noOptionalProperties
});
this.typeSchemaGenerator = new TypeSchemaGenerator({
includeUtilsOnUnionMembers: config.includeUtilsOnUnionMembers,
noOptionalProperties: false
noOptionalProperties: config.noOptionalProperties
});
this.typeReferenceExampleGenerator = new TypeReferenceExampleGenerator();
this.expressInlinedRequestBodyGenerator = new ExpressInlinedRequestBodyGenerator();
Expand Down
18 changes: 18 additions & 0 deletions generators/typescript/express/versions.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
- changelogEntry:
- summary: |
Introduces a configuration `noOptionalProperties` which forces consumers to explicitly pass
in `undefined` instead of excluding the key. To turn this setting on, do the following:
```yml generators.yml
groups:
server:
generators:
- name: fernapi/fern-typescript-express
version: 0.17.5
config:
noOptionalProperties: true
```
type: feat
irVersion: 53
version: 0.17.5

- changelogEntry:
- summary: Update inlined request objects to respect `noSerdeLayer`
type: fix
Expand Down
2 changes: 0 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 08c0d1a

Please sign in to comment.