From 5e720716f33079a0e9627f5573f18cbfaf5fcbda Mon Sep 17 00:00:00 2001 From: Jonas Lagoni Date: Mon, 12 Feb 2024 16:29:09 +0100 Subject: [PATCH 1/3] update implementation --- src/commands/generate/models.ts | 38 ++- test/fixtures/specification-v3.yml | 256 ------------------ test/integration/bundle/bundle.test.ts | 2 +- test/integration/diff.test.ts | 2 +- .../integration/generate/fromTemplate.test.ts | 2 +- test/integration/generate/models.test.ts | 48 +++- test/integration/optimize.test.ts | 2 +- 7 files changed, 55 insertions(+), 295 deletions(-) delete mode 100644 test/fixtures/specification-v3.yml diff --git a/src/commands/generate/models.ts b/src/commands/generate/models.ts index 556e7d9af7b..e5f12bf9603 100644 --- a/src/commands/generate/models.ts +++ b/src/commands/generate/models.ts @@ -1,4 +1,4 @@ -import { CSharpFileGenerator, JavaFileGenerator, JavaScriptFileGenerator, TypeScriptFileGenerator, GoFileGenerator, Logger, DartFileGenerator, PythonFileGenerator, RustFileGenerator, TS_COMMON_PRESET, TS_JSONBINPACK_PRESET, CSHARP_DEFAULT_PRESET, CSHARP_NEWTONSOFT_SERIALIZER_PRESET, CSHARP_COMMON_PRESET, CSHARP_JSON_SERIALIZER_PRESET, KotlinFileGenerator, TS_DESCRIPTION_PRESET, PhpFileGenerator, CplusplusFileGenerator, JAVA_CONSTRAINTS_PRESET, JAVA_JACKSON_PRESET, JAVA_COMMON_PRESET, JAVA_DESCRIPTION_PRESET } from '@asyncapi/modelina'; +import { CSharpFileGenerator, JavaFileGenerator, JavaScriptFileGenerator, TypeScriptFileGenerator, GoFileGenerator, Logger, DartFileGenerator, PythonFileGenerator, RustFileGenerator, TS_COMMON_PRESET, TS_JSONBINPACK_PRESET, CSHARP_DEFAULT_PRESET, CSHARP_NEWTONSOFT_SERIALIZER_PRESET, CSHARP_COMMON_PRESET, CSHARP_JSON_SERIALIZER_PRESET, KotlinFileGenerator, TS_DESCRIPTION_PRESET, PhpFileGenerator, CplusplusFileGenerator, JAVA_CONSTRAINTS_PRESET, JAVA_JACKSON_PRESET, JAVA_COMMON_PRESET, JAVA_DESCRIPTION_PRESET, ScalaFileGenerator } from '@asyncapi/modelina'; import { Flags } from '@oclif/core'; import { ConvertDocumentParserAPIVersion } from '@smoya/multi-parser'; import Command from '../../base'; @@ -18,7 +18,8 @@ enum Languages { rust = 'rust', kotlin='kotlin', php='php', - cplusplus='cplusplus' + cplusplus='cplusplus', + scala='scala' } const possibleLanguageValues = Object.values(Languages).join(', '); @@ -171,20 +172,12 @@ export default class Models extends Command { const { tsModelType, tsEnumType, tsIncludeComments, tsModuleSystem, tsExportType, tsJsonBinPack, tsMarshalling, tsExampleInstance, namespace, csharpAutoImplement, csharpArrayType, csharpNewtonsoft, csharpHashcode, csharpEqual, csharpSystemJson, packageName, javaIncludeComments, javaJackson, javaConstraints, output } = flags; const { language, file } = args; const inputFile = (await load(file)) || (await load()); - if (inputFile.isAsyncAPI3()) { - this.error('Generate Models command does not support AsyncAPI v3 yet, please checkout https://github.com/asyncapi/modelina/issues/1376'); - } const { document, diagnostics ,status } = await parse(this, inputFile, flags); if (!document || status === 'invalid') { const severityErrors = diagnostics.filter((obj) => obj.severity === 0); this.log(`Input is not a correct AsyncAPI document so it cannot be processed.${formatOutput(severityErrors,'stylish','error')}`); return; } - - // Modelina, atm, is not using @asyncapi/parser@v3.x but @asyncapi/parser@v2.x, so it still uses Parser-API v1.0.0. - // This call converts the parsed document object using @asyncapi/parser@v3.x (Parser-API v2) to a document compatible with the Parser-API version in use in @asyncapi/parser@v2.x (v1) - // This is needed until https://github.com/asyncapi/modelina/issues/1493 gets fixed. - const convertedDoc = ConvertDocumentParserAPIVersion(document.json(), 1); Logger.setLogger({ info: (message) => { @@ -242,15 +235,6 @@ export default class Models extends Command { if (namespace === undefined) { throw new Error('In order to generate models to C#, we need to know which namespace they are under. Add `--namespace=NAMESPACE` to set the desired namespace.'); } - - if (csharpAutoImplement) { - presets.push({ - preset: CSHARP_DEFAULT_PRESET, - options: { - autoImplementedProperties: true - } - }); - } if (csharpNewtonsoft) { presets.push(CSHARP_NEWTONSOFT_SERIALIZER_PRESET); } @@ -269,7 +253,8 @@ export default class Models extends Command { fileGenerator = new CSharpFileGenerator({ presets, - collectionType: csharpArrayType as 'Array' | 'List' + collectionType: csharpArrayType as 'Array' | 'List', + autoImplementedProperties: csharpAutoImplement }); fileOptions = { @@ -284,6 +269,15 @@ export default class Models extends Command { namespace }); break; + case Languages.scala: + if (packageName === undefined) { + throw new Error('In order to generate models to Scala, we need to know which package they are under. Add `--packageName=PACKAGENAME` to set the desired package name.'); + } + fileGenerator = new ScalaFileGenerator(); + fileOptions = { + packageName + }; + break; case Languages.golang: if (packageName === undefined) { throw new Error('In order to generate models to Go, we need to know which package they are under. Add `--packageName=PACKAGENAME` to set the desired package name.'); @@ -345,7 +339,7 @@ export default class Models extends Command { if (output) { const models = await fileGenerator.generateToFiles( - convertedDoc as any, + document, output, { ...fileOptions, }); const generatedModels = models.map((model) => { return model.modelName; }); @@ -354,7 +348,7 @@ export default class Models extends Command { } const models = await fileGenerator.generateCompleteModels( - convertedDoc as any, + document, { ...fileOptions }); const generatedModels = models.map((model) => { return ` diff --git a/test/fixtures/specification-v3.yml b/test/fixtures/specification-v3.yml deleted file mode 100644 index 622cc03a058..00000000000 --- a/test/fixtures/specification-v3.yml +++ /dev/null @@ -1,256 +0,0 @@ -asyncapi: 3.0.0 -id: 'urn:example:com:smartylighting:streetlights:server' -info: - title: AsyncAPI Sample App - version: 1.0.1 - description: This is a sample app. - termsOfService: 'https://asyncapi.com/terms/' - contact: - name: API Support - url: 'https://www.asyncapi.com/support' - email: support@asyncapi.org - license: - name: Apache 2.0 - url: 'https://www.apache.org/licenses/LICENSE-2.0.html' - tags: - - name: e-commerce - - name: another-tag - description: Description... - externalDocs: - description: Find more info here - url: 'https://www.asyncapi.com' -defaultContentType: application/json -servers: - default: - host: 'api.streetlights.smartylighting.com:{port}' - protocol: mqtt - description: Test broker - variables: - port: - description: Secure connection (TLS) is available through port 8883. - default: '1883' - enum: - - '1883' - - '8883' - security: - - $ref: '#/components/securitySchemes/apiKey' - - type: oauth2 - flows: - implicit: - authorizationUrl: 'https://example.com/api/oauth/dialog' - availableScopes: - 'write:pets': modify pets in your account - 'read:pets': read your pets - scopes: - - 'write:pets' - - type: openIdConnect - openIdConnectUrl: https://example.com/api - scopes: - - 'some:scope:1' - - 'some:scope:2' - production: - host: 'api.streetlights.smartylighting.com:{port}' - pathname: /some/path - protocol: mqtt - description: Test broker - variables: - port: - description: Secure connection (TLS) is available through port 8883. - default: '1883' - enum: - - '1883' - - '8883' - security: - - $ref: '#/components/securitySchemes/apiKey' - withProtocol: - host: 'api.streetlights.smartylighting.com:{port}' - pathname: /some/path - protocol: mqtt - description: Test broker - variables: - port: - description: Secure connection (TLS) is available through port 8883. - default: '1883' - enum: - - '1883' - - '8883' - security: - - $ref: '#/components/securitySchemes/apiKey' -channels: - 'smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured': - address: 'smartylighting/streetlights/1/0/event/{streetlightId}/lighting/measured' - messages: - lightMeasured.message: - payload: - type: object - servers: - - $ref: '#/servers/production' - parameters: - streetlightId: - $ref: '#/components/parameters/streetlightId' - 'smartylighting/streetlights/1/0/action/{streetlightId}/turn/on': - address: 'smartylighting/streetlights/1/0/action/{streetlightId}/turn/on' - messages: - publish.message: - $ref: '#/components/messages/lightMeasured' - subscribe.message.0: - $ref: '#/components/messages/turnOnOff' - customMessageId: - payload: - type: object - subscribe.message.2: - payload: - type: object - servers: - - $ref: '#/servers/default' - - $ref: '#/servers/production' - parameters: - streetlightId: - $ref: '#/components/parameters/streetlightId' - customChannelId: - address: 'smartylighting/streetlights/1/0/action/{streetlightId}/turn/off' - messages: - turnOnOff.message: - $ref: '#/components/messages/turnOnOff' - parameters: - streetlightId: - $ref: '#/components/parameters/streetlightId' - x-channelId: customChannelId - 'smartylighting/streetlights/1/0/action/{streetlightId}/dim': - address: 'smartylighting/streetlights/1/0/action/{streetlightId}/dim' - messages: - dimLight.message: - $ref: '#/components/messages/dimLight' - parameters: - streetlightId: - $ref: '#/components/parameters/streetlightId' -operations: - lightMeasured: - action: receive - channel: - $ref: >- - #/channels/smartylighting~1streetlights~11~10~1event~1{streetlightId}~1lighting~1measured - messages: - - $ref: >- - #/channels/smartylighting~1streetlights~11~10~1event~1{streetlightId}~1lighting~1measured/messages/lightMeasured.message - 'smartylighting/streetlights/1/0/action/{streetlightId}/turn/on.publish': - action: receive - channel: - $ref: >- - #/channels/smartylighting~1streetlights~11~10~1action~1{streetlightId}~1turn~1on - messages: - - $ref: '#/components/messages/lightMeasured' - 'smartylighting/streetlights/1/0/action/{streetlightId}/turn/on.subscribe': - action: send - channel: - $ref: >- - #/channels/smartylighting~1streetlights~11~10~1action~1{streetlightId}~1turn~1on - messages: - - $ref: '#/components/messages/turnOnOff' - - $ref: >- - #/channels/smartylighting~1streetlights~11~10~1action~1{streetlightId}~1turn~1on/messages/customMessageId - - $ref: >- - #/channels/smartylighting~1streetlights~11~10~1action~1{streetlightId}~1turn~1on/messages/subscribe.message.2 - turnOnOff: - action: send - channel: - $ref: '#/channels/customChannelId' - messages: - - $ref: '#/components/messages/turnOnOff' - dimLight: - action: send - channel: - $ref: >- - #/channels/smartylighting~1streetlights~11~10~1action~1{streetlightId}~1dim - security: - - type: oauth2 - flows: - implicit: - authorizationUrl: 'https://example.com/api/oauth/dialog' - availableScopes: - 'write:pets': modify pets in your account - 'read:pets': read your pets - scopes: - - 'write:pets' - messages: - - $ref: '#/components/messages/dimLight' -components: - messages: - lightMeasured: - summary: >- - Inform about environmental lighting conditions for a particular - streetlight. - payload: - $ref: '#/components/schemas/lightMeasuredPayload' - turnOnOff: - summary: Command a particular streetlight to turn the lights on or off. - payload: - $ref: '#/components/schemas/turnOnOffPayload' - dimLight: - summary: Command a particular streetlight to dim the lights. - payload: - $ref: '#/components/schemas/dimLightPayload' - schemas: - lightMeasuredPayload: - type: object - properties: - lumens: - type: integer - minimum: 0 - description: Light intensity measured in lumens. - sentAt: - $ref: '#/components/schemas/sentAt' - turnOnOffPayload: - type: object - properties: - command: - type: string - enum: - - 'on' - - 'off' - description: Whether to turn on or off the light. - sentAt: - $ref: '#/components/schemas/sentAt' - dimLightPayload: - type: object - properties: - percentage: - type: integer - description: Percentage to which the light should be dimmed to. - minimum: 0 - maximum: 100 - sentAt: - $ref: '#/components/schemas/sentAt' - sentAt: - type: string - format: date-time - description: Date and time when the message was sent. - securitySchemes: - apiKey: - type: apiKey - in: user - description: Provide your API key as the user and leave the password empty. - flows: - type: oauth2 - flows: - implicit: - authorizationUrl: 'https://example.com/api/oauth/dialog' - availableScopes: - 'write:pets': modify pets in your account - 'read:pets': read your pets - openIdConnect: - openIdConnectUrl: https://example.com/api - scopes: - - 'some:scope:1' - - 'some:scope:2' - unusedFlows: - type: oauth2 - flows: - implicit: - authorizationUrl: 'https://example.com/api/oauth/dialog' - availableScopes: - 'write:pets': modify pets in your account - 'read:pets': read your pets - parameters: - streetlightId: - description: The ID of the streetlight. diff --git a/test/integration/bundle/bundle.test.ts b/test/integration/bundle/bundle.test.ts index dcfe4de72d1..72b248cd50e 100644 --- a/test/integration/bundle/bundle.test.ts +++ b/test/integration/bundle/bundle.test.ts @@ -4,7 +4,7 @@ import path from 'path'; import { fileCleanup } from '../../helpers'; const spec = fs.readFileSync('./test/integration/bundle/final-asyncapi.yaml', {encoding: 'utf-8'}); -const asyncapiv3 = './test/fixtures/specification-v3.yml'; +const asyncapiv3 = './test/fixtures/asyncapi_v3.yml'; function validateGeneratedSpec(filePath: string, spec: string) { const generatedSPec = fs.readFileSync(path.resolve(filePath), { encoding: 'utf-8' }); diff --git a/test/integration/diff.test.ts b/test/integration/diff.test.ts index 5f814a2400c..19455bd4a21 100644 --- a/test/integration/diff.test.ts +++ b/test/integration/diff.test.ts @@ -1,7 +1,7 @@ /* eslint-disable sonarjs/no-duplicate-string */ import { expect, test } from '@oclif/test'; -const asyncapiv3 = './test/fixtures/specification-v3.yml'; +const asyncapiv3 = './test/fixtures/asyncapi_v3.yml'; const asyncapiv2 = './test/fixtures/specification.yml'; const noChangesJson = '"{\\n \\"changes\\": []\\n}\\n"'; const breakingChangesJson = '"[\\n {\\n \\"action\\": \\"edit\\",\\n \\"path\\": \\"/servers/mosquitto/protocol\\",\\n \\"before\\": \\"mqtt\\",\\n \\"after\\": \\"http\\",\\n \\"type\\": \\"breaking\\"\\n },\\n {\\n \\"action\\": \\"edit\\",\\n \\"path\\": \\"/servers/mosquitto/url\\",\\n \\"before\\": \\"mqtt://test.mosquitto.org\\",\\n \\"after\\": \\"http://test.mosquitto.org\\",\\n \\"type\\": \\"breaking\\"\\n }\\n]\\n"'; diff --git a/test/integration/generate/fromTemplate.test.ts b/test/integration/generate/fromTemplate.test.ts index fe5e0cd126a..dfce2785cf2 100644 --- a/test/integration/generate/fromTemplate.test.ts +++ b/test/integration/generate/fromTemplate.test.ts @@ -9,7 +9,7 @@ const generalOptions = [ './test/fixtures/specification.yml', '@asyncapi/minimaltemplate', ]; -const asyncapiv3 = './test/fixtures/specification-v3.yml'; +const asyncapiv3 = './test/fixtures/asyncapi_v3.yml'; function cleanup(filepath: string) { rimraf.sync(filepath); diff --git a/test/integration/generate/models.test.ts b/test/integration/generate/models.test.ts index c18d8b50b2b..7b5bbf37e36 100644 --- a/test/integration/generate/models.test.ts +++ b/test/integration/generate/models.test.ts @@ -7,7 +7,7 @@ import { createMockServer, stopMockServer } from '../../helpers'; import rimraf from 'rimraf'; const generalOptions = ['generate:models']; const outputDir = './test/fixtures/generate/models'; -const asyncapiv3 = './test/fixtures/specification-v3.yml'; +const asyncapiv3 = './test/fixtures/asyncapi_v3.yml'; describe('models', () => { before(() => { @@ -17,17 +17,18 @@ describe('models', () => { stopMockServer(); rimraf.sync(outputDir); }); - describe('should handle AsyncAPI v3 document correctly', () => { - test - .stderr() - .stdout() - .command([ - ...generalOptions, 'typescript', asyncapiv3]) - .it('give error', (ctx, done) => { - expect(ctx.stderr).to.contain('Error: Generate Models command does not support AsyncAPI v3 yet, please checkout https://github.com/asyncapi/modelina/issues/1376\n'); - done(); - }); - }); + + test + .stderr() + .stdout() + .command([ + ...generalOptions, 'typescript', asyncapiv3]) + .it('should generate AsyncAPI v3 document', (ctx, done) => { + expect(ctx.stdout).to.contain( + 'Successfully generated the following models: ' + ); + done(); + }); test .stderr() .stdout() @@ -44,7 +45,7 @@ describe('models', () => { .stdout() .command([...generalOptions, 'random', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './random')}`]) .it('fails when it dont know the language', (ctx, done) => { - expect(ctx.stderr).to.contain('Error: Expected random to be one of: typescript, csharp, golang, java, javascript, dart, python, rust, kotlin, php, cplusplus\nSee more help with --help\n'); + expect(ctx.stderr).to.contain('Error: Expected random to be one of: typescript, csharp, golang, java, javascript, dart, python, rust, kotlin, php, cplusplus, scala\nSee more help with --help\n'); done(); }); test @@ -124,6 +125,27 @@ describe('models', () => { }); }); + describe('for Scala', () => { + test + .stderr() + .stdout() + .command([...generalOptions, 'scala', './test/fixtures/specification.yml', `-o=${path.resolve(outputDir, './scala')}`, '--packageName=\'asyncapi.models\'']) + .it('works when file path is passed', (ctx, done) => { + expect(ctx.stdout).to.contain( + 'Successfully generated the following models: ' + ); + done(); + }); + test + .stderr() + .stdout() + .command([...generalOptions, 'scala', './test/fixtures/specification.yml', `-o=${ path.resolve(outputDir, './scala')}`]) + .it('fails when no package provided', (ctx, done) => { + expect(ctx.stderr).to.contain('Error: In order to generate models to Scala, we need to know which package they are under. Add `--packageName=PACKAGENAME` to set the desired package name.\n'); + done(); + }); + }); + describe('for Python', () => { test .stderr() diff --git a/test/integration/optimize.test.ts b/test/integration/optimize.test.ts index 91f56938128..095151099b5 100644 --- a/test/integration/optimize.test.ts +++ b/test/integration/optimize.test.ts @@ -9,7 +9,7 @@ const testHelper = new TestHelper(); const optimizedFilePath = './test/fixtures/specification.yml'; const unoptimizedFile = './test/fixtures/dummyspec/unoptimizedSpec.yml'; const invalidFile = './test/fixtures/specification-invalid.yml'; -const asyncapiv3 = './test/fixtures/specification-v3.yml'; +const asyncapiv3 = './test/fixtures/asyncapi_v3.yml'; describe('optimize', () => { describe('should handle AsyncAPI v3 document correctly', () => { From 7943b4c8ab9cd553ab824280373a7eabd977bd04 Mon Sep 17 00:00:00 2001 From: Jonas Lagoni Date: Mon, 12 Feb 2024 16:29:20 +0100 Subject: [PATCH 2/3] update implementation --- test/fixtures/asyncapi_v3.yml | 206 ++++++++++++++++++++++++++++++++++ 1 file changed, 206 insertions(+) create mode 100644 test/fixtures/asyncapi_v3.yml diff --git a/test/fixtures/asyncapi_v3.yml b/test/fixtures/asyncapi_v3.yml new file mode 100644 index 00000000000..e16a1c5d173 --- /dev/null +++ b/test/fixtures/asyncapi_v3.yml @@ -0,0 +1,206 @@ +asyncapi: 3.0.0 +info: + title: Streetlights Kafka API + version: 1.0.0 + description: |- + The Smartylighting Streetlights API allows you to remotely manage the city + lights. + ### Check out its awesome features: + + * Turn a specific streetlight on/off 🌃 + * Dim a specific streetlight 😎 + * Receive real-time information about environmental lighting conditions 📈 + license: + name: Apache 2.0 + url: 'https://www.apache.org/licenses/LICENSE-2.0' +defaultContentType: application/json +servers: + scram-connections: + host: 'test.mykafkacluster.org:18092' + protocol: kafka-secure + description: Test broker secured with scramSha256 + security: + - $ref: '#/components/securitySchemes/saslScram' + tags: + - name: 'env:test-scram' + description: >- + This environment is meant for running internal tests through + scramSha256 + - name: 'kind:remote' + description: This server is a remote server. Not exposed by the application + - name: 'visibility:private' + description: This resource is private and only available to certain users + mtls-connections: + host: 'test.mykafkacluster.org:28092' + protocol: kafka-secure + description: Test broker secured with X509 + security: + - $ref: '#/components/securitySchemes/certs' + tags: + - name: 'env:test-mtls' + description: This environment is meant for running internal tests through mtls + - name: 'kind:remote' + description: This server is a remote server. Not exposed by the application + - name: 'visibility:private' + description: This resource is private and only available to certain users +channels: + lightingMeasured: + address: 'smartylighting.streetlights.1.0.event.{streetlightId}.lighting.measured' + messages: + lightMeasured: + $ref: '#/components/messages/lightMeasured' + description: The topic on which measured values may be produced and consumed. + parameters: + streetlightId: + $ref: '#/components/parameters/streetlightId' + lightTurnOn: + address: 'smartylighting.streetlights.1.0.action.{streetlightId}.turn.on' + messages: + turnOn: + $ref: '#/components/messages/turnOnOff' + parameters: + streetlightId: + $ref: '#/components/parameters/streetlightId' + lightTurnOff: + address: 'smartylighting.streetlights.1.0.action.{streetlightId}.turn.off' + messages: + turnOff: + $ref: '#/components/messages/turnOnOff' + parameters: + streetlightId: + $ref: '#/components/parameters/streetlightId' + lightsDim: + address: 'smartylighting.streetlights.1.0.action.{streetlightId}.dim' + messages: + dimLight: + $ref: '#/components/messages/dimLight' + parameters: + streetlightId: + $ref: '#/components/parameters/streetlightId' +operations: + receiveLightMeasurement: + action: receive + channel: + $ref: '#/channels/lightingMeasured' + summary: >- + Inform about environmental lighting conditions of a particular + streetlight. + traits: + - $ref: '#/components/operationTraits/kafka' + messages: + - $ref: '#/channels/lightingMeasured/messages/lightMeasured' + turnOn: + action: send + channel: + $ref: '#/channels/lightTurnOn' + traits: + - $ref: '#/components/operationTraits/kafka' + messages: + - $ref: '#/channels/lightTurnOn/messages/turnOn' + turnOff: + action: send + channel: + $ref: '#/channels/lightTurnOff' + traits: + - $ref: '#/components/operationTraits/kafka' + messages: + - $ref: '#/channels/lightTurnOff/messages/turnOff' + dimLight: + action: send + channel: + $ref: '#/channels/lightsDim' + traits: + - $ref: '#/components/operationTraits/kafka' + messages: + - $ref: '#/channels/lightsDim/messages/dimLight' +components: + messages: + lightMeasured: + name: lightMeasured + title: Light measured + summary: >- + Inform about environmental lighting conditions of a particular + streetlight. + contentType: application/json + traits: + - $ref: '#/components/messageTraits/commonHeaders' + payload: + $ref: '#/components/schemas/lightMeasuredPayload' + turnOnOff: + name: turnOnOff + title: Turn on/off + summary: Command a particular streetlight to turn the lights on or off. + traits: + - $ref: '#/components/messageTraits/commonHeaders' + payload: + $ref: '#/components/schemas/turnOnOffPayload' + dimLight: + name: dimLight + title: Dim light + summary: Command a particular streetlight to dim the lights. + traits: + - $ref: '#/components/messageTraits/commonHeaders' + payload: + $ref: '#/components/schemas/dimLightPayload' + schemas: + lightMeasuredPayload: + type: object + properties: + lumens: + type: integer + minimum: 0 + description: Light intensity measured in lumens. + sentAt: + $ref: '#/components/schemas/sentAt' + turnOnOffPayload: + type: object + properties: + command: + type: string + enum: + - 'on' + - 'off' + description: Whether to turn on or off the light. + sentAt: + $ref: '#/components/schemas/sentAt' + dimLightPayload: + type: object + properties: + percentage: + type: integer + description: Percentage to which the light should be dimmed to. + minimum: 0 + maximum: 100 + sentAt: + $ref: '#/components/schemas/sentAt' + sentAt: + type: string + format: date-time + description: Date and time when the message was sent. + securitySchemes: + saslScram: + type: scramSha256 + description: Provide your username and password for SASL/SCRAM authentication + certs: + type: X509 + description: Download the certificate files from service provider + parameters: + streetlightId: + description: The ID of the streetlight. + messageTraits: + commonHeaders: + headers: + type: object + properties: + my-app-header: + type: integer + minimum: 0 + maximum: 100 + operationTraits: + kafka: + bindings: + kafka: + clientId: + type: string + enum: + - my-app-id From 5d2484d0a293aa645dbb8284940838d2a1c6c949 Mon Sep 17 00:00:00 2001 From: Jonas Lagoni Date: Mon, 12 Feb 2024 16:41:44 +0100 Subject: [PATCH 3/3] fix linting --- src/commands/generate/models.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/commands/generate/models.ts b/src/commands/generate/models.ts index e5f12bf9603..ae8d33fe943 100644 --- a/src/commands/generate/models.ts +++ b/src/commands/generate/models.ts @@ -1,6 +1,5 @@ -import { CSharpFileGenerator, JavaFileGenerator, JavaScriptFileGenerator, TypeScriptFileGenerator, GoFileGenerator, Logger, DartFileGenerator, PythonFileGenerator, RustFileGenerator, TS_COMMON_PRESET, TS_JSONBINPACK_PRESET, CSHARP_DEFAULT_PRESET, CSHARP_NEWTONSOFT_SERIALIZER_PRESET, CSHARP_COMMON_PRESET, CSHARP_JSON_SERIALIZER_PRESET, KotlinFileGenerator, TS_DESCRIPTION_PRESET, PhpFileGenerator, CplusplusFileGenerator, JAVA_CONSTRAINTS_PRESET, JAVA_JACKSON_PRESET, JAVA_COMMON_PRESET, JAVA_DESCRIPTION_PRESET, ScalaFileGenerator } from '@asyncapi/modelina'; +import { CSharpFileGenerator, JavaFileGenerator, JavaScriptFileGenerator, TypeScriptFileGenerator, GoFileGenerator, Logger, DartFileGenerator, PythonFileGenerator, RustFileGenerator, TS_COMMON_PRESET, TS_JSONBINPACK_PRESET, CSHARP_NEWTONSOFT_SERIALIZER_PRESET, CSHARP_COMMON_PRESET, CSHARP_JSON_SERIALIZER_PRESET, KotlinFileGenerator, TS_DESCRIPTION_PRESET, PhpFileGenerator, CplusplusFileGenerator, JAVA_CONSTRAINTS_PRESET, JAVA_JACKSON_PRESET, JAVA_COMMON_PRESET, JAVA_DESCRIPTION_PRESET, ScalaFileGenerator } from '@asyncapi/modelina'; import { Flags } from '@oclif/core'; -import { ConvertDocumentParserAPIVersion } from '@smoya/multi-parser'; import Command from '../../base'; import { load } from '../../models/SpecificationFile'; import { formatOutput, parse, validationFlags } from '../../parser';