lib/openapi.ts is the machine-readable spec (served at /api/openapi) per AGENTS.md; info.version sourced from package.json. Unit tests pin the spec shape and version sync.
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import pkg from '@/package.json';
|
|
|
|
// OpenAPI 3.1 document for the app's public JSON API, kept in code so it can be
|
|
// served machine-readable at /api/openapi (see AGENTS.md "## API"). Must be updated
|
|
// whenever an endpoint changes.
|
|
export const openApiSpec = {
|
|
openapi: '3.1.0',
|
|
info: {
|
|
title: 'SpaceWanderer API',
|
|
description:
|
|
'JSON API for SpaceWanderer — a single-player turn-based space adventure. Scaffold stage: app metadata only; game endpoints (turn actions, state snapshots) land with the first game systems.',
|
|
// Sourced from package.json so it stays in sync with every version bump.
|
|
version: pkg.version,
|
|
},
|
|
// Empty url = current origin (the spec is served from the same host that runs the API).
|
|
servers: [{ url: '' }],
|
|
paths: {
|
|
'/api/version': {
|
|
get: {
|
|
summary: 'App version',
|
|
description: 'The running app version, read from package.json.',
|
|
operationId: 'getVersion',
|
|
responses: {
|
|
200: {
|
|
description: 'Current app version',
|
|
content: {
|
|
'application/json': {
|
|
schema: { $ref: '#/components/schemas/AppVersion' },
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
components: {
|
|
schemas: {
|
|
AppVersion: {
|
|
type: 'object',
|
|
properties: {
|
|
version: { type: 'string', description: 'Semver of the running build' },
|
|
},
|
|
required: ['version'],
|
|
},
|
|
},
|
|
},
|
|
};
|