@Override public ObjectSchema.AdditionalProperties deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { if (p.hasCurrentToken()) { switch (p.getCurrentTokenId()) { case JsonTokenId.ID_TRUE: return null; // "additionalProperties":true is the default case JsonTokenId.ID_FALSE: return ObjectSchema.NoAdditionalProperties.instance; case JsonTokenId.ID_START_OBJECT: case JsonTokenId.ID_FIELD_NAME: case JsonTokenId.ID_END_OBJECT: // 29-Dec-2015, tatu: may need/want to use property value reader in future but for now: JsonSchema innerSchema = ctxt.readValue(p, JsonSchema.class); return new ObjectSchema.SchemaAdditionalProperties(innerSchema); } } return ctxt.reportInputMismatch(this, "additionalProperties nodes can only be of type boolean or object, got token of type: %s", p.getCurrentToken()); } }
@Override public ObjectSchema.AdditionalProperties deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { if (p.hasCurrentToken()) { switch (p.getCurrentTokenId()) { case JsonTokenId.ID_TRUE: return null; // "additionalProperties":true is the default case JsonTokenId.ID_FALSE: return ObjectSchema.NoAdditionalProperties.instance; case JsonTokenId.ID_START_OBJECT: case JsonTokenId.ID_FIELD_NAME: case JsonTokenId.ID_END_OBJECT: // 29-Dec-2015, tatu: may need/want to use property value reader in future but for now: JsonSchema innerSchema = ctxt.readValue(p, JsonSchema.class); return new ObjectSchema.SchemaAdditionalProperties(innerSchema); } } return ctxt.reportInputMismatch(this, "additionalProperties nodes can only be of type boolean or object, got token of type: %s", p.getCurrentToken()); } }
@Override public void valueFormat(JsonFormatVisitable handler, JavaType valueType) throws JsonMappingException { // ISSUE #24: https://github.com/FasterXML/jackson-module-jsonSchema/issues/24 JsonSchema valueSchema = propertySchema(handler, valueType); ObjectSchema.AdditionalProperties ap = new ObjectSchema.SchemaAdditionalProperties(valueSchema.asSimpleTypeSchema()); this.schema.setAdditionalProperties(ap); }
@Override public void valueFormat(JsonFormatVisitable handler, JavaType valueType) throws JsonMappingException { // ISSUE #24: https://github.com/FasterXML/jackson-module-jsonSchema/issues/24 JsonSchema valueSchema = propertySchema(handler, valueType); ObjectSchema.AdditionalProperties ap = new ObjectSchema.SchemaAdditionalProperties(valueSchema.asSimpleTypeSchema()); this.schema.setAdditionalProperties(ap); }