Update OpenAPI specs to match current implementation; split into frontend and integration surfaces with operation-level shared components - #49
Conversation
… (integration.yaml)
- Rewrite rest.yaml to match current implementation with all endpoints
- Add auth, users, API keys, export, import, schedule CRUD, batch
- Fix DTO schemas: add missing fields (type, classe in Group), fix required fields
- Fix type: number → type: integer for IDs and sizes
- Fix schedule endpoints (now under /schedule, not /levels/{levelId}/schedule)
- Fix GET /levels returns LevelDetailsDTO[], not LevelDTO[]
- Add proper JWT bearer security scheme with operationIds and tags
- Create integration.yaml for read-only integration API with X-Api-Key auth
- Add reusable parameters, responses, and proper error schemas
Co-authored-by: rivon0507 <107705903+rivon0507@users.noreply.github.com>
…istency Co-authored-by: rivon0507 <107705903+rivon0507@users.noreply.github.com>
rivon0507
left a comment
There was a problem hiding this comment.
@copilot
Continue working with the existing OpenAPI specifications.
There are currently two spec files:
- Frontend API spec
- Integration API spec
Do not merge them or change their roles.
Task
Introduce a shared specification file to centralize reusable definitions and reduce duplication, and correctly model base paths using OpenAPI servers.
Requirements
1. Create a shared file
Create a new OpenAPI YAML file that contains only reusable definitions:
components.schemascomponents.securitySchemes- reusable path definitions (for example
components.pathItems)
Do not include:
infoservers- top-level
paths - global
security
2. Move shared elements
Move all reusable elements common to both specs into the shared file:
- schemas
- shared path structures
- security schemes
3. Update the two existing specs
They must:
-
reference shared paths from the shared file instead of defining them inline
-
reference their global security scheme from the shared file
-
keep their own:
infoserverssecurity- path selection
4. Base path handling (important)
Currently the API prefixes are only mentioned in descriptions. Fix this.
Move base paths into the servers section:
- Frontend spec server URL must include
/api/v1 - Integration spec server URL must include
/integration
Paths themselves must not contain these prefixes.
5. Security rules
-
Each spec must define its own global security.
-
Shared paths must not be duplicated solely because authentication differs.
-
Public endpoints must explicitly declare:
security: []
6. Integration spec constraints
- Must remain a strict subset of frontend endpoints.
- Must contain only GET operations.
- Must not redefine shared structures.
7. Validity constraints
- YAML must be valid.
- OpenAPI must be valid.
- No duplicate keys.
$refmust not appear with sibling fields.- Do not change endpoint contracts or behavior.
Output format
Return:
- the new shared file
- modified sections of frontend spec
- modified sections of integration spec
- Create shared.yaml with centralized schemas, securitySchemes, parameters, responses, and pathItems for GET operations shared across both surfaces - Update rest.yaml: add global security, reference shared components, remove duplicated schemas/parameters, use $ref pathItems for GET-only paths - Update integration.yaml: all paths now $ref shared pathItems, components reference shared securitySchemes, no duplicated definitions - Fix all $ref sibling violations (use allOf wrapper for TeachingUnitDTO.level) - Public endpoints explicitly declare security: [] Co-authored-by: rivon0507 <107705903+rivon0507@users.noreply.github.com>
Co-authored-by: rivon0507 <107705903+rivon0507@users.noreply.github.com>
Changes made:
All |
rivon0507
left a comment
There was a problem hiding this comment.
@copilot
Continue refining the existing OpenAPI specifications.
Change the refactoring approach: do not share full paths between files. Instead, centralize operation definitions and have each spec compose its paths from those shared operations.
Goal
Make shared.yaml the single source of truth for all operation logic, schemas, and security schemes.
Required structure
shared.yaml
Must contain:
- all
components.schemas - all
components.securitySchemes - a reusable operations container under
components(for examplecomponents.x-operations) - inside that container: every operation definition (
get,post, etc.) for every endpoint in the API
Each operation must be fully defined (responses, parameters, requestBody, etc.).
If an endpoint is public, that operation must explicitly declare:
security: []
Do not define top-level paths here.
rest.yaml (frontend spec)
Must:
- keep its own
openapi,info,servers, and globalsecurity - define
servers: - url: /api/v1 - define its
pathsnormally, but each HTTP method must$refthe operation fromshared.yaml - not define schemas locally
- not define operations inline
Example pattern:
paths:
/rooms:
get:
$ref: 'shared.yaml#/components/x-operations/listRooms'
post:
$ref: 'shared.yaml#/components/x-operations/createRoom'
integration.yaml (integration spec)
Must:
- keep its own
openapi,info,servers, and globalsecurity - define
servers: - url: /integration - define
pathsthat reference only the subset of operations it exposes - include only GET operations
- not define schemas locally
- not define operations inline
Rules
-
Do not change endpoint behavior or contracts.
-
Do not rename schemas or endpoints.
-
Do not duplicate operations.
-
Do not inline operations in rest.yaml or integration.yaml.
-
YAML and OpenAPI must remain valid:
- no duplicate keys
$refmust not have sibling fields
Output
Return full contents of:
- shared.yaml
- rest.yaml
- integration.yaml
Include short inline comments explaining structural decisions.
- shared.yaml: move ALL schemas and operations into x-operations container (47 operations, 37 schemas, all security schemes and parameters) - rest.yaml: paths compose methods via $ref to shared x-operations, no local schemas or inline operations - integration.yaml: GET-only subset, same $ref pattern, no local definitions - Remove pathItems in favor of x-operations - Public endpoints explicitly declare security: [] - All $ref resolve, no sibling violations, YAML valid Co-authored-by: rivon0507 <107705903+rivon0507@users.noreply.github.com>
Done in d799ef0. Structure:
|
The single
rest.yamlspec had diverged significantly from the codebase — missing entire endpoint groups, incorrect paths, wrong schema fields, and no coverage of the integration API surface.shared.yaml— Single source of truth — new filecomponents.schemas(read DTOs, write DTOs, auth, user, API key, import/export, error/validation)components.x-operations— every GET, POST, PUT, and DELETE for every endpoint in the API, fully defined with responses, parameters, and requestBodybearerAuth(JWT) andapiKeyAuth(X-Api-Key header)levelId,groupId,teacherId,unitId,roomId,scheduleItemId,userId,apiKeyId)Unauthorized,Forbidden)security: []paths,servers, or globalsecurityrest.yaml— Frontend API (/api/v1)servers: [{url: /api/v1}]— base path modeled inservers, not in path prefixessecurity: [{bearerAuth: []}]$ref-ing operations fromshared.yaml:shared.yaml/levels/{levelId}/schedule→/schedule(matches actualScheduleControllermapping)GET /levelsreturnsLevelDetailsDTO[], notLevelDTO[]type/classefields to Group DTOs, correctedabbreviationas required,type: number→type: integer, format: int64for all IDs/sizesintegration.yaml— Integration API (/integration) — new fileservers: [{url: /integration}]security: [{apiKeyAuth: []}]Validity
$refsibling violations fixed (TeachingUnitDTO.levelusesallOfwrapper)$reflinks resolve, no duplicate keys or operationIdsOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.