Skip to content

Commit 1b8d5af

Browse files
authored
Merge branch 'main' into enable_openapi_types
2 parents 570e17c + 4031b37 commit 1b8d5af

File tree

10 files changed

+562
-190
lines changed

10 files changed

+562
-190
lines changed

docs/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,4 @@ Get an overview of how to contribute to the project
7474

7575

7676

77+

docs/contributing.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,5 +157,6 @@ Prefix that follows specification is not enough though. Remember that the title
157157

158158

159159

160+
160161

161162

docs/migrations/v0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,4 @@ const subscriber = await jetStreamPullSubscribeToReceiveUserSignedup({
5858
});
5959
```
6060

61+

docs/usage.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ $ npm install -g @the-codegen-project/cli
99
$ codegen COMMAND
1010
running command...
1111
$ codegen (--version)
12-
@the-codegen-project/cli/0.45.0 linux-x64 node-v18.20.8
12+
@the-codegen-project/cli/0.46.0 linux-x64 node-v18.20.8
1313
$ codegen --help [COMMAND]
1414
USAGE
1515
$ codegen COMMAND
@@ -81,7 +81,7 @@ DESCRIPTION
8181
Generate code based on your configuration, use `init` to get started.
8282
```
8383

84-
_See code: [src/commands/generate.ts](https://github.com/the-codegen-project/cli/blob/v0.45.0/src/commands/generate.ts)_
84+
_See code: [src/commands/generate.ts](https://github.com/the-codegen-project/cli/blob/v0.46.0/src/commands/generate.ts)_
8585

8686
## `codegen help [COMMAND]`
8787

@@ -139,7 +139,7 @@ DESCRIPTION
139139
Initialize The Codegen Project in your project
140140
```
141141

142-
_See code: [src/commands/init.ts](https://github.com/the-codegen-project/cli/blob/v0.45.0/src/commands/init.ts)_
142+
_See code: [src/commands/init.ts](https://github.com/the-codegen-project/cli/blob/v0.46.0/src/commands/init.ts)_
143143

144144
## `codegen version`
145145

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@the-codegen-project/cli",
33
"description": "CLI to work with code generation in any environment",
4-
"version": "0.45.0",
4+
"version": "0.46.0",
55
"bin": {
66
"codegen": "./bin/run.mjs"
77
},

schemas/configuration-schema-0.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
{
3434
"$ref": "#/definitions/AsyncAPICodegenConfiguration/properties/generators/items/anyOf/0"
3535
},
36+
{
37+
"$ref": "#/definitions/AsyncAPICodegenConfiguration/properties/generators/items/anyOf/1"
38+
},
3639
{
3740
"$ref": "#/definitions/AsyncAPICodegenConfiguration/properties/generators/items/anyOf/4"
3841
},

src/codegen/generators/typescript/parameters.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
/* eslint-disable security/detect-object-injection */
2-
import {
3-
OutputModel,
4-
TypeScriptFileGenerator
5-
} from '@asyncapi/modelina';
2+
import {OutputModel, TypeScriptFileGenerator} from '@asyncapi/modelina';
63
import {AsyncAPIDocumentInterface} from '@asyncapi/parser';
74
import {GenericCodegenContext, ParameterRenderType} from '../../types';
85
import {z} from 'zod';
@@ -12,7 +9,10 @@ import {
129
processAsyncAPIParameters,
1310
ProcessedParameterSchemaData
1411
} from '../../inputs/asyncapi/generators/parameters';
15-
import {createOpenAPIGenerator, processOpenAPIParameters} from '../../inputs/openapi/generators/parameters';
12+
import {
13+
createOpenAPIGenerator,
14+
processOpenAPIParameters
15+
} from '../../inputs/openapi/generators/parameters';
1616

1717
export const zodTypescriptParametersGenerator = z.object({
1818
id: z.string().optional().default('parameters-typescript'),

src/codegen/inputs/asyncapi/generators/parameters.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
/* eslint-disable security/detect-object-injection */
22
import {AsyncAPIDocumentInterface} from '@asyncapi/parser';
3-
import {defaultCodegenTypescriptModelinaOptions, pascalCase} from '../../../generators/typescript/utils';
3+
import {
4+
defaultCodegenTypescriptModelinaOptions,
5+
pascalCase
6+
} from '../../../generators/typescript/utils';
47
import {findNameFromChannel} from '../../../utils';
5-
import { ConstrainedEnumModel, ConstrainedObjectModel, ConstrainedReferenceModel, TS_DESCRIPTION_PRESET, TypeScriptFileGenerator } from '@asyncapi/modelina';
8+
import {
9+
ConstrainedEnumModel,
10+
ConstrainedObjectModel,
11+
ConstrainedReferenceModel,
12+
TS_DESCRIPTION_PRESET,
13+
TypeScriptFileGenerator
14+
} from '@asyncapi/modelina';
615

716
// Interface for processed parameter schema data
817
export interface ProcessedParameterSchemaData {
@@ -20,7 +29,7 @@ export async function processAsyncAPIParameters(
2029
if (parameters.length > 0) {
2130
const channelName = findNameFromChannel(channel);
2231
const schemaId = pascalCase(`${channelName}_parameters`);
23-
32+
2433
const schemaObj: any = {
2534
type: 'object',
2635
$id: schemaId,
@@ -46,7 +55,7 @@ export async function processAsyncAPIParameters(
4655
return {
4756
channelParameters
4857
};
49-
}
58+
}
5059

5160
/**
5261
* Component which contains the parameter unwrapping functionality.
@@ -103,12 +112,10 @@ return parameters;`;
103112
* Generate additional content for AsyncAPI channel parameter classes
104113
*/
105114
function generateAsyncAPIParameterMethods(model: ConstrainedObjectModel) {
106-
const parameters = Object.entries(model.properties).map(
107-
([, parameter]) => {
108-
return `channel = channel.replace(/\\{${parameter.unconstrainedPropertyName}\\}/g, this.${parameter.propertyName})`;
109-
}
110-
);
111-
115+
const parameters = Object.entries(model.properties).map(([, parameter]) => {
116+
return `channel = channel.replace(/\\{${parameter.unconstrainedPropertyName}\\}/g, this.${parameter.propertyName})`;
117+
});
118+
112119
return `/**
113120
* Realize the channel/topic with the parameters added to this class.
114121
*/

0 commit comments

Comments
 (0)