Skip to content

Conversation

@jonathandavies-CS
Copy link
Contributor

No description provided.

@ianmiell ianmiell requested a review from Copilot October 2, 2025 16:35
Copy link
Contributor

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

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.

Comment on lines +15 to +25
type HTTPError struct {
StatusCode int
Err error
}

func NewHTTPError(status int, err error) HTTPError {
return HTTPError{
StatusCode: status,
Err: err,
}
}
Copy link
Contributor

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.

Copy link
Contributor Author

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.

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.

3 participants