From 485a6d56c92ef35e642965a9a95c75f9d9697f55 Mon Sep 17 00:00:00 2001 From: Jochen Schalanda Date: Sun, 26 Feb 2023 11:24:02 +0100 Subject: [PATCH] Failing test for #464 --- .../openapidiff/core/ExternalRefsTest.java | 14 +++ .../common/examples/200-health.yaml | 4 + .../specification/common/examples/400.yaml | 5 + .../specification/common/examples/404.yaml | 5 + .../specification/common/examples/500.yaml | 5 + .../Product/200-GetProductResponse.yaml | 3 + .../common/models/GetProductResponse.yaml | 9 ++ .../specification/common/models/Product.yaml | 15 +++ .../specification/common/models/error.yaml | 34 ++++++ .../common/parameters/correlation-id.yaml | 6 + .../common/parameters/traceparent.yaml | 6 + .../destination/specification/openapi.yaml | 110 ++++++++++++++++++ .../common/examples/200-health.yaml | 4 + .../specification/common/examples/400.yaml | 5 + .../specification/common/examples/404.yaml | 5 + .../specification/common/examples/500.yaml | 5 + .../Product/200-GetProductResponse.yaml | 3 + .../common/models/GetProductResponse.yaml | 9 ++ .../specification/common/models/Product.yaml | 15 +++ .../specification/common/models/error.yaml | 34 ++++++ .../common/parameters/correlation-id.yaml | 6 + .../common/parameters/traceparent.yaml | 6 + .../source/specification/openapi.yaml | 110 ++++++++++++++++++ 23 files changed, 418 insertions(+) create mode 100644 core/src/test/java/org/openapitools/openapidiff/core/ExternalRefsTest.java create mode 100644 core/src/test/resources/issue-464/destination/specification/common/examples/200-health.yaml create mode 100644 core/src/test/resources/issue-464/destination/specification/common/examples/400.yaml create mode 100644 core/src/test/resources/issue-464/destination/specification/common/examples/404.yaml create mode 100644 core/src/test/resources/issue-464/destination/specification/common/examples/500.yaml create mode 100644 core/src/test/resources/issue-464/destination/specification/common/examples/Product/200-GetProductResponse.yaml create mode 100644 core/src/test/resources/issue-464/destination/specification/common/models/GetProductResponse.yaml create mode 100644 core/src/test/resources/issue-464/destination/specification/common/models/Product.yaml create mode 100644 core/src/test/resources/issue-464/destination/specification/common/models/error.yaml create mode 100644 core/src/test/resources/issue-464/destination/specification/common/parameters/correlation-id.yaml create mode 100644 core/src/test/resources/issue-464/destination/specification/common/parameters/traceparent.yaml create mode 100644 core/src/test/resources/issue-464/destination/specification/openapi.yaml create mode 100644 core/src/test/resources/issue-464/source/specification/common/examples/200-health.yaml create mode 100644 core/src/test/resources/issue-464/source/specification/common/examples/400.yaml create mode 100644 core/src/test/resources/issue-464/source/specification/common/examples/404.yaml create mode 100644 core/src/test/resources/issue-464/source/specification/common/examples/500.yaml create mode 100644 core/src/test/resources/issue-464/source/specification/common/examples/Product/200-GetProductResponse.yaml create mode 100644 core/src/test/resources/issue-464/source/specification/common/models/GetProductResponse.yaml create mode 100644 core/src/test/resources/issue-464/source/specification/common/models/Product.yaml create mode 100644 core/src/test/resources/issue-464/source/specification/common/models/error.yaml create mode 100644 core/src/test/resources/issue-464/source/specification/common/parameters/correlation-id.yaml create mode 100644 core/src/test/resources/issue-464/source/specification/common/parameters/traceparent.yaml create mode 100644 core/src/test/resources/issue-464/source/specification/openapi.yaml diff --git a/core/src/test/java/org/openapitools/openapidiff/core/ExternalRefsTest.java b/core/src/test/java/org/openapitools/openapidiff/core/ExternalRefsTest.java new file mode 100644 index 000000000..221135672 --- /dev/null +++ b/core/src/test/java/org/openapitools/openapidiff/core/ExternalRefsTest.java @@ -0,0 +1,14 @@ +package org.openapitools.openapidiff.core; + +import static org.openapitools.openapidiff.core.TestUtils.assertOpenApiAreEquals; + +import org.junit.jupiter.api.Test; + +public class ExternalRefsTest { + @Test + public void testDiffSame() { + assertOpenApiAreEquals( + "issue-464/source/specification/openapi.yaml", + "issue-464/destination/specification/openapi.yaml"); + } +} diff --git a/core/src/test/resources/issue-464/destination/specification/common/examples/200-health.yaml b/core/src/test/resources/issue-464/destination/specification/common/examples/200-health.yaml new file mode 100644 index 000000000..fece2ca5e --- /dev/null +++ b/core/src/test/resources/issue-464/destination/specification/common/examples/200-health.yaml @@ -0,0 +1,4 @@ +status: up +date_time: "2021-09-04T21:00:00Z" +api_name: api +api_version: 1.1.2 diff --git a/core/src/test/resources/issue-464/destination/specification/common/examples/400.yaml b/core/src/test/resources/issue-464/destination/specification/common/examples/400.yaml new file mode 100644 index 000000000..35050cf6b --- /dev/null +++ b/core/src/test/resources/issue-464/destination/specification/common/examples/400.yaml @@ -0,0 +1,5 @@ +type: /problem/bad-request +title: Bad Request +status: 400 +detail: Invalid or malformed request syntax +instance: /problem/bad-request#invalid-or-malformed-request-syntax diff --git a/core/src/test/resources/issue-464/destination/specification/common/examples/404.yaml b/core/src/test/resources/issue-464/destination/specification/common/examples/404.yaml new file mode 100644 index 000000000..2d1a287f2 --- /dev/null +++ b/core/src/test/resources/issue-464/destination/specification/common/examples/404.yaml @@ -0,0 +1,5 @@ +type: /problem/data-not-found +title: Data not found +status: 404 +detail: Requested data not found +instance: /problem/data-not-found#requested-data-not-found \ No newline at end of file diff --git a/core/src/test/resources/issue-464/destination/specification/common/examples/500.yaml b/core/src/test/resources/issue-464/destination/specification/common/examples/500.yaml new file mode 100644 index 000000000..6bf838311 --- /dev/null +++ b/core/src/test/resources/issue-464/destination/specification/common/examples/500.yaml @@ -0,0 +1,5 @@ +type: /problem/internal-server-error +title: Internal Server Error +status: 500 +detail: A technical exception occurred within the application +instance: /problem/internal-server-error#a-technical-exception-occurred-within-the-application \ No newline at end of file diff --git a/core/src/test/resources/issue-464/destination/specification/common/examples/Product/200-GetProductResponse.yaml b/core/src/test/resources/issue-464/destination/specification/common/examples/Product/200-GetProductResponse.yaml new file mode 100644 index 000000000..a63465c1b --- /dev/null +++ b/core/src/test/resources/issue-464/destination/specification/common/examples/Product/200-GetProductResponse.yaml @@ -0,0 +1,3 @@ +products: + - id: Prod-000001 + status: Active diff --git a/core/src/test/resources/issue-464/destination/specification/common/models/GetProductResponse.yaml b/core/src/test/resources/issue-464/destination/specification/common/models/GetProductResponse.yaml new file mode 100644 index 000000000..d6fbbabbf --- /dev/null +++ b/core/src/test/resources/issue-464/destination/specification/common/models/GetProductResponse.yaml @@ -0,0 +1,9 @@ +type: object +description: Model for response from call to GET products requiring an array of products to be returned. +title: GetProductResponse +properties: + Products: + type: array + items: + $ref: Product.yaml + diff --git a/core/src/test/resources/issue-464/destination/specification/common/models/Product.yaml b/core/src/test/resources/issue-464/destination/specification/common/models/Product.yaml new file mode 100644 index 000000000..08f039d10 --- /dev/null +++ b/core/src/test/resources/issue-464/destination/specification/common/models/Product.yaml @@ -0,0 +1,15 @@ +type: object +description: Product Data Model +title: '' +properties: + id: + type: string + example: Prod-00001 + description: An unique Id of product record + status: + type: string + example: Active + enum: + - Active + - Expired + description: Defines the current status of the product diff --git a/core/src/test/resources/issue-464/destination/specification/common/models/error.yaml b/core/src/test/resources/issue-464/destination/specification/common/models/error.yaml new file mode 100644 index 000000000..5947543da --- /dev/null +++ b/core/src/test/resources/issue-464/destination/specification/common/models/error.yaml @@ -0,0 +1,34 @@ +type: object +properties: + type: + type: string + format: uri-reference + description: | + A URI reference that uniquely identifies the problem type only in the context of the provided API. Opposed to the specification in RFC-7807, it is neither recommended to be dereferenceable and point to a human-readable documentation nor globally unique for the problem type. + default: about:blank + example: /problem/connection-error + title: + type: string + description: | + A short summary of the problem type. Written in English and readable for engineers, usually not suited for non technical stakeholders and not localized. + example: Service Unavailable + status: + type: integer + format: int32 + description: | + The HTTP status code generated by the origin server for this occurrence of the problem. + minimum: 100 + maximum: 600 + exclusiveMaximum: true + example: 503 + detail: + type: string + description: | + A human readable explanation specific to this occurrence of the problem that is helpful to locate the problem and give advice on how to proceed. Written in English and readable for engineers, usually not suited for non technical stakeholders and not localized. + example: Connection to database timed out + instance: + type: string + format: uri-reference + description: | + A URI reference that identifies the specific occurrence of the problem, e.g. by adding a fragment identifier or sub-path to the problem type. May be used to locate the root of this problem in the source code. + example: /problem/connection-error#token-info-read-timed-out diff --git a/core/src/test/resources/issue-464/destination/specification/common/parameters/correlation-id.yaml b/core/src/test/resources/issue-464/destination/specification/common/parameters/correlation-id.yaml new file mode 100644 index 000000000..347e860b2 --- /dev/null +++ b/core/src/test/resources/issue-464/destination/specification/common/parameters/correlation-id.yaml @@ -0,0 +1,6 @@ +name: correlation-id +in: header +schema: + type: string + example: 4cbc91f7-11d3-4019-a92b-64a54964b470 +description: A unique identifier attached to request and responses as header that allows reference to a particular transaction or chain of transactions. Based on UUID conforming to RFC 4122 - https://datatracker.ietf.org/doc/html/rfc4122 diff --git a/core/src/test/resources/issue-464/destination/specification/common/parameters/traceparent.yaml b/core/src/test/resources/issue-464/destination/specification/common/parameters/traceparent.yaml new file mode 100644 index 000000000..5943a2e94 --- /dev/null +++ b/core/src/test/resources/issue-464/destination/specification/common/parameters/traceparent.yaml @@ -0,0 +1,6 @@ +name: traceparent +in: header +schema: + type: string + example: 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01 +description: The traceparent HTTP header field identifies the incoming request in a tracing system. Conforming to OpenTelemetry (OTel) Trace Context diff --git a/core/src/test/resources/issue-464/destination/specification/openapi.yaml b/core/src/test/resources/issue-464/destination/specification/openapi.yaml new file mode 100644 index 000000000..1a2db3d58 --- /dev/null +++ b/core/src/test/resources/issue-464/destination/specification/openapi.yaml @@ -0,0 +1,110 @@ +openapi: 3.0.0 +info: + title: service/someapi/v1 + version: 1.1.2 + contact: + name: john.doe + email: john.doe@acme.com + description: Provide description of the API +servers: + - url: 'https://api.acme.com/service/someapi/v1' +paths: + /products: + get: + summary: Query Products + operationId: get-products + responses: + '200': + $ref: '#/components/responses/200-GetProductResponse' + '400': + $ref: '#/components/responses/400' + '404': + $ref: '#/components/responses/404' + '500': + $ref: '#/components/responses/500' + description: Get Product Records + parameters: + - $ref: ./common/parameters/correlation-id.yaml + - $ref: ./common/parameters/traceparent.yaml + tags: + - applicant +components: + schemas: + Error: + $ref: common/models/error.yaml + GetProductResponse: + $ref: ./common/models/GetProductResponse.yaml + securitySchemes: + Oauth: + type: oauth2 + description: Oauth Security Token Enforcement for internal production environment. + flows: + clientCredentials: + tokenUrl: 'https://api.acme.com/auth/app/v1/token' + scopes: + scope: READ + responses: + '400': + description: 400 Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + 400 Bad Request: + value: + $ref: common/examples/400.yaml + headers: + correlation-id: + schema: + type: string + description: An ID passed by clients to correlate multiple API requests. + '404': + description: 404 Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + 404 Not Found: + value: + $ref: common/examples/404.yaml + headers: + correlation-id: + schema: + type: string + description: An ID passed by clients to correlate multiple API requests. + '500': + description: 500 Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + 500 Internal Server Error: + value: + $ref: common/examples/500.yaml + headers: + correlation-id: + schema: + type: string + description: An ID passed by clients to correlate multiple API requests. + 200-GetProductResponse: + description: Get Product Response + content: + application/json: + schema: + $ref: '#/components/schemas/GetProductResponse' + examples: + 200 - Sample Data: + value: + $ref: common/examples/Product/200-GetProductResponse.yaml + headers: + correlation-id: + schema: + type: string + description: An ID passed by clients to correlate multiple API requests. +security: + - Oauth: [] +tags: + - name: applicant diff --git a/core/src/test/resources/issue-464/source/specification/common/examples/200-health.yaml b/core/src/test/resources/issue-464/source/specification/common/examples/200-health.yaml new file mode 100644 index 000000000..fece2ca5e --- /dev/null +++ b/core/src/test/resources/issue-464/source/specification/common/examples/200-health.yaml @@ -0,0 +1,4 @@ +status: up +date_time: "2021-09-04T21:00:00Z" +api_name: api +api_version: 1.1.2 diff --git a/core/src/test/resources/issue-464/source/specification/common/examples/400.yaml b/core/src/test/resources/issue-464/source/specification/common/examples/400.yaml new file mode 100644 index 000000000..35050cf6b --- /dev/null +++ b/core/src/test/resources/issue-464/source/specification/common/examples/400.yaml @@ -0,0 +1,5 @@ +type: /problem/bad-request +title: Bad Request +status: 400 +detail: Invalid or malformed request syntax +instance: /problem/bad-request#invalid-or-malformed-request-syntax diff --git a/core/src/test/resources/issue-464/source/specification/common/examples/404.yaml b/core/src/test/resources/issue-464/source/specification/common/examples/404.yaml new file mode 100644 index 000000000..2d1a287f2 --- /dev/null +++ b/core/src/test/resources/issue-464/source/specification/common/examples/404.yaml @@ -0,0 +1,5 @@ +type: /problem/data-not-found +title: Data not found +status: 404 +detail: Requested data not found +instance: /problem/data-not-found#requested-data-not-found \ No newline at end of file diff --git a/core/src/test/resources/issue-464/source/specification/common/examples/500.yaml b/core/src/test/resources/issue-464/source/specification/common/examples/500.yaml new file mode 100644 index 000000000..6bf838311 --- /dev/null +++ b/core/src/test/resources/issue-464/source/specification/common/examples/500.yaml @@ -0,0 +1,5 @@ +type: /problem/internal-server-error +title: Internal Server Error +status: 500 +detail: A technical exception occurred within the application +instance: /problem/internal-server-error#a-technical-exception-occurred-within-the-application \ No newline at end of file diff --git a/core/src/test/resources/issue-464/source/specification/common/examples/Product/200-GetProductResponse.yaml b/core/src/test/resources/issue-464/source/specification/common/examples/Product/200-GetProductResponse.yaml new file mode 100644 index 000000000..a63465c1b --- /dev/null +++ b/core/src/test/resources/issue-464/source/specification/common/examples/Product/200-GetProductResponse.yaml @@ -0,0 +1,3 @@ +products: + - id: Prod-000001 + status: Active diff --git a/core/src/test/resources/issue-464/source/specification/common/models/GetProductResponse.yaml b/core/src/test/resources/issue-464/source/specification/common/models/GetProductResponse.yaml new file mode 100644 index 000000000..d6fbbabbf --- /dev/null +++ b/core/src/test/resources/issue-464/source/specification/common/models/GetProductResponse.yaml @@ -0,0 +1,9 @@ +type: object +description: Model for response from call to GET products requiring an array of products to be returned. +title: GetProductResponse +properties: + Products: + type: array + items: + $ref: Product.yaml + diff --git a/core/src/test/resources/issue-464/source/specification/common/models/Product.yaml b/core/src/test/resources/issue-464/source/specification/common/models/Product.yaml new file mode 100644 index 000000000..08f039d10 --- /dev/null +++ b/core/src/test/resources/issue-464/source/specification/common/models/Product.yaml @@ -0,0 +1,15 @@ +type: object +description: Product Data Model +title: '' +properties: + id: + type: string + example: Prod-00001 + description: An unique Id of product record + status: + type: string + example: Active + enum: + - Active + - Expired + description: Defines the current status of the product diff --git a/core/src/test/resources/issue-464/source/specification/common/models/error.yaml b/core/src/test/resources/issue-464/source/specification/common/models/error.yaml new file mode 100644 index 000000000..5947543da --- /dev/null +++ b/core/src/test/resources/issue-464/source/specification/common/models/error.yaml @@ -0,0 +1,34 @@ +type: object +properties: + type: + type: string + format: uri-reference + description: | + A URI reference that uniquely identifies the problem type only in the context of the provided API. Opposed to the specification in RFC-7807, it is neither recommended to be dereferenceable and point to a human-readable documentation nor globally unique for the problem type. + default: about:blank + example: /problem/connection-error + title: + type: string + description: | + A short summary of the problem type. Written in English and readable for engineers, usually not suited for non technical stakeholders and not localized. + example: Service Unavailable + status: + type: integer + format: int32 + description: | + The HTTP status code generated by the origin server for this occurrence of the problem. + minimum: 100 + maximum: 600 + exclusiveMaximum: true + example: 503 + detail: + type: string + description: | + A human readable explanation specific to this occurrence of the problem that is helpful to locate the problem and give advice on how to proceed. Written in English and readable for engineers, usually not suited for non technical stakeholders and not localized. + example: Connection to database timed out + instance: + type: string + format: uri-reference + description: | + A URI reference that identifies the specific occurrence of the problem, e.g. by adding a fragment identifier or sub-path to the problem type. May be used to locate the root of this problem in the source code. + example: /problem/connection-error#token-info-read-timed-out diff --git a/core/src/test/resources/issue-464/source/specification/common/parameters/correlation-id.yaml b/core/src/test/resources/issue-464/source/specification/common/parameters/correlation-id.yaml new file mode 100644 index 000000000..347e860b2 --- /dev/null +++ b/core/src/test/resources/issue-464/source/specification/common/parameters/correlation-id.yaml @@ -0,0 +1,6 @@ +name: correlation-id +in: header +schema: + type: string + example: 4cbc91f7-11d3-4019-a92b-64a54964b470 +description: A unique identifier attached to request and responses as header that allows reference to a particular transaction or chain of transactions. Based on UUID conforming to RFC 4122 - https://datatracker.ietf.org/doc/html/rfc4122 diff --git a/core/src/test/resources/issue-464/source/specification/common/parameters/traceparent.yaml b/core/src/test/resources/issue-464/source/specification/common/parameters/traceparent.yaml new file mode 100644 index 000000000..5943a2e94 --- /dev/null +++ b/core/src/test/resources/issue-464/source/specification/common/parameters/traceparent.yaml @@ -0,0 +1,6 @@ +name: traceparent +in: header +schema: + type: string + example: 00-0af7651916cd43dd8448eb211c80319c-b7ad6b7169203331-01 +description: The traceparent HTTP header field identifies the incoming request in a tracing system. Conforming to OpenTelemetry (OTel) Trace Context diff --git a/core/src/test/resources/issue-464/source/specification/openapi.yaml b/core/src/test/resources/issue-464/source/specification/openapi.yaml new file mode 100644 index 000000000..1a2db3d58 --- /dev/null +++ b/core/src/test/resources/issue-464/source/specification/openapi.yaml @@ -0,0 +1,110 @@ +openapi: 3.0.0 +info: + title: service/someapi/v1 + version: 1.1.2 + contact: + name: john.doe + email: john.doe@acme.com + description: Provide description of the API +servers: + - url: 'https://api.acme.com/service/someapi/v1' +paths: + /products: + get: + summary: Query Products + operationId: get-products + responses: + '200': + $ref: '#/components/responses/200-GetProductResponse' + '400': + $ref: '#/components/responses/400' + '404': + $ref: '#/components/responses/404' + '500': + $ref: '#/components/responses/500' + description: Get Product Records + parameters: + - $ref: ./common/parameters/correlation-id.yaml + - $ref: ./common/parameters/traceparent.yaml + tags: + - applicant +components: + schemas: + Error: + $ref: common/models/error.yaml + GetProductResponse: + $ref: ./common/models/GetProductResponse.yaml + securitySchemes: + Oauth: + type: oauth2 + description: Oauth Security Token Enforcement for internal production environment. + flows: + clientCredentials: + tokenUrl: 'https://api.acme.com/auth/app/v1/token' + scopes: + scope: READ + responses: + '400': + description: 400 Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + 400 Bad Request: + value: + $ref: common/examples/400.yaml + headers: + correlation-id: + schema: + type: string + description: An ID passed by clients to correlate multiple API requests. + '404': + description: 404 Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + 404 Not Found: + value: + $ref: common/examples/404.yaml + headers: + correlation-id: + schema: + type: string + description: An ID passed by clients to correlate multiple API requests. + '500': + description: 500 Internal Server Error + content: + application/json: + schema: + $ref: '#/components/schemas/Error' + examples: + 500 Internal Server Error: + value: + $ref: common/examples/500.yaml + headers: + correlation-id: + schema: + type: string + description: An ID passed by clients to correlate multiple API requests. + 200-GetProductResponse: + description: Get Product Response + content: + application/json: + schema: + $ref: '#/components/schemas/GetProductResponse' + examples: + 200 - Sample Data: + value: + $ref: common/examples/Product/200-GetProductResponse.yaml + headers: + correlation-id: + schema: + type: string + description: An ID passed by clients to correlate multiple API requests. +security: + - Oauth: [] +tags: + - name: applicant