Skip to content

Commit

Permalink
Separated merger and tester fixtures.
Browse files Browse the repository at this point in the history
Signed-off-by: dblock <[email protected]>
  • Loading branch information
dblock committed Sep 9, 2024
1 parent 9193d58 commit adaeeb3
Show file tree
Hide file tree
Showing 19 changed files with 250 additions and 5 deletions.
4 changes: 2 additions & 2 deletions tools/tests/merger/OpenApiMerger.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('OpenApiMerger', () => {

describe('defaults', () => {
beforeEach(() => {
merger = new OpenApiMerger('./tools/tests/merger/fixtures/spec/')
merger = new OpenApiMerger('./tools/tests/merger/fixtures/specs/animals')
})

describe('merge()', () => {
Expand Down Expand Up @@ -45,7 +45,7 @@ describe('OpenApiMerger', () => {

test('writes a spec', () => {
merger.write_to(filename)
expect(fs.readFileSync('./tools/tests/merger/fixtures/merger/expected.yaml', 'utf8'))
expect(fs.readFileSync('./tools/tests/merger/fixtures/merger/animals/expected.yaml', 'utf8'))
.toEqual(fs.readFileSync(filename, 'utf8'))
})
})
Expand Down
6 changes: 3 additions & 3 deletions tools/tests/merger/OpenApiVersionExtractor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import fs from 'fs'
import tmp from 'tmp'

describe('extract() from a merged API spec', () => {
const merger = new OpenApiMerger('tools/tests/tester/fixtures/specs/complete')
const merger = new OpenApiMerger('tools/tests/merger/fixtures/specs/opensearch')

describe('1.3', () => {
const extractor = new OpenApiVersionExtractor(merger.spec(), '1.3', 'ignore')
Expand All @@ -35,7 +35,7 @@ describe('extract() from a merged API spec', () => {

test('writes a spec', () => {
extractor.write_to(filename)
expect(fs.readFileSync('./tools/tests/merger/fixtures/extractor/expected_1.3.yaml', 'utf8'))
expect(fs.readFileSync('./tools/tests/merger/fixtures/extractor/opensearch/expected_1.3.yaml', 'utf8'))
.toEqual(fs.readFileSync(filename, 'utf8'))
})
})
Expand Down Expand Up @@ -74,7 +74,7 @@ describe('extract() from a merged API spec', () => {

test('writes a spec', () => {
extractor.write_to(filename)
expect(fs.readFileSync('./tools/tests/merger/fixtures/extractor/expected_2.0.yaml', 'utf8'))
expect(fs.readFileSync('./tools/tests/merger/fixtures/extractor/opensearch/expected_2.0.yaml', 'utf8'))
.toEqual(fs.readFileSync(filename, 'utf8'))
})
})
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
openapi: 3.1.0
info:
title: ''
version: ''
6 changes: 6 additions & 0 deletions tools/tests/merger/fixtures/specs/opensearch/_info.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
$schema: should-be-ignored

title: OpenSearch API
description: OpenSearch API
version: 1.0.0
x-api-version: 1.2.3
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$schema: should-be-ignored
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
openapi: 3.1.0
info:
title: OpenSearch API
description: OpenSearch API
version: 1.0.0
paths:
/cluster_manager:
get:
operationId: cluster_manager.0
x-version-added: '2.0'
post:
operationId: cluster_manager.0
x-version-added: '2.0'
components:
requestBodies: []
parameters: []
responses: []
109 changes: 109 additions & 0 deletions tools/tests/merger/fixtures/specs/opensearch/namespaces/index.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
openapi: 3.1.0
info:
title: OpenSearch API
description: OpenSearch API
version: 1.0.0
paths:
/index:
get:
operationId: get.0
responses:
'200':
$ref: '#/components/responses/info@200'
'201':
$ref: '#/components/responses/info@201'
'404':
$ref: '#/components/responses/info@404'
added-2.0:
$ref: '#/components/responses/[email protected]'
x-version-added: '2.0'
removed-2.0:
$ref: '#/components/responses/[email protected]'
x-version-removed: '2.0'
added-1.3-removed-2.0:
$ref: '#/components/responses/[email protected]'
added-2.1:
$ref: '#/components/responses/[email protected]'
'500':
$ref: '#/components/responses/info@500'
'503':
$ref: '#/components/responses/info@503'
distributed-included-all:
$ref: '#/components/responses/info@distributed-all'
x-distributions-included:
- amazon-managed
- amazon-serverless
- opensearch.org
distributed-included-amazon-managed:
$ref: '#/components/responses/info@distributed-amazon-managed'
x-distributions-included:
- amazon-managed
distributed-excluded-amazon-serverless:
$ref: '#/components/responses/info@distributed-all'
x-distributions-excluded:
- amazon-serverless
components:
responses:
info@200:
content:
application/json:
schema:
type: object
properties:
_type:
$ref: '../schemas/_common.yaml#/components/schemas/Type'
tagline:
type: string
required:
- tagline
info@201:
content:
application/json:
schema:
type: object
properties:
tagline:
type: string
required:
- tagline
unevaluatedProperties: true
info@404:
content:
application/json:
schema:
type: object
properties:
tagline:
type: string
required:
- tagline
unevaluatedProperties:
type: object
[email protected]:
description: Added in 2.0 via attribute next to ref.
[email protected]:
description: Removed in 2.0 via attribute next to ref.
[email protected]:
description: Added in 1.3, removed in 2.0 via attribute in response body.
x-version-added: '1.3'
x-version-removed: '2.0'
[email protected]:
description: Added in 2.1 via attribute in response body.
x-version-added: '2.1'
info@distributed-amazon-managed:
description: Distributed only in AOS.
info@distributed-all:
description: Distributed in opensearch.org, AOS and AOSS.
info@500:
content:
application/json:
schema:
type: object
properties:
tagline:
type: string
info@503:
content:
application/json:
schema:
type: object
90 changes: 90 additions & 0 deletions tools/tests/merger/fixtures/specs/opensearch/namespaces/nodes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
openapi: 3.1.0
info:
title: OpenSearch API
description: OpenSearch API
version: 1.0.0
paths:
/nodes:
get:
operationId: nodes.0
responses:
'200':
$ref: '#/components/responses/nodes.info@200'
/_nodes/{id}:
get:
operationId: nodes.info.1
x-operation-group: nodes.info
x-version-added: '1.0'
description: Returns information about nodes in the cluster.
parameters:
- $ref: '#/components/parameters/nodes.info::path.id'
responses:
'200':
$ref: '#/components/responses/nodes.info@200'
post:
operationId: nodes.info.1
x-operation-group: nodes.info
x-version-added: '2.0'
description: Returns information about nodes in the cluster.
parameters:
- $ref: '#/components/parameters/nodes.info::path.id'
- $ref: '#/components/parameters/nodes.info::query.flag'
requestBody:
$ref: '#/components/requestBodies/nodes.info'
responses:
'201':
$ref: '#/components/responses/nodes.info@201'
'200':
$ref: '#/components/responses/nodes.info@200'
components:
requestBodies:
nodes.info:
content:
application/json:
schema:
type: object
properties:
_all:
type: boolean
ids:
$ref: '../schemas/_common.yaml#/components/schemas/Ids'
x-version-added: '2.0'
description: Nodes options.
parameters:
nodes.info::path.id:
in: path
name: id
description: Node ID.
required: true
schema:
type: string
nodes.info::query.flag:
in: query
name: flag
description: Flag.
required: false
schema:
type: boolean
default: false
nodes.info::query.new:
in: query
name: new
description: New option added in 2.1.
required: false
x-version-added: '2.1'
schema:
type: array
default: false
responses:
nodes.info@200:
description: All nodes.
content:
application/json:
schema:
type: object
nodes.info@201:
description: All nodes.
content:
application/json:
schema:
type: object
18 changes: 18 additions & 0 deletions tools/tests/merger/fixtures/specs/opensearch/schemas/_common.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
openapi: 3.1.0
info:
title: Schemas of _common category
description: Schemas of _common category
version: 1.0.0
components:
schemas:
Type:
type: string
x-version-removed: '2.0'
OldId:
type: string
Ids:
oneOf:
- $ref: '#/components/schemas/OldId'
- type: array
items:
$ref: '#/components/schemas/Ids'

0 comments on commit adaeeb3

Please sign in to comment.