Skip to content

Commit 8f8b488

Browse files
author
Jens Karlsson
committed
renames makeImmutable to immutable
1 parent 25634c6 commit 8f8b488

File tree

10 files changed

+15
-16
lines changed

10 files changed

+15
-16
lines changed

.changeset/real-wombats-dream.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
"swagger-typescript-api": minor
33
---
44

5-
Supports immutable types with --make-immutable or makeImmutable
5+
Supports immutable types with --immutable flag or immutable option

index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ const generateCommand = defineCommand({
8686
description: "generate readonly properties",
8787
default: codeGenBaseConfig.addReadonly,
8888
},
89-
"make-immutable": {
89+
immutable: {
9090
type: "boolean",
9191
description: "makes all properties and values readonly",
92-
default: codeGenBaseConfig.makeImmutable,
92+
default: codeGenBaseConfig.immutable,
9393
},
9494
"another-array-type": {
9595
type: "boolean",
@@ -321,7 +321,7 @@ const generateCommand = defineCommand({
321321
? HTTP_CLIENT.AXIOS
322322
: HTTP_CLIENT.FETCH,
323323
input: path.resolve(process.cwd(), args.path as string),
324-
makeImmutable: args["make-immutable"],
324+
immutable: args["immutable"],
325325
modular: args.modular,
326326
moduleNameFirstTag: args["module-name-first-tag"],
327327
moduleNameIndex: +args["module-name-index"] || 0,

src/configuration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export class CodeGenConfig {
5858
/** CLI flag */
5959
addReadonly = false;
6060
/** CLI flag */
61-
makeImmutable = false;
61+
immutable = false;
6262
enumNamesAsValues = false;
6363
/** parsed swagger schema from getSwaggerObject() */
6464

src/schema-parser/base-schema-parsers/array.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export class ArraySchemaParser extends MonoSchemaParser {
77
const { type, description, items, readOnly } = this.schema || {};
88

99
const readonly =
10-
(readOnly && this.config.addReadonly) || this.config.makeImmutable;
10+
(readOnly && this.config.addReadonly) || this.config.immutable;
1111

1212
if (Array.isArray(items) && type === SCHEMA_TYPES.ARRAY) {
1313
const tupleContent = [];

src/schema-parser/base-schema-parsers/discriminator.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ export class DiscriminatorSchemaParser extends MonoSchemaParser {
8585
ts.ObjectWrapper(
8686
ts.TypeField({
8787
readonly:
88-
(readOnly && this.config.addReadonly) ||
89-
this.config.makeImmutable,
88+
(readOnly && this.config.addReadonly) || this.config.immutable,
9089
key: ts.StringValue(discriminator.propertyName),
9190
value: "Key",
9291
}),
@@ -132,7 +131,7 @@ export class DiscriminatorSchemaParser extends MonoSchemaParser {
132131
ts.TypeField({
133132
readonly:
134133
(mappingSchema.readOnly && this.config.addReadonly) ||
135-
this.config.makeImmutable,
134+
this.config.immutable,
136135
key: discriminator.propertyName,
137136
value: mappingUsageKey,
138137
}),

src/schema-parser/base-schema-parsers/object.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ export class ObjectSchemaParser extends MonoSchemaParser {
7474
value: fieldValue,
7575
field: this.config.Ts.TypeField({
7676
readonly:
77-
(readOnly && this.config.addReadonly) || this.config.makeImmutable,
77+
(readOnly && this.config.addReadonly) || this.config.immutable,
7878
optional: !required,
7979
key: fieldName,
8080
value: fieldValue,
@@ -105,7 +105,7 @@ export class ObjectSchemaParser extends MonoSchemaParser {
105105
field: this.config.Ts.InterfaceDynamicField({
106106
readonly:
107107
(additionalProperties.readOnly && this.config.addReadonly) ||
108-
this.config.makeImmutable,
108+
this.config.immutable,
109109
key: interfaceKeysContent,
110110
value: this.config.Ts.Keyword.Any,
111111
}),

src/schema-parser/base-schema-parsers/primitive.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export class PrimitiveSchemaParser extends MonoSchemaParser {
88
this.schema || {};
99

1010
const readonly =
11-
(readOnly && this.config.addReadonly) || this.config.makeImmutable;
11+
(readOnly && this.config.addReadonly) || this.config.immutable;
1212

1313
if (type === this.config.Ts.Keyword.Object && additionalProperties) {
1414
const propertyNamesSchema = this.schemaUtils.getSchemaPropertyNamesSchema(

src/schema-parser/schema-formatters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ export class SchemaFormatters {
8585
: this.config.Ts.RecordType({
8686
readonly:
8787
(parsedSchema.readOnly && this.config.addReadonly) ||
88-
this.config.makeImmutable,
88+
this.config.immutable,
8989
key: this.config.Ts.Keyword.String,
9090
value: this.config.Ts.Keyword.Any,
9191
}),

tests/spec/readonly-always/basic.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe("basic", async () => {
2121
input: path.resolve(import.meta.dirname, "schema.json"),
2222
output: tmpdir,
2323
silent: true,
24-
makeImmutable: true,
24+
immutable: true,
2525
generateClient: false,
2626
});
2727

@@ -37,7 +37,7 @@ describe("basic", async () => {
3737
input: path.resolve(import.meta.dirname, "schema.json"),
3838
output: tmpdir,
3939
silent: true,
40-
makeImmutable: true,
40+
immutable: true,
4141
generateClient: false,
4242
anotherArrayType: true,
4343
});

types/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ export interface GenerateApiConfiguration {
557557
/** customise code generation constructs */
558558
codeGenConstructs?: (struct: CodeGenConstruct) => Partial<CodeGenConstruct>;
559559
/** extract response body type to data contract */
560-
makeImmutable: boolean;
560+
immutable: boolean;
561561
extractResponseBody: boolean;
562562
/** extract response error type to data contract */
563563
extractResponseError: boolean;

0 commit comments

Comments
 (0)