Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions apps/engine/src/__generated__/openapi.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

158 changes: 95 additions & 63 deletions apps/engine/src/__generated__/openapi.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions apps/engine/src/__tests__/openapi.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,54 @@ describe('Engine OpenAPI spec', () => {
expect(schema, `${name} should not have $schema`).not.toHaveProperty('$schema')
}
})

it('has SourceState as a named component schema', async () => {
const spec = await getSpec()
expect(spec.components.schemas).toHaveProperty('SourceState')
const sourceState = spec.components.schemas['SourceState'] as Record<string, unknown>
expect(sourceState.type).toBe('object')
expect(sourceState).toHaveProperty('properties')
const props = sourceState.properties as Record<string, unknown>
expect(props).toHaveProperty('streams')
expect(props).toHaveProperty('global')
})

it('header params use application/json content key, never [object Object]', async () => {
const spec = await getSpec()
for (const [path, pathItem] of Object.entries(spec.paths ?? {})) {
for (const [method, op] of Object.entries(pathItem as Record<string, unknown>)) {
const operation = op as { parameters?: Array<Record<string, unknown>> } | undefined
for (const param of operation?.parameters ?? []) {
const content = param.content as Record<string, unknown> | undefined
if (content) {
expect(
Object.keys(content),
`${method.toUpperCase()} ${path} param "${param.name}" has [object Object] content key`
).not.toContain('[object Object]')
}
}
}
}
})

it('x-source-state header uses application/json content with $ref to SourceState', async () => {
const spec = await getSpec()
const allParams: Array<Record<string, unknown>> = []
for (const pathItem of Object.values(spec.paths ?? {})) {
for (const op of Object.values(pathItem as Record<string, unknown>)) {
const operation = op as { parameters?: Array<Record<string, unknown>> } | undefined
allParams.push(...(operation?.parameters ?? []))
}
}
const stateParams = allParams.filter((p) => p.name === 'x-source-state')
expect(stateParams.length).toBeGreaterThan(0)
for (const param of stateParams) {
expect(param.schema).toBeUndefined()
const content = param.content as Record<string, Record<string, unknown>> | undefined
expect(content?.['application/json']).toBeDefined()
expect(content?.['application/json']?.schema).toMatchObject({
$ref: '#/components/schemas/SourceState',
})
}
})
})
Loading
Loading