feat(api): GET /api/events endpoint + OpenAPI
Latest game events, newest first; auto-initializes like the other reads. ?limit= defaults to 50 (cap 200), non-integer/out-of-range → 400. OpenAPI spec gains the path + Event schema (14 -> 15 paths).
This commit is contained in:
@@ -523,6 +523,40 @@ export const openApiSpec = {
|
||||
},
|
||||
},
|
||||
},
|
||||
'/api/events': {
|
||||
get: {
|
||||
summary: 'Event log',
|
||||
description: "The save's game events, newest first — every action (new game, jump, scan, research, ship work, mission) appends one. Auto-initializes a new game when no save exists yet.",
|
||||
operationId: 'getEvents',
|
||||
parameters: [
|
||||
{
|
||||
name: 'limit',
|
||||
in: 'query',
|
||||
required: false,
|
||||
schema: { type: 'integer', minimum: 1, maximum: 200 },
|
||||
description: 'How many of the latest events to return (default 50)',
|
||||
},
|
||||
],
|
||||
responses: {
|
||||
200: {
|
||||
description: 'Latest events, newest first',
|
||||
content: {
|
||||
'application/json': {
|
||||
schema: { type: 'array', items: { $ref: '#/components/schemas/Event' } },
|
||||
},
|
||||
},
|
||||
},
|
||||
400: {
|
||||
description: 'limit is not an integer in [1, 200]',
|
||||
content: {
|
||||
'application/json': {
|
||||
schema: { $ref: '#/components/schemas/Error' },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
components: {
|
||||
schemas: {
|
||||
@@ -682,6 +716,17 @@ export const openApiSpec = {
|
||||
},
|
||||
required: ['id', 'type', 'description', 'targetSystemId', 'conditionKind', 'progressTarget', 'progress', 'rewardKind', 'rewardQty', 'state'],
|
||||
},
|
||||
Event: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: { type: 'integer' },
|
||||
turn: { type: 'integer', description: 'The save turn the action cost (new_game is 0)' },
|
||||
type: { type: 'string', enum: ['new_game', 'jump', 'explore', 'research', 'upgrade', 'expand', 'build', 'mission'] },
|
||||
message: { type: 'string' },
|
||||
createdAt: { type: 'string', description: 'ISO 8601 timestamp' },
|
||||
},
|
||||
required: ['id', 'turn', 'type', 'message', 'createdAt'],
|
||||
},
|
||||
UpgradeRequest: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
|
||||
Reference in New Issue
Block a user