-
Notifications
You must be signed in to change notification settings - Fork 2
BCH 994: Add single post endpoint for component/capability #284
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
base: main
Are you sure you want to change the base?
Conversation
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.
Pull Request Overview
Adds singular POST endpoints to create a single component or capability for a component definition instead of using only the existing bulk endpoints. Introduces corresponding handlers, tests, and Swagger documentation.
- Adds POST /:id/component and POST /:id/capability handlers with validation and DB persistence.
- Adds integration tests for single component and capability creation (success and failure paths).
- Updates Swagger (YAML/JSON/docs.go) to document new endpoints.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 14 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/api/handler/oscal/component_definition_integration_test.go | Adds integration tests for new single component and capability creation endpoints. |
| internal/api/handler/oscal/component_definition.go | Registers new routes and implements CreateComponent and CreateCapability handlers. |
| docs/swagger.yaml | Documents the new single creation endpoints. |
| docs/swagger.json | Generated Swagger JSON including new endpoints. |
| docs/docs.go | Generated Go Swagger doc template including new endpoints. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
internal/api/handler/oscal/component_definition_integration_test.go
Outdated
Show resolved
Hide resolved
| type HTTPError struct { | ||
| StatusCode int | ||
| Err error | ||
| } | ||
|
|
||
| func NewHTTPError(status int, err error) HTTPError { | ||
| return HTTPError{ | ||
| StatusCode: status, | ||
| Err: err, | ||
| } | ||
| } |
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.
There exists an API Error for this type of error already.
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.
I need the status code to propagate back from the function that returns this error. Of course I can just return the err in said function (getExistingComponentDefinition) but it would mean repeating the same code everywhere it's used. I could put the status code into the API Error struct - just most of the time it won't be used.
No description provided.