You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following templates were customized but don't need to be adjusted when updating the Go SDK generator to a new a newer upstream version:
6
+
7
+
-`configuration.mustache`: This template was entirely overwritten so we can use our custom [configuration struct](https://github.com/stackitcloud/stackit-sdk-go/blob/c3b04bc3cb8bf93de351fd7b1b04ac11de78ff89/core/config/config.go#L78) from our Go SDK core module. By default the OpenAPI generator would generate a new configuration struct for each service API version.
8
+
9
+
The following templates were customized and need to be checked for adjustments when updating the Go SDK generator to a newer upstream version:
10
+
11
+
-`client.mustache`:
12
+
- Removed the generation of the `GenericOpenAPIError` struct which would be generated for each service API version by default. Instead use the `GenericOpenAPIError` struct from the [Go SDK core module](https://github.com/stackitcloud/stackit-sdk-go/blob/c3b04bc3cb8bf93de351fd7b1b04ac11de78ff89/core/oapierror/oapierror.go#L15).
13
+
- Our custom `GenericOpenAPIError` struct from the core module has additional fields like the http status code, ... which the default one doesn't have.
14
+
- Customized the `NewAPIClient` func to use the configuration struct and the authentication from the core SDK module.
15
+
-`api.mustache`
16
+
- Added customization to capture the HTTP request and response in the context (like it was done before the multi API version support was implemented in the Go SDK generator).
17
+
- Use the `GenericOpenAPIError` struct from the core module instead of the default one (see previous section of `client.mustache`).
18
+
- Don't return the `http.Response` param which the OpenAPI generator returns by default.
19
+
- It was done like that before the multi API version support was implemented in the Go SDK generator.
20
+
- Furthermore, it would when using the STACKIT Go SDK require a lot of boilerplate code after each SDK API call to do a nil check, close the http response body and handle the potential error.
21
+
22
+
## Custom templates
23
+
24
+
The custom templates don't need to be adjusted when updating the Go SDK generator to a new a newer upstream version.
25
+
26
+
-`custom/api_mock.mustache`: This template was added to allow easy mocking of SDK API calls in unit test implementations.
Copy file name to clipboardExpand all lines: languages/golang/templates/api.mustache
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -482,6 +482,7 @@ func (a *{{{classname}}}Service) {{nickname}}Execute(r {{#structPrefix}}{{&class
482
482
{{! TEMPLATE CUSTOMIZATION - BEGIN - use the GenericOpenAPIError struct from the core module instead of the one generated by OpenAPI generator by default}}
{{! TEMPLATE CUSTOMIZATION - END - use the GenericOpenAPIError struct from the core module instead of the one generated by OpenAPI generator by default}}
485
486
{{! TEMPLATE CUSTOMIZATION - BEGIN - don't return http response - would require closing after each SDK API call to prevent resource leaks }}
0 commit comments