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 nullable attribute #164

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

Unable to parse a spec with an nullable attribute #164

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 a 'nullable' 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
          inventory:
            description: Count of items in inventory
            type: number
            nullable: true
          id:
            description: Unique identifier of the product
            type: number

Note: The inventory property has a 'nullable' attribute.

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: "nullable" 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["inventory"]->com.asyncapi.v2.schema.Schema["nullable"])
	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
@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)

Reason: nullable is not present in Schema

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
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
None yet
Development

Successfully merging a pull request may close this issue.

2 participants