Unable to parse a spec with an nullable attribute
jaydeepk opened this issue · 3 comments
jaydeepk commented
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)
Pakisan commented
@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 commented
Right scenario is to use schemaFormat
to be able to use schemas from OpenAPI - asyncapi/spec#1037
Pakisan commented
Implemented in 1.0.0-RC