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

Unable to parse a spec with an example attribute #163

Closed
jaydeepk opened this issue Feb 14, 2024 · 3 comments · Fixed by #195
Closed

Unable to parse a spec with an example attribute #163

jaydeepk opened this issue Feb 14, 2024 · 3 comments · Fixed by #195
Assignees
Labels
bug Something isn't working

Comments

@jaydeepk
Copy link
Contributor

Description

When we try to parse a spec with an 'example' attribute, it throws an error.

How to Reproduce

Given a spec with the following message schema:

messages:
    product:
      name: product
      title: An inventory product
      summary: Product representing items in inventory
      contentType: application/json
      payload:
        type: object
        properties:
          name:
            description: Every product has a name
            type: string
            example: Iphone
          inventory:
            description: Count of items in inventory
            type: number
            nullable: true
          id:
            description: Unique identifier of the product
            type: number

Note: The name property has an 'example' attribute.

Now when we try to parse the spec :

val specFilePath ="path to spec file"
val specFileContents = File(specFilePath).readText()
val asyncAPISpec= ObjectMapper(YAMLFactory()).readValue(specFileContents, AsyncAPI::class.java)

It throws this error:

com.fasterxml.jackson.databind.JsonMappingException: "example" is not valid extension property (through reference chain: com.asyncapi.v2._6_0.model.channel.message.Message["payload"]->com.asyncapi.v2.schema.Schema["properties"]->java.util.LinkedHashMap["name"]->com.asyncapi.v2.schema.Schema["example"])
	at com.fasterxml.jackson.databind.deser.SettableAnyProperty._throwAsIOE(SettableAnyProperty.java:246)
	at com.fasterxml.jackson.databind.deser.SettableAnyProperty.set(SettableAnyProperty.java:209)
	at com.fasterxml.jackson.databind.deser.SettableAnyProperty.deserializeAndSet(SettableAnyProperty.java:179)
	at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.handleUnknownVanilla(BeanDeserializerBase.java:1765)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:316)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:177)
	at com.fasterxml.jackson.databind.deser.std.MapDeserializer._readAndBindStringKeyMap(MapDeserializer.java:623)
	at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:449)
	at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:32)
	at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:310)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:177)
	at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:342) ...
@jaydeepk jaydeepk added the bug Something isn't working label Feb 14, 2024
@jaydeepk jaydeepk changed the title Unable to parse a spec with an example (singular) Unable to parse a spec with an example attribute (singular) Feb 14, 2024
@jaydeepk jaydeepk changed the title Unable to parse a spec with an example attribute (singular) Unable to parse a spec with an example attribute Feb 14, 2024
@Pakisan Pakisan self-assigned this Feb 14, 2024
@Pakisan
Copy link
Member

Pakisan commented Feb 14, 2024

@jaydeepk this is incorrect example:

See this reply:
asyncapi/spec#1031 (comment)

upd:

Need time to discuss what to do with this fields: asyncapi/spec#1031 (comment)

@Pakisan
Copy link
Member

Pakisan commented Feb 27, 2024

Right scenario is to use schemaFormat to be able to use schemas from OpenAPI - asyncapi/spec#1037

@Pakisan Pakisan moved this from In progress to Done in 1.0.0-EAP-3 Mar 10, 2024
@Pakisan Pakisan added this to In Progress in RC-1 Apr 20, 2024
@Pakisan Pakisan moved this from In Progress to Done in RC-1 Apr 20, 2024
@Pakisan
Copy link
Member

Pakisan commented Apr 20, 2024

Implemented in 1.0.0-RC

@Pakisan Pakisan closed this as completed Apr 20, 2024
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
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants