sngular / scs-multiapi-plugin

This is a Maven plugin designed to help developers automatizing the creation of code classes from YML files based on AsyncApi and OpenAPI.
http://sngular.com
Mozilla Public License 2.0
48 stars 10 forks source link

Supplier/Producer code is generated exclusively #265

Closed novaross closed 1 year ago

novaross commented 1 year ago

Hi,

I'm using version 4.9.5 of the plugin. It seems that the plugin does not generate the supplier code, and also it generates a redundant sngular.apigenerator.asyncapi package.

Definition of the plugin is as follows:

asyncapimodel {
    specFile {
        {
            filePath = './src/main/resources/asyncapi/sampleapi.yaml'
            consumer {
                ids = 'operationIdTwo'
                apiPackage = 'com.rs.sample.consumer.api'
                modelPackage = 'com.rs.sample.consumer.model'
            }
            supplier {
                ids = 'operationIdOne'
                apiPackage = 'com.rs.sample.supplier.api'
                modelPackage = 'com.rs.sample.supplier.model'
            }
        }
        overWriteModel = true
    }
}

The valid sampleapi.yaml contains publish and subscribe operations defined as below:

channels:
  testChannel:
    description: channel for test messages
    parameters:
      messageId:
        $ref: '#/components/parameters/testChannelMessageId'

    subscribe:
      operationId: operationIdOne
      summary: some event occurred in the system
      message:
        $ref: '#/components/messages/testMessage'
      traits:
        - $ref: '#/components/operationTraits/kafka'

    publish:
      operationId: operationIdTwo
      summary: some event occurred in the system
      message:
        $ref: '#/components/messages/testMessage'
      traits:
        - $ref: '#/components/operationTraits/kafka'

In the generated sources there is no generation of the consumer code. Also the sngular.apigenerator.asyncapi is generated when it is not required. Below are the contents of the build/generated-sources folder.

\---com
    +---rs
    |   \---sample
    |       +---consumer
    |       |   \---api
    |       \---supplier
    |           +---api
    |           |       IOperationIdOne.java
    |           |       Producer.java
    |           |
    |           \---model
    |               +---messages
    |               |   |   TestMessage.java
    |               |   |
    |               |   \---customvalidator
    |               |           Min.java
    |               |           MinValidator.java
    |               |
    |               \---schemas
    |                       SomeObject.java
    |                       TestMessagePayload.java
    |
    \---sngular
        \---apigenerator
            \---asyncapi

If i switch the operation ids in the plugin configuration, then there is no producer code generated. Is this the expected behavior of the plugin? Is it possible to generate producer code for one of the operation id's and supplier code for the other?

jemacineiras commented 1 year ago

HI @novaross,

generation of extra folder is a know issue, low priority, but I can take a look into it. But the no code generation is something new. In our manual test all is generated as expected. but I will try your configuration and back to you asap.

Cheers