Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Payload don't generated with avro schema #419

Open
2 tasks done
leonardotorresaltez opened this issue Oct 27, 2024 · 2 comments
Open
2 tasks done

[BUG] Payload don't generated with avro schema #419

leonardotorresaltez opened this issue Oct 27, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@leonardotorresaltez
Copy link

Describe the bug.

Hello,
I tried to generate avro mapping java classes with spring template but in any way the generator is making json mapping java classes ( with @JsonProperty property ) .

asyncapi: '2.6.0'
info:
  title: Mercadona Kafka API
  version: 1.0.0
  description: |-
    Api acerca de las entidades en Mercadona.
  license:
    name: Apache 2.0
    url: https://www.apache.org/licenses/LICENSE-2.0

defaultContentType: 'application/vnd.apache.avro+json;version=1.9.0'

servers:
  production:
    url: broker:9092
    description: Kafka PRODUCTION cluster
    protocol: kafka

channels:
  mytopic:
    description: The topic.
    publish:
      summary: publish message.
      operationId: publishStoreassortmentvisibility
      message:
        schemaFormat: 'application/vnd.apache.avro;version=1.9.0'
        $ref: '#/components/messages/storeassortmentvisibility'
    subscribe:
      summary: receive message.
      operationId: receiveStoreassortmentvisibility
      message:
        schemaFormat: 'application/vnd.apache.avro;version=1.9.0'
        $ref: '#/components/messages/storeassortmentvisibility'
components:
  messages:
    storeassortmentvisibility:
      name: storeassortmentvisibility
      title: storeassortmentvisibility measured     
      schemaFormat: 'application/vnd.apache.avro;version=1.9.0'
      payload:
        type: record
        name: User
        namespace: com.company
        doc: User information
        fields:
          - name: displayName
            type: string
          - name: email
            type: string
          - name: age
            type: int

the command is :

 asyncapi generate fromTemplate asyncapi_demo_contract262.yml @asyncapi/[email protected] --output ./output_folder --force-write

the generated file is:

package com.asyncapi.model;


import jakarta.validation.constraints.*;
import jakarta.validation.Valid;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonValue;

import javax.annotation.processing.Generated;
import java.util.List;
import java.util.Map;
import java.util.Objects;

/**
 * User information
 */
@Generated(value="com.asyncapi.generator.template.spring", date="2024-10-27T11:32:20.876Z")
public class ComCompanyUser {
    
    private @Valid String displayName;
    
    private @Valid String email;
    
    private @Valid int age;
    

    

    
    @JsonProperty("displayName")@NotNull
    public String getDisplayName() {
        return displayName;
    }

    public void setDisplayName(String displayName) {
        this.displayName = displayName;
    }
    

    
    @JsonProperty("email")@NotNull
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

 . . .

Expected behavior

Expected to see generated java avro mapping files , example :

@org.apache.avro.specific.AvroGenerated
public class User extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord
. . .

Screenshots

none

How to Reproduce

  1. I first did this
  2. I then did this
  3. And so on . . .
 asyncapi generate fromTemplate asyncapi_demo_contract262.yml @asyncapi/[email protected] --output ./output_folder --force-write

🥦 Browser

Microsoft Edge

👀 Have you checked for similar open issues?

  • I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

None

@leonardotorresaltez leonardotorresaltez added the bug Something isn't working label Oct 27, 2024
Copy link

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

@leonardotorresaltez
Copy link
Author

I already check the similar issue:
#78

From i can see the avro parser exist:
https://github.com/asyncapi/avro-schema-parser?tab=readme-ov-file#usage-with-remote-references

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant