use of io.swagger.v3.oas.models.media.MapSchema in project swagger-core by swagger-api.
the class ModelDeserializer method deserializeObjectSchema.
private Schema deserializeObjectSchema(JsonNode node) {
JsonNode additionalProperties = node.get("additionalProperties");
Schema schema = null;
if (additionalProperties != null) {
// try first to convert to Schema, if it fails it must be a boolean
try {
Schema innerSchema = Json.mapper().convertValue(additionalProperties, Schema.class);
((ObjectNode) node).remove("additionalProperties");
MapSchema ms = Json.mapper().convertValue(node, MapSchema.class);
ms.setAdditionalProperties(innerSchema);
schema = ms;
} catch (Exception e) {
Boolean additionalPropsBoolean = Json.mapper().convertValue(additionalProperties, Boolean.class);
if (additionalPropsBoolean) {
schema = Json.mapper().convertValue(node, MapSchema.class);
} else {
schema = Json.mapper().convertValue(node, ObjectSchema.class);
}
schema.setAdditionalProperties(additionalPropsBoolean);
}
} else {
schema = Json.mapper().convertValue(node, ObjectSchema.class);
}
if (schema != null) {
schema.jsonSchema(Json31.jsonSchemaAsMap(node));
}
return schema;
}
Aggregations