Skip to content

Commit

Permalink
Fix warnings during generation due to missing summary and description (
Browse files Browse the repository at this point in the history
…#178)

Currently, if you run `make generate | grep WARN` there are thousands of
warnings due to endpoints missing summaries or descriptions.

The overwhelming number of warnings makes it harder to spot genuine
errors in the templates - e.g. #177.

This change wraps each unconditional reference to summary or description
in an `{{#if}}` to cure the warnings.
  • Loading branch information
maxb authored May 29, 2023
1 parent 50806fa commit b48642a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion generate/templates/api.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ type {{cut classname "Api"}} struct {

{{#if isDeprecated}}
// Deprecated{{/if}}
// {{operationId}} {{{summary}}}{{#if notes}}
// {{operationId}} {{#if summary}}{{{summary}}}{{/if}}{{#if notes}}
// {{{notes}}}{{/if}}{{#each pathParams}}{{#endsWith baseName "_mount_path"}}{{else}}{{#with description}}
// {{paramName}}: {{.}}{{/with}}{{/endsWith}}{{/each}}{{#each bodyParams}}{{#with description}}
// {{paramName}}: {{.}}{{/with}}{{/each}}{{#each queryParams}}{{#neq paramName "list"}}{{#with description}}
Expand Down
10 changes: 5 additions & 5 deletions generate/templates/api_doc.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

Method | HTTP request | Description
------------- | ------------- | -------------
{{#with operations}}{{#each operation}}{{#endsWith operationId "2"}}{{else}}{{#endsWith operationId "3"}}{{else}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{summary}}
{{#with operations}}{{#each operation}}{{#endsWith operationId "2"}}{{else}}{{#endsWith operationId "3"}}{{else}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#if summary}}{{summary}}{{/if}}
{{/endsWith}}{{/endsWith}}{{/each}}{{/with}}
{{#with operations}}
{{#each operation}}{{#endsWith operationId "2"}}{{else}}{{#endsWith operationId "3"}}{{else}}
## {{{operationId}}}
{{{summary}}}{{#if notes}}
{{#if summary}}{{{summary}}}{{/if}}{{#if notes}}
{{{unescapedNotes}}}{{/if}}
Expand All @@ -38,7 +38,7 @@ func main() {
log.Fatal(err)
}
{{#each allParams}}{{#if isPathParam}}{{#endsWith baseName "_mount_path"}}{{else}}
{{paramName}} := {{{vendorExtensions.x-go-example}}} // {{{dataType}}} | {{{description}}}{{#with defaultValue}} (defaults to {{{.}}}){{/with}}{{/endsWith}}{{/if}}{{/each}}{{#each bodyParams}}
{{paramName}} := {{{vendorExtensions.x-go-example}}} // {{{dataType}}} | {{#if description}}{{{description}}}{{/if}}{{#with defaultValue}} (defaults to {{{.}}}){{/with}}{{/endsWith}}{{/if}}{{/each}}{{#each bodyParams}}
request := schema.New{{{dataType}}}WithDefaults(){{/each}}{{#each allParams}}{{#if isQueryParam}}{{#neq paramName "list"}}
{{paramName}} := {{{vendorExtensions.x-go-example}}} // {{{dataType}}} | {{{description}}}{{#with defaultValue}} (defaults to {{{.}}}){{/with}}{{/neq}}{{/if}}{{/each}}
resp, err := client.{{cut classname "Api"}}.{{operationId}}(
Expand All @@ -63,14 +63,14 @@ func main() {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**ctx** | **context.Context** | context for request cancellation {{/if}}{{/each}}{{#each pathParams}}{{#endsWith baseName "_mount_path"}}{{else}}
**{{paramName}}** | {{#unless isPrimitiveType}}{{#unless isFile}}[{{/unless}}{{/unless}}**{{dataType}}**{{#unless isPrimitiveType}}{{#unless isFile}}]({{baseType}}.md){{/unless}}{{/unless}} | {{description}} | {{#with defaultValue}}[default to {{.}}]{{/with}}{{/endsWith}}{{/each}}
**{{paramName}}** | {{#unless isPrimitiveType}}{{#unless isFile}}[{{/unless}}{{/unless}}**{{dataType}}**{{#unless isPrimitiveType}}{{#unless isFile}}]({{baseType}}.md){{/unless}}{{/unless}} | {{#if description}}{{description}}{{/if}} | {{#with defaultValue}}[default to {{.}}]{{/with}}{{/endsWith}}{{/each}}
### Other Parameters
{{#each allParams}}{{#if @last}}
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------{{/if}}{{/each}}{{#each allParams}}
{{#unless isPathParam}} **{{paramName}}** | {{#if isContainer}}{{#if isArray}}{{#with items}}{{#unless isPrimitiveType}}{{#unless isFile}}[{{/unless}}{{/unless}}**[]{{dataType}}**{{#unless isPrimitiveType}}{{#unless isFile}}]({{#unless baseType}}{{dataType}}{{/unless}}{{baseType}}.md){{/unless}}{{/unless}}{{/with}}{{/if}}{{#if isMap}}{{#with items}}{{#unless isPrimitiveType}}{{#unless isFile}}[{{/unless}}{{/unless}}**map[string]{{dataType}}**{{#unless isPrimitiveType}}{{#unless isFile}}]({{#unless baseType}}{{dataType}}{{/unless}}{{baseType}}.md){{/unless}}{{/unless}}{{/with}}{{/if}}{{/if}}{{#unless isContainer}}{{#unless isPrimitiveType}}{{#unless isFile}}[{{/unless}}{{/unless}}**{{dataType}}**{{#unless isPrimitiveType}}{{#unless isFile}}]({{#unless baseType}}{{dataType}}{{/unless}}{{baseType}}.md){{/unless}}{{/unless}}{{/unless}} | {{description}} | {{#with defaultValue}}[default to {{.}}]{{/with}}{{/unless}}{{/each}}
{{#unless isPathParam}} **{{paramName}}** | {{#if isContainer}}{{#if isArray}}{{#with items}}{{#unless isPrimitiveType}}{{#unless isFile}}[{{/unless}}{{/unless}}**[]{{dataType}}**{{#unless isPrimitiveType}}{{#unless isFile}}]({{#unless baseType}}{{dataType}}{{/unless}}{{baseType}}.md){{/unless}}{{/unless}}{{/with}}{{/if}}{{#if isMap}}{{#with items}}{{#unless isPrimitiveType}}{{#unless isFile}}[{{/unless}}{{/unless}}**map[string]{{dataType}}**{{#unless isPrimitiveType}}{{#unless isFile}}]({{#unless baseType}}{{dataType}}{{/unless}}{{baseType}}.md){{/unless}}{{/unless}}{{/with}}{{/if}}{{/if}}{{#unless isContainer}}{{#unless isPrimitiveType}}{{#unless isFile}}[{{/unless}}{{/unless}}**{{dataType}}**{{#unless isPrimitiveType}}{{#unless isFile}}]({{#unless baseType}}{{dataType}}{{/unless}}{{baseType}}.md){{/unless}}{{/unless}}{{/unless}} | {{#if description}}{{description}}{{/if}} | {{#with defaultValue}}[default to {{.}}]{{/with}}{{/unless}}{{/each}}
{{#with returnType}}{{#with returnTypeIsPrimitive}}**{{{returnType}}}**{{/with}}{{#unless returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/unless}}{{/with}}{{#unless returnType}} (empty response body){{/unless}}
Expand Down
2 changes: 1 addition & 1 deletion generate/templates/model_doc.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------{{#with vendorExtensions.x-is-one-of-interface}}
**{{classname}}Interface** | **interface { {{#with discriminator}}{{propertyGetter}}() {{propertyType}}{{/with}} }** | An interface that can hold any of the proper implementing types |
{{/with}}{{#unless vendorExtensions.x-is-one-of-interface}}
{{#each vars}}**{{name}}** | {{#unless required}}Pointer to {{/unless}}{{#if isContainer}}{{#if isArray}}{{#with items}}{{#unless isPrimitiveType}}{{#unless isFile}}[{{/unless}}{{/unless}}**[]{{dataType}}**{{#unless isPrimitiveType}}{{#unless isFile}}]({{dataType}}.md){{/unless}}{{/unless}}{{/with}}{{/if}}{{#if isMap}}{{#with items}}{{#unless isPrimitiveType}}{{#unless isFile}}[{{/unless}}{{/unless}}**map[string]{{dataType}}**{{#unless isPrimitiveType}}{{#unless isFile}}]({{#unless baseType}}{{dataType}}{{/unless}}{{baseType}}.md){{/unless}}{{/unless}}{{/with}}{{/if}}{{/if}}{{#unless isContainer}}{{#unless isPrimitiveType}}{{#unless isFile}}{{#unless isDateTime}}[{{/unless}}{{/unless}}{{/unless}}**{{dataType}}**{{#unless isPrimitiveType}}{{#unless isFile}}{{#unless isDateTime}}]({{#unless baseType}}{{dataType}}{{/unless}}{{baseType}}.md){{/unless}}{{/unless}}{{/unless}}{{/unless}} | {{description}} | {{#unless required}}[optional] {{/unless}}{{#if isReadOnly}}[readonly] {{/if}}{{#with defaultValue}}[default to {{{.}}}]{{/with}}
{{#each vars}}**{{name}}** | {{#unless required}}Pointer to {{/unless}}{{#if isContainer}}{{#if isArray}}{{#with items}}{{#unless isPrimitiveType}}{{#unless isFile}}[{{/unless}}{{/unless}}**[]{{dataType}}**{{#unless isPrimitiveType}}{{#unless isFile}}]({{dataType}}.md){{/unless}}{{/unless}}{{/with}}{{/if}}{{#if isMap}}{{#with items}}{{#unless isPrimitiveType}}{{#unless isFile}}[{{/unless}}{{/unless}}**map[string]{{dataType}}**{{#unless isPrimitiveType}}{{#unless isFile}}]({{#unless baseType}}{{dataType}}{{/unless}}{{baseType}}.md){{/unless}}{{/unless}}{{/with}}{{/if}}{{/if}}{{#unless isContainer}}{{#unless isPrimitiveType}}{{#unless isFile}}{{#unless isDateTime}}[{{/unless}}{{/unless}}{{/unless}}**{{dataType}}**{{#unless isPrimitiveType}}{{#unless isFile}}{{#unless isDateTime}}]({{#unless baseType}}{{dataType}}{{/unless}}{{baseType}}.md){{/unless}}{{/unless}}{{/unless}}{{/unless}} | {{#if description}}{{description}}{{/if}} | {{#unless required}}[optional] {{/unless}}{{#if isReadOnly}}[readonly] {{/if}}{{#with defaultValue}}[default to {{{.}}}]{{/with}}
{{/each}}
{{/unless}}

Expand Down
2 changes: 1 addition & 1 deletion generate/templates/model_simple.handlebars
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// {{classname}} {{{description}}}{{#unless description}}struct for {{{classname}}}{{/unless}}
// {{classname}} {{#if description}}{{{description}}}{{else}}struct for {{{classname}}}{{/if}}
type {{classname}} struct {
{{#with parent}}
{{#unless isMap}}
Expand Down

0 comments on commit b48642a

Please sign in to comment.