diff --git a/src/main/resources/swagger.api/schema/resource/response/InstanceResponse.json b/src/main/resources/swagger.api/schema/resource/response/InstanceResponse.json index 8b5a7232..b66cf920 100644 --- a/src/main/resources/swagger.api/schema/resource/response/InstanceResponse.json +++ b/src/main/resources/swagger.api/schema/resource/response/InstanceResponse.json @@ -5,17 +5,12 @@ { "$ref": "../common/IdField.json" }, + { + "$ref": "title/TitleFieldResponse.json" + }, { "type": "object", "properties": { - "title": { - "type": "array", - "items": { - "type": "object", - "$ref": "title/TitleFieldResponse.json" - }, - "x-json-property": "http://bibfra.me/vocab/marc/title" - }, "production": { "type": "array", "items": { diff --git a/src/main/resources/swagger.api/schema/resource/response/WorkResponse.json b/src/main/resources/swagger.api/schema/resource/response/WorkResponse.json index 737d8d3d..dcb71034 100644 --- a/src/main/resources/swagger.api/schema/resource/response/WorkResponse.json +++ b/src/main/resources/swagger.api/schema/resource/response/WorkResponse.json @@ -5,17 +5,12 @@ { "$ref": "../common/IdField.json" }, + { + "$ref": "title/TitleFieldResponse.json" + }, { "type": "object", "properties": { - "title": { - "type": "array", - "items": { - "type": "object", - "$ref": "title/TitleFieldResponse.json" - }, - "x-json-property": "http://bibfra.me/vocab/marc/title" - }, "targetAudience": { "type": "array", "items": { diff --git a/src/main/resources/swagger.api/schema/resource/response/title/TitleFieldResponse.json b/src/main/resources/swagger.api/schema/resource/response/title/TitleFieldResponse.json index 02feca37..215b92c8 100644 --- a/src/main/resources/swagger.api/schema/resource/response/title/TitleFieldResponse.json +++ b/src/main/resources/swagger.api/schema/resource/response/title/TitleFieldResponse.json @@ -1,38 +1,51 @@ { + "$schema": "http://json-schema.org/draft-04/schema#", "description": "Title of the Work or Instance resource", - "oneOf": [ - { - "type": "object", - "title": "PrimaryTitleFieldResponse", - "properties": { - "PrimaryTitle": { - "type": "object", - "$ref": "schema/resource/response/title/PrimaryTitleResponse.json", - "x-json-property": "http://bibfra.me/vocab/marc/Title" - } - } - }, - { - "type": "object", - "title": "VariantTitleFieldResponse", - "properties": { - "VariantTitle": { - "type": "object", - "$ref": "schema/resource/response/title/VariantTitleResponse.json", - "x-json-property": "http://bibfra.me/vocab/marc/VariantTitle" - } - } - }, - { - "type": "object", - "title": "ParallelTitleFieldResponse", - "properties": { - "ParallelTitle": { - "type": "object", - "$ref": "schema/resource/response/title/ParallelTitleResponse.json", - "x-json-property": "http://bibfra.me/vocab/marc/ParallelTitle" - } - } + "properties": { + "title": { + "type": "array", + "items": { + "type": "object", + "oneOf": [ + { + "type": "object", + "title": "PrimaryTitleFieldResponse", + "properties": { + "PrimaryTitle": { + "type": "object", + "$ref": "PrimaryTitleResponse.json", + "x-json-property": "http://bibfra.me/vocab/marc/Title", + "description": "The primary title of the work or instance" + } + } + }, + { + "type": "object", + "title": "VariantTitleFieldResponse", + "properties": { + "VariantTitle": { + "type": "object", + "$ref": "VariantTitleResponse.json", + "x-json-property": "http://bibfra.me/vocab/marc/VariantTitle", + "description": "The variant title of the work or instance" + } + } + }, + { + "type": "object", + "title": "ParallelTitleFieldResponse", + "properties": { + "ParallelTitle": { + "type": "object", + "$ref": "ParallelTitleResponse.json", + "x-json-property": "http://bibfra.me/vocab/marc/ParallelTitle", + "description": "The parallel title of the work or instance" + } + } + } + ] + }, + "x-json-property": "http://bibfra.me/vocab/marc/title" } - ] + } } diff --git a/src/test/java/org/folio/linked/data/test/TestUtil.java b/src/test/java/org/folio/linked/data/test/TestUtil.java index 4b18e890..50b9d4b2 100644 --- a/src/test/java/org/folio/linked/data/test/TestUtil.java +++ b/src/test/java/org/folio/linked/data/test/TestUtil.java @@ -37,7 +37,7 @@ import org.folio.linked.data.configuration.json.ObjectMapperConfig; import org.folio.linked.data.domain.dto.InstanceResponseAllOfMap; import org.folio.linked.data.domain.dto.ResourceResponseField; -import org.folio.linked.data.domain.dto.TitleFieldResponse; +import org.folio.linked.data.domain.dto.TitleFieldResponseTitleInner; import org.folio.linked.data.exception.RequestProcessingExceptionBuilder; import org.folio.linked.data.model.entity.Resource; import org.folio.linked.data.test.json.InstanceResponseAllOfMapDeserializer; @@ -72,7 +72,7 @@ public class TestUtil { static { OBJECT_MAPPER.registerModule(new SimpleModule() .addDeserializer(ResourceResponseField.class, new ResourceResponseFieldDeserializer()) - .addDeserializer(TitleFieldResponse.class, new TitleFieldResponseDeserializer()) + .addDeserializer(TitleFieldResponseTitleInner.class, new TitleFieldResponseDeserializer()) .addDeserializer(InstanceResponseAllOfMap.class, new InstanceResponseAllOfMapDeserializer()) ); PARAMETERS.excludeField(named("id")); diff --git a/src/test/java/org/folio/linked/data/test/json/TitleFieldResponseDeserializer.java b/src/test/java/org/folio/linked/data/test/json/TitleFieldResponseDeserializer.java index 7c3e5531..2e19fc15 100644 --- a/src/test/java/org/folio/linked/data/test/json/TitleFieldResponseDeserializer.java +++ b/src/test/java/org/folio/linked/data/test/json/TitleFieldResponseDeserializer.java @@ -12,21 +12,21 @@ import java.util.Map; import org.folio.linked.data.domain.dto.ParallelTitleFieldResponse; import org.folio.linked.data.domain.dto.PrimaryTitleFieldResponse; -import org.folio.linked.data.domain.dto.TitleFieldResponse; +import org.folio.linked.data.domain.dto.TitleFieldResponseTitleInner; import org.folio.linked.data.domain.dto.VariantTitleFieldResponse; import org.folio.linked.data.util.DtoDeserializer; -public class TitleFieldResponseDeserializer extends JsonDeserializer { - private static final Map> IDENDTITY_MAP = Map.of( +public class TitleFieldResponseDeserializer extends JsonDeserializer { + private static final Map> IDENDTITY_MAP = Map.of( TITLE.getUri(), PrimaryTitleFieldResponse.class, PARALLEL_TITLE.getUri(), ParallelTitleFieldResponse.class, VARIANT_TITLE.getUri(), VariantTitleFieldResponse.class ); - private final DtoDeserializer dtoDeserializer = - new DtoDeserializer<>(TitleFieldResponse.class, IDENDTITY_MAP, EMPTY_EXCEPTION_BUILDER); + private final DtoDeserializer dtoDeserializer = + new DtoDeserializer<>(TitleFieldResponseTitleInner.class, IDENDTITY_MAP, EMPTY_EXCEPTION_BUILDER); @Override - public TitleFieldResponse deserialize(JsonParser jp, DeserializationContext dc) throws IOException { + public TitleFieldResponseTitleInner deserialize(JsonParser jp, DeserializationContext dc) throws IOException { return dtoDeserializer.deserialize(jp); } }