api: GET /api/system + POST /api/explore, OpenAPI spec updated in code
This commit is contained in:
+22
-1
@@ -4,7 +4,28 @@ import { openApiSpec } from './openapi';
|
||||
|
||||
describe('OpenAPI spec', () => {
|
||||
it('documents every public endpoint', () => {
|
||||
expect(Object.keys(openApiSpec.paths).sort()).toEqual(['/api/jump', '/api/version', '/api/world']);
|
||||
expect(Object.keys(openApiSpec.paths).sort()).toEqual([
|
||||
'/api/explore',
|
||||
'/api/jump',
|
||||
'/api/system',
|
||||
'/api/version',
|
||||
'/api/world',
|
||||
]);
|
||||
});
|
||||
|
||||
it('describes the system endpoints as SystemState in and out', () => {
|
||||
const system = openApiSpec.paths['/api/system'].get.responses[200].content['application/json'].schema;
|
||||
expect(system.$ref).toBe('#/components/schemas/SystemState');
|
||||
|
||||
const explore = openApiSpec.paths['/api/explore'].post;
|
||||
expect(explore.requestBody.content['application/json'].schema.$ref).toBe('#/components/schemas/ExploreRequest');
|
||||
expect(explore.responses[200].content['application/json'].schema.$ref).toBe('#/components/schemas/ExploreResult');
|
||||
// ExploreResult extends SystemState with the scan outcome.
|
||||
const exploreResult = openApiSpec.components.schemas.ExploreResult as { allOf: { $ref?: string }[] };
|
||||
expect(exploreResult.allOf[0].$ref).toBe('#/components/schemas/SystemState');
|
||||
for (const status of ['400', '404', '409'] as const) {
|
||||
expect(explore.responses[status].content['application/json'].schema.$ref).toBe('#/components/schemas/Error');
|
||||
}
|
||||
});
|
||||
|
||||
it('describes the world endpoints as WorldState in and out', () => {
|
||||
|
||||
Reference in New Issue
Block a user