-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Comments
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. |
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 |
Thanks for the issue. The correct fix for this problem is to start supporting the discriminator which would handle this case as part of the implementation. Since there appears to be low adoption of this property in other templates and due to the complexity, it's not something that is expected to be implemented immediately. I think opening another issue for this would be the best thing to do. Please let us know if this is still an issue and what solution is acceptable. |
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
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
The text was updated successfully, but these errors were encountered: