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

Can't determine the type of property #356

Open
2 tasks done
marian-varga opened this issue Apr 30, 2024 · 2 comments
Open
2 tasks done

Can't determine the type of property #356

marian-varga opened this issue Apr 30, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@marian-varga
Copy link

marian-varga commented Apr 30, 2024

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?

  • I checked and didn't find similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue ?

None

@marian-varga marian-varga added the bug Something isn't working label Apr 30, 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.

@marian-varga
Copy link
Author

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

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