Skip to content

Commit eb10785

Browse files
aorabdeldependabot[bot]monty-botacabarbaye
authored
✨ Extend the code generator for Collections by extending their functionality to follow links (#76)
### Description This change extends the generator for endpoints with a `Get` method that returns a `Collection` (`x-collection` or SimpleCollection schemas), and defines two methods for following links for each endpoint, one in the APIService struct and one in the APIRequest struct. The generation is based on the same methods that executes a Get request, the original Execute method is parsed into an AST, copied and modified to be able to follow links, by adding a link argument, and modifying the path to follow that argument. ### Test Coverage The test added only tests generation for the FollowLinks functions as the testing for `x-redact` in Collections is already part of existing tests. - [X] This change is covered by existing or additional automated tests. - [ ] Manual testing has been performed (and evidence provided) as automated testing was not feasible. - [ ] Additional tests are not required for this change (e.g. documentation update). --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: aorabdel <aorabdel@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Monty Bot <monty-bot@arm.com> Co-authored-by: Adrien CABARBAYE <adrien.cabarbaye@arm.com> Co-authored-by: acabarbaye <acabarbaye@users.noreply.github.com>
1 parent 6768022 commit eb10785

36 files changed

Lines changed: 11970 additions & 3134 deletions

.github/workflows/update-client.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ jobs:
9595
go mod tidy
9696
go run main.go -i ../all-service-definition/all-def-flat.yaml -o ../extensions/extension_entities.gen.go -t templates/entities.go.tmpl -g collections
9797
go run main.go -i ../all-service-definition/all-def-flat.yaml -o ../extensions/extension_jobs.gen.go -t templates/jobs.go.tmpl -g jobs
98+
go run main.go -i ../all-service-definition/all-def-flat.yaml -o ../extensions/extension_link_followers.gen.go -t templates/linkfollowers.go.tmpl -g links
9899
- name: Copy extensions to client
99100
run: |
100101
if [ -d ./extensions/ ] ; then cp -r extensions/. ${{ env.go_module }}/ ; fi

changes/20250328143030.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
:sparkles: Extend the code generator for Collections by extending their functionality to follow links

changes/20250328152148.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Updated client due to schema changes

changes/20250328182830.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Updated client due to schema changes

changes/20250328185439.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Updated client due to schema changes

changes/20250328212543.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Updated client due to schema changes

client/extension_builders_link.go

Lines changed: 0 additions & 158 deletions
This file was deleted.

client/extension_buildjobs_link.go

Lines changed: 0 additions & 158 deletions
This file was deleted.

client/extension_client.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,3 @@ func (c *APIClient) PrepareRequest(
3535
func (c *APIClient) CallAPI(request *http.Request) (*http.Response, error) {
3636
return c.callAPI(request)
3737
}
38-
39-
// wrapParameterAddToHeader wraps wrapParameterAddToHeaderOrQuery to avoid future breaking changes.
40-
func wrapParameterAddToHeader(headerOrQueryParams interface{}, keyPrefix string, obj interface{}, collectionType string) {
41-
parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, obj, "simple", collectionType)
42-
}
43-
44-
// wrapParameterAddToQuery wraps wrapParameterAddToHeaderOrQuery to avoid future breaking changes.
45-
func wrapParameterAddToQuery(headerOrQueryParams interface{}, keyPrefix string, obj interface{}, collectionType string) {
46-
parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, obj, "form", collectionType)
47-
}

0 commit comments

Comments
 (0)