@@ -66,8 +66,8 @@ class OpenApi3GeneratorTest {
6666 }
6767
6868 @Test
69- fun `should aggregate responses with different content type` () {
70- givenResourcesWithSamePathAndDifferentContentType ()
69+ fun `should aggregate responses with different content type and different response schema ` () {
70+ givenResourcesWithSamePathAndDifferentContentTypeAndDifferentResponseSchema ()
7171
7272 whenOpenApiObjectGenerated()
7373
@@ -82,32 +82,13 @@ class OpenApi3GeneratorTest {
8282 then(openApiJsonPathContext.read<Any >(" $productPatchByIdPath .responses.200.content.application/hal+json.schema.\$ ref" )).isNotNull()
8383 then(openApiJsonPathContext.read<Any >(" $productPatchByIdPath .responses.200.content.application/hal+json.examples.test-1" )).isNotNull()
8484
85- thenOpenApiSpecIsValid()
86- }
87-
88- @Test
89- fun `should segregate responses schema with different content type and different response schema` () {
90- givenResourcesWithSamePathAndDifferentContentTypeAndDifferentResponseSchema()
91-
92- whenOpenApiObjectGenerated()
93-
94- val productPatchByIdPath = " paths./products/{id}.patch"
95- then(openApiJsonPathContext.read<Any >(" $productPatchByIdPath .requestBody.content.application/json.schema.\$ ref" )).isNotNull()
96- then(openApiJsonPathContext.read<Any >(" $productPatchByIdPath .requestBody.content.application/json.examples.test" )).isNotNull()
97- then(openApiJsonPathContext.read<Any >(" $productPatchByIdPath .requestBody.content.application/json-patch+json.schema.\$ ref" )).isNotNull()
98- then(openApiJsonPathContext.read<Any >(" $productPatchByIdPath .requestBody.content.application/json-patch+json.examples.test-1" )).isNotNull()
99-
100- val schema1 = openApiJsonPathContext.read<Any >(" $productPatchByIdPath .responses.200.content.application/json.schema.\$ ref" )
101- val schema2 = openApiJsonPathContext.read<Any >(" $productPatchByIdPath .responses.200.content.application/hal+json.schema.\$ ref" )
85+ val schema1 = openApiJsonPathContext.read<String >(" $productPatchByIdPath .responses.200.content.application/json.schema.\$ ref" )
86+ val schema2 = openApiJsonPathContext.read<String >(" $productPatchByIdPath .responses.200.content.application/hal+json.schema.\$ ref" )
10287 then(schema1).isEqualTo(" #/components/schemas/schema1" )
10388 then(schema2).isEqualTo(" #/components/schemas/schema2" )
10489
105- then(openApiJsonPathContext.read<Any >(" $productPatchByIdPath .responses.200.content.application/json.examples.test" )).isNotNull()
106- then(openApiJsonPathContext.read<Any >(" $productPatchByIdPath .responses.200.content.application/hal+json.examples.test-1" )).isNotNull()
107-
108- val componentsSchemaPath = " components.schemas"
109- then(openApiJsonPathContext.read<Any >(" $componentsSchemaPath .schema1" )).isNotNull()
110- then(openApiJsonPathContext.read<Any >(" $componentsSchemaPath .schema2" )).isNotNull()
90+ then(openApiJsonPathContext.read<Any >(" ${schema1.replaceFirst(" #/" , " " ).replace(" /" , " ." )} " )).isNotNull()
91+ then(openApiJsonPathContext.read<Any >(" ${schema2.replaceFirst(" #/" , " " ).replace(" /" , " ." )} " )).isNotNull()
11192
11293 thenOpenApiSpecIsValid()
11394 }
@@ -577,31 +558,6 @@ class OpenApi3GeneratorTest {
577558 )
578559 }
579560
580- private fun givenResourcesWithSamePathAndDifferentContentType () {
581- resources = listOf (
582- ResourceModel (
583- operationId = " test" ,
584- summary = " summary" ,
585- description = " description" ,
586- privateResource = false ,
587- deprecated = false ,
588- tags = setOf (" tag1" , " tag2" ),
589- request = getProductPatchRequest(),
590- response = getProductResponse()
591- ),
592- ResourceModel (
593- operationId = " test-1" ,
594- summary = " summary 1" ,
595- description = " description 1" ,
596- privateResource = false ,
597- deprecated = false ,
598- tags = setOf (" tag1" , " tag2" ),
599- request = getProductPatchJsonPatchRequest(),
600- response = getProductHalResponse()
601- )
602- )
603- }
604-
605561 private fun givenResourcesWithSamePathAndDifferentContentTypeAndDifferentResponseSchema () {
606562 resources = listOf (
607563 ResourceModel (
0 commit comments