Skip to content

@JsonProperty will not get imported in java fileΒ #304

@pasinski

Description

@pasinski

Describe the bug

If the property name is different from the type name it references @JsonProperty annotation gets added for the field. However, no import com.fasterxml.jackson.annotation.JsonProperty

How to Reproduce

Create schema file example-jsonproperty.yaml with following content:

asyncapi: 2.5.0
info:
  title: JsonProperty Example
  version: 1.0.2
  description: | 
    This file contains schema definition, where some of the elements require ' @JsonProperty`. The annotation will get added to properties by `@asyncapi/java-spring-cloud-stream-template` however the import statement will not get added to the class file
defaultContentType: application/json
channels:
  helloWorld:
    description: |
      Greet User.
    publish:
      message:
        oneOf:
          - $ref: '#/components/messages/helloWorld'

components:

  messages:
    helloWorld:
      title: Hello World
      summary: 'Event: Greet the world'
      payload:
        $ref: '#/components/schemas/GreetingMessage'

  schemas:
    GreetingMessage:
        type: object
        required:
          - "greetingText"
          - "newsOfTheDay"
        properties:
          greetingText:
            type: string
            const: "Hello World"
          newsOfTheDay:
            $ref: '#/components/schemas/NewsOfTheDayType'
    NewsOfTheDayType:
      type: object
      required:
        - "theNews"
      properties:
        theNews:
          type: string

Generate app with command
ag example-jsonproperty.yaml @asyncapi/java-spring-cloud-stream-template -p artifactId=anschluss-events -p groupId=de.db.sab.kira -p javaPackage=de.db.sab.ki ra.anschlussEvents -o example-jsonproperty --force-write

Expected behavior

import com.fasterxml.jackson.annotation.JsonProperty; should get added to the imports section of generated java file

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstale

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions