Skip to content

Commit 036eb58

Browse files
authored
chore: synced file(s) with sumup/apis (#237)
1 parent 8e3388d commit 036eb58

17 files changed

Lines changed: 794 additions & 446 deletions

DOCUMENTATION.md

Lines changed: 400 additions & 276 deletions
Large diffs are not rendered by default.

checkouts.go

Lines changed: 115 additions & 75 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

customers.go

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/cmd/codegen/pkg/builder/godoc.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@ func operationParamsGodoc(name string, operation *v3.Operation) string {
4545
return formatGodoc(fmt.Sprintf("%s are query parameters for %s.", name, operation.OperationId))
4646
}
4747

48+
// clientGodoc creates godoc for a generated client from the OpenAPI tag description.
49+
func clientGodoc(name string, tag *base.Tag) string {
50+
out := new(strings.Builder)
51+
52+
fmt.Fprintf(out, "%s provides access to the %s API.", name, cmp.Or(tag.Name, "tag"))
53+
54+
if tag != nil && strings.TrimSpace(tag.Description) != "" {
55+
fmt.Fprintf(out, "\n\n%s", strings.TrimSpace(tag.Description))
56+
}
57+
58+
return formatGodoc(out.String())
59+
}
60+
4861
// schemaGodoc creates godoc for a schema.
4962
func schemaGodoc(name string, schema *base.Schema) string {
5063
out := new(strings.Builder)

internal/cmd/codegen/pkg/builder/out.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type templateData struct {
2525
Aliases []Alias
2626
Types []Writable
2727
Service string
28+
ServiceDoc string
2829
Methods []*Method
2930
}
3031

@@ -75,6 +76,7 @@ func (b *Builder) generateResource(tagName string, paths *v3.Paths) error {
7576
Types: types,
7677
Methods: methods,
7778
Service: strcase.ToCamel(tag.Name),
79+
ServiceDoc: clientGodoc(strcase.ToCamel(tag.Name)+"Client", tag),
7880
}); err != nil {
7981
return err
8082
}

internal/cmd/codegen/templates/resource.go.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ import (
3232
{{- end }}
3333

3434
{{ if ne (len .Methods) 0 }}
35+
{{- with .ServiceDoc}}
36+
// {{.}}
37+
{{- end }}
3538
type {{.Service}}Client struct {
3639
c *client.Client
3740
}

members.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

memberships.go

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

merchants.go

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

openapi.json

Lines changed: 76 additions & 68 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)