Skip to content

Fix CI failures: Update OpenAPI spec with V2 endpoints#30

Merged
macintorsten merged 2 commits into
mainfrom
copilot/fix-openapi-spec-issues
Dec 21, 2025
Merged

Fix CI failures: Update OpenAPI spec with V2 endpoints#30
macintorsten merged 2 commits into
mainfrom
copilot/fix-openapi-spec-issues

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 21, 2025

The baseline OpenAPI spec in docs/openapi.json was missing V2 API endpoints, causing 10 test failures (8 in SampleControllerV2IntegrationTest, 1 in ApiSpecValidationTest, 1 in V1 tests).

Changes

  • Regenerated docs/openapi.json using .github/scripts/update-openapi-spec.sh

    • Added V2 endpoints: /api/v2/samples, /api/v2/samples/{id}, /api/v2/samples/statistics
    • Added StatisticsResponse schema with aggregation fields (totalCount, averageNumber, countByStatus, averagePriority)
    • Updated CreateSampleRequest schema with V2 description and priority field
    • Fixed operationId conflicts (V1 endpoints suffixed with _1)
  • Made update script executable (chmod +x on update-openapi-spec.sh)

Context

The spec was outdated because V2 API was implemented but the baseline spec wasn't regenerated. Tests validate responses against the checked-in spec, so mismatches fail CI.

// Missing endpoint now documented:
"/api/v2/samples/statistics": {
  "get": {
    "summary": "Get sample statistics",
    "responses": {
      "200": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/StatisticsResponse"
            }
          }
        }
      }
    }
  }
}

All 115 tests now pass. Full CI pipeline (mvn clean verify) verified.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Can you fix this issue?

Bug Report

Description

The CI build is failing with 10 test failures related to OpenAPI spec validation and schema extraction issues.

Failed Job

https://github.com/macintorsten/reflection/actions/runs/20409061802/job/58643077783

Root Causes

  1. Missing API endpoint in OpenAPI spec: The path `/api/v2/samples/statistics` is not documented in the OpenAPI spec, causing `SampleControllerV2IntegrationTest` tests to fail with:
    ```
    java.lang.RuntimeException: Path not found in OpenAPI spec: /api/v2/samples/statistics
    ```

  2. Outdated OpenAPI documentation: The `ApiSpecValidationTest.testApiSpecIsUpToDate` test is failing because the OpenAPI spec in `docs/openapi.json` doesn't match the current API implementation. Expected vs actual differences include:

    • `CreateSampleRequest` description changed from "Request to create a new sample" to "Request to create a new sample V2"
    • Schema properties and structure have diverged
  3. Schema validation error: `SampleControllerV1IntegrationTest.testGetSample_NotFound` is failing because the error response returns an integer status code (404) but the schema expects a string enum with values ["active", "inactive"]

Failed Tests

  • `ApiSpecValidationTest.testApiSpecIsUpToDate` (1 failure)
  • `SampleControllerV1IntegrationTest.testGetSample_NotFound` (1 failure)
  • `SampleControllerV2IntegrationTest` (8 errors across multiple tests)

Solution Steps

  1. Add missing endpoint to OpenAPI spec - Add the `/api/v2/samples/statistics` endpoint definition to `docs/openapi.json`

  2. Regenerate or update OpenAPI spec - If using auto-generation (springdoc, swagger-maven-plugin), regenerate the spec. Otherwise, manually sync the schema definitions with the current code

  3. Fix error response schema - Update the error response schema to properly handle HTTP status codes as integers, not as the "status" enum field

  4. Validate locally - Run `mvn test` to ensure all tests pass before committing

Impact

  • CI/CD pipeline is blocked
  • 10/115 tests failing
  • Build cannot proceed to deployment

The user has attached the following file paths as relevant context:

  • .github/instructions/development-workflow.instructions.md
  • .github/copilot-instructions.md

Created from VS Code.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Co-authored-by: macintorsten <18098382+macintorsten@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix CI build failures due to OpenAPI spec issues Fix CI failures: Update OpenAPI spec with V2 endpoints Dec 21, 2025
Copilot AI requested a review from macintorsten December 21, 2025 11:50
@macintorsten macintorsten marked this pull request as ready for review December 21, 2025 11:55
@macintorsten macintorsten merged commit f97bcd8 into main Dec 21, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants