Skip to content

Add happy path examples and Links to OpenAPI documentation #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 17, 2025

Enhanced the OpenAPI specification at docs/api/openapi.yaml to improve developer experience by adding comprehensive happy path examples and operational workflow links.

Changes Made

Happy Path Examples (8 total)

Added realistic, successful API interaction examples for all CRUD operations:

  • GET /lamps: lamps_list (multiple lamps with pagination) and empty_list (no lamps) examples
  • POST /lamps: created_lamp_on and created_lamp_off examples showing lamp creation with different initial states
  • GET /lamps/{lampId}: lamp_on and lamp_off examples demonstrating individual lamp retrieval
  • PUT /lamps/{lampId}: updated_to_on and updated_to_off examples showing status updates

OpenAPI 3.0 Links (10 total)

Implemented Links to document relationships between operations, enabling better workflow understanding:

  • POST /lamps → 3 links to GetLampById, UpdateLamp, DeleteLamp
  • GET /lamps → 3 links to individual lamp operations using any lamp ID from the list
  • GET /lamps/{lampId} → 2 links to UpdateLamp and DeleteLamp for the retrieved lamp
  • PUT /lamps/{lampId} → 2 links to GetLampById and DeleteLamp for the updated lamp

Example Data Quality

  • Uses consistent UUID patterns matching existing generated code (046b6c7f-0b8a-43b9-b35d-6489e6daee91)
  • Includes realistic ISO 8601 timestamps for createdAt and updatedAt fields
  • Demonstrates proper pagination with nextCursor and hasMore fields
  • Shows both lamp states (on/off) across all operations

Validation

  • ✅ OpenAPI Generator CLI validation passed with no issues
  • ✅ TypeScript type generation works correctly with enhanced specification
  • ✅ YAML syntax validation passed
  • ✅ Compatible with existing code generation in all language implementations

This enhancement significantly improves API documentation usability by providing clear examples of successful API interactions and showing how operations relate to each other in typical workflows.

Fixes #127.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] Add happy path examples and Links to OpenAPI documentation Add happy path examples and Links to OpenAPI documentation Aug 17, 2025
@Copilot Copilot AI requested a review from davideme August 17, 2025 09:02
Copilot finished work on behalf of davideme August 17, 2025 09:02
@davideme davideme marked this pull request as ready for review August 17, 2025 09:06
@Copilot Copilot AI review requested due to automatic review settings August 17, 2025 09:06
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the OpenAPI specification by adding comprehensive examples and operational workflow links to improve developer experience. The changes provide realistic API interaction examples for all CRUD operations and implement OpenAPI 3.0 Links to document relationships between operations.

  • Added 8 happy path examples showing successful API interactions for all endpoints
  • Implemented 10 OpenAPI Links to document operational workflows between endpoints
  • Enhanced documentation with consistent example data using proper UUID patterns and timestamps

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@@ -48,13 +90,60 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/LampCreate'
examples:
Copy link
Preview

Copilot AI Aug 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The examples are placed at the wrong level in the YAML structure. They should be nested under the media type (application/json) rather than at the requestBody level.

Copilot uses AI. Check for mistakes.

status: false
createdAt: "2024-01-15T10:15:45Z"
updatedAt: "2024-01-15T10:15:45Z"
links:
Copy link
Preview

Copilot AI Aug 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The links section is incorrectly indented. It should be at the same level as the response content, not nested within the 201 response.

Copilot uses AI. Check for mistakes.

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.

Add happy path examples and Links to OpenAPI documentation
2 participants