-
Notifications
You must be signed in to change notification settings - Fork 0
feat: add OpenAPI/Swagger spec module for auto-generating HTTP routes #134
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
aa2aed1
feat: add OpenAPI/Swagger spec module for auto-generating HTTP routes…
intel352 037a746
fix: register openapi module type in schema and fix spec_file path re…
intel352 6f5d7ee
fix(openapi): address review feedback — correctness, security, and pe…
Copilot 475de78
fix(openapi): address remaining unresolved review comments on OpenAPI…
Copilot 8b469c7
fix: add admin_test.go with corrected TestMergeInto_WithRealAdminConfig
intel352 cee546a
fix(openapi): address remaining review comments — validation, content…
Copilot 98ab280
Merge branch 'main' into feat/issue-79-openapi
intel352 55e173d
fix(cmd): restore missing multiWorkflowAddr flag definition (#152)
Copilot 9a622a8
fix(openapi): harden body validation, determinism, and router wiring …
Copilot 8c76673
Merge branch 'main' into feat/issue-79-openapi
intel352 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| requires: | ||
| plugins: | ||
| - name: workflow-plugin-http | ||
| - name: workflow-plugin-openapi | ||
|
|
||
| modules: | ||
| # HTTP server on port 8095 | ||
| - name: petstore-server | ||
| type: http.server | ||
| config: | ||
| address: ":8095" | ||
|
|
||
| # HTTP router — the OpenAPI module registers routes onto this | ||
| - name: petstore-router | ||
| type: http.router | ||
| dependsOn: | ||
| - petstore-server | ||
|
|
||
| # OpenAPI module — parses the spec and generates routes | ||
| - name: pet-store-api | ||
| type: openapi | ||
| dependsOn: | ||
| - petstore-router | ||
| config: | ||
| # NOTE: spec_file is resolved relative to this config file's directory | ||
| # via the _config_dir mechanism in config.ResolvePathInConfig. | ||
| spec_file: specs/petstore.yaml | ||
| base_path: /api/v1 | ||
| router: petstore-router | ||
| validation: | ||
| request: true | ||
| response: false | ||
| swagger_ui: | ||
| enabled: true | ||
| path: /docs | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| openapi: "3.0.0" | ||
| info: | ||
| title: Petstore API | ||
| version: "1.0.0" | ||
| description: A sample pet store API based on the OpenAPI 3.0 Petstore example | ||
|
|
||
| paths: | ||
| /pets: | ||
| get: | ||
| operationId: listPets | ||
| summary: List all pets | ||
| parameters: | ||
| - name: limit | ||
| in: query | ||
| required: false | ||
| schema: | ||
| type: integer | ||
| minimum: 1 | ||
| maximum: 100 | ||
| responses: | ||
| "200": | ||
| description: A list of pets | ||
| "400": | ||
| description: Invalid request | ||
| post: | ||
| operationId: createPet | ||
| summary: Create a pet | ||
| requestBody: | ||
| required: true | ||
| content: | ||
| application/json: | ||
| schema: | ||
| type: object | ||
| required: | ||
| - name | ||
| properties: | ||
| name: | ||
| type: string | ||
| minLength: 1 | ||
| maxLength: 100 | ||
| tag: | ||
| type: string | ||
| maxLength: 50 | ||
| responses: | ||
| "201": | ||
| description: Null response | ||
| "400": | ||
| description: Validation error | ||
|
|
||
| /pets/{petId}: | ||
| get: | ||
| operationId: showPetById | ||
| summary: Info for a specific pet | ||
| parameters: | ||
| - name: petId | ||
| in: path | ||
| required: true | ||
| schema: | ||
| type: integer | ||
| responses: | ||
| "200": | ||
| description: Expected response to a valid request | ||
| "404": | ||
| description: Pet not found | ||
|
|
||
| /pets/{petId}/status: | ||
| put: | ||
| operationId: updatePetStatus | ||
| summary: Update pet status | ||
| parameters: | ||
| - name: petId | ||
| in: path | ||
| required: true | ||
| schema: | ||
| type: integer | ||
| requestBody: | ||
| required: true | ||
| content: | ||
| application/json: | ||
| schema: | ||
| type: object | ||
| required: | ||
| - status | ||
| properties: | ||
| status: | ||
| type: string | ||
| enum: | ||
| - available | ||
| - pending | ||
| - sold | ||
| responses: | ||
| "200": | ||
| description: Updated | ||
| "400": | ||
| description: Invalid status | ||
| "404": | ||
| description: Pet not found |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example configuration uses a relative path "example/specs/petstore.yaml" for the spec_file on line 25. This path is relative to where the engine binary is executed from, which could cause confusion if the config is run from a different directory. Consider either using an absolute path, or documenting in a comment that paths are resolved relative to the config file's directory (via the _config_dir mechanism in config.ResolvePathInConfig).