cli icon indicating copy to clipboard operation
cli copied to clipboard

Generating with preset: 'client' is not working correctly

Open ALagoni97 opened this issue 2 years ago • 3 comments

My config:

import { TheCodegenConfiguration } from '@the-codegen-project/cli'
const config: TheCodegenConfiguration = {
	inputType: 'asyncapi',
	inputPath: '../../definitions/asyncapi.json',
	language: 'typescript',
	generators: [
		{
			preset: 'client',
			outputPath: 'src/__nats__/channels',
			language: 'typescript',
			protocols: ['nats'],
		},
		{
			preset: 'payloads',
			outputPath: 'src/__nats__/payloads',
			serializationType: 'json',
			language: 'typescript',
			enum: 'enum',
			map: 'record',
			useForJavaScript: true,
			rawPropertyNames: false,
		},
		{
			preset: 'parameters',
			language: 'typescript',
			outputPath: 'src/__nats__/parameters',
			serializationType: 'json',
		},
	],
}
export default config

Is generating the following error: image

ALagoni97 avatar Oct 27 '24 15:10 ALagoni97

It seems like the dependencies is getting a default array of 1 item: channels-typescript which the code might then expect to be present all the time. In my case I don't have any dependencies.

ALagoni97 avatar Oct 27 '24 16:10 ALagoni97

Update on this. I figured out it was because it adds the channels-typescript as a dependency but doesn't generate a default channels generator. That's the core issue here. Fixed it with this:


		{
			preset: 'channels',
			outputPath: './src/__nats__/channels',
			language: 'typescript',
			protocols: ['nats'],
		},

ALagoni97 avatar Oct 27 '24 16:10 ALagoni97

Should not be necessary, fixing

jonaslagoni avatar Oct 28 '24 07:10 jonaslagoni