asyncapi / java-spring-cloud-stream-template

Java Spring Cloud Stream template for the AsyncAPI Generator
31 stars 33 forks source link

Can't determine the type of property #356

Open marian-varga opened 5 months ago

marian-varga commented 5 months ago

Describe the bug.

Cannot generate code from the spec

Something went wrong: Template render error: (node_modules\@asyncapi\generator\node_modules\@asyncapi\java-spring-cloud-stream-template\template\src\main\java\$$everySchema$$.java) [Line 10, Column 51] Error: Can't determine the type of property petType at eval (eval at _compile (node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:527:18), :46:11) at node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:510:9 at eval (eval at _compile (node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:527:18), :12:11) at node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:510:9 at Template.root [as rootRenderFunc] (eval at _compile (node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:527:18), :367:3) at Template.getExported (node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:508:10) at eval (eval at _compile (node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:527:18), :11:5) at Environment.getTemplate (node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:225:9) at Template.root [as rootRenderFunc] (eval at _compile (node_modules\@asyncapi\generator\node_modules\nunjucks\src\environment.js:527:18), :9:5)

Expected behavior

Code should be generated

Screenshots

image

How to Reproduce

ag ../polymorphism.yaml @asyncapi/java-spring-cloud-stream-template

🥦 Browser

None

👀 Have you checked for similar open issues?

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

None

github-actions[bot] commented 5 months ago

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.

marian-varga commented 5 months ago
asyncapi: 2.6.0
info:
  title: Example of schema using polymorphism
  version: 2.6.0
channels:
  pet:
    subscribe:
      message:
        payload:
          type: object
          properties:
            pet:
              $ref: "#/components/schemas/Pet"
components:
  schemas:
    Pet:
      type: object
      discriminator: petType
      properties:
        name:
          type: string
        petType:
          type: string
      required:
        - name
        - petType
    ## applies to instances with `petType: "Cat"`
    ## because that is the schema name
    Cat:
      description: A representation of a cat
      allOf:
        - $ref: '#/components/schemas/Pet'
        - type: object
          properties:
            huntingSkill:
              type: string
              description: The measured skill for hunting
              enum:
                - clueless
                - lazy
                - adventurous
                - aggressive
          required:
            - huntingSkill
    ## applies to instances with `petType: "Dog"`
    ## because that is the schema name
    Dog:
      description: A representation of a dog
      allOf:
        - $ref: '#/components/schemas/Pet'
        - type: object
          properties:
            packSize:
              type: integer
              format: int32
              description: the size of the pack the dog is from
              minimum: 0
          required:
            - packSize
    ## applies to instances with `petType: "StickBug"`
    ## because that is the required value of the discriminator field,
    ## overriding the schema name
    StickInsect:
      description: A representation of an Australian walking stick
      allOf:
        - $ref: '#/components/schemas/Pet'
        - type: object
          properties:
            petType:
              const: StickBug
            color:
              type: string
          required:
            - color