Skip to content

Commit

Permalink
fix: add api mustache for correct import paths in readme documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
will7200 committed Jul 20, 2020
1 parent 927740f commit 04264ec
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 5 deletions.
89 changes: 89 additions & 0 deletions api/templates/coinbase/api_doc.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
# {{invokerPackage}}\{{classname}}{{#description}}

{{description}}{{/description}}

All URIs are relative to *{{basePath}}*

Method | HTTP request | Description
------------- | ------------- | -------------
{{#operations}}{{#operation}}[**{{operationId}}**]({{classname}}.md#{{operationId}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
{{/operation}}{{/operations}}

{{#operations}}
{{#operation}}

## {{{operationId}}}

> {{#returnType}}{{{.}}} {{/returnType}}{{{operationId}}}(ctx{{#pathParams}}, {{paramName}}{{/pathParams}}){{#allParams}}{{^isPathParam}}.{{vendorExtensions.x-export-param-name}}({{paramName}}){{/isPathParam}}{{/allParams}}.Execute()

{{{summary}}}{{#notes}}

{{{unespacedNotes}}}{{/notes}}

### Example

```go
package main

import (
"context"
"fmt"
"os"
{{goImportAlias}} "{{topLevelPackageName}}/{{modulePackageName}}"
)

func main() {
{{#allParams}}
{{paramName}} := {{{vendorExtensions.x-go-example}}} // {{{dataType}}} | {{{description}}}{{^required}} (optional){{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
{{/allParams}}

configuration := {{goImportAlias}}.NewConfiguration()
api_client := {{goImportAlias}}.NewAPIClient(configuration)
resp, r, err := api_client.{{classname}}.{{operationId}}(context.Background(), {{#requiredParams}}{{paramName}}{{^-last}}, {{/-last}}{{/requiredParams}}){{#optionalParams}}.{{{vendorExtensions.x-export-param-name}}}({{{paramName}}}){{/optionalParams}}.Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `{{classname}}.{{operationId}}``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}
{{#returnType}}
// response from `{{operationId}}`: {{{.}}}
fmt.Fprintf(os.Stdout, "Response from `{{classname}}.{{operationId}}`: %v\n", resp)
{{/returnType}}
}
```

### Path Parameters

{{^allParams}}This endpoint does not need any parameter.{{/allParams}}{{#pathParams}}{{#-last}}
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc.{{/-last}}{{/pathParams}}{{#pathParams}}
**{{paramName}}** | {{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}} | {{description}} | {{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}{{/pathParams}}

### Other Parameters

Other parameters are passed through a pointer to a api{{{nickname}}}Request struct via the builder pattern
{{#allParams}}{{#-last}}

Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------{{/-last}}{{/allParams}}{{#allParams}}
{{^isPathParam}} **{{paramName}}** | {{^isPrimitiveType}}{{^isFile}}[{{/isFile}}{{/isPrimitiveType}}**{{dataType}}**{{^isPrimitiveType}}{{^isFile}}]({{baseType}}.md){{/isFile}}{{/isPrimitiveType}} | {{description}} | {{#defaultValue}}[default to {{defaultValue}}]{{/defaultValue}}{{/isPathParam}}{{/allParams}}

### Return type

{{#returnType}}{{#returnTypeIsPrimitive}}**{{{returnType}}}**{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}[**{{{returnType}}}**]({{returnBaseType}}.md){{/returnTypeIsPrimitive}}{{/returnType}}{{^returnType}} (empty response body){{/returnType}}

### Authorization

{{^authMethods}}No authorization required{{/authMethods}}{{#authMethods}}[{{{name}}}](../README.md#{{{name}}}){{^-last}}, {{/-last}}{{/authMethods}}

### HTTP request headers

- **Content-Type**: {{#consumes}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/consumes}}{{^consumes}}Not defined{{/consumes}}
- **Accept**: {{#produces}}{{{mediaType}}}{{#hasMore}}, {{/hasMore}}{{/produces}}{{^produces}}Not defined{{/produces}}

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
[[Back to Model list]](../README.md#documentation-for-models)
[[Back to README]](../README.md)

{{/operation}}
{{/operations}}
2 changes: 1 addition & 1 deletion pkg/coinbase/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat

- API version: 2019-11-15
- Package version: 0.1.0
- Build date: 2020-06-21T22:27:12.898-07:00[America/Los_Angeles]
- Build date: 2020-07-20T12:51:07.865-07:00[America/Los_Angeles]
- Build package: org.openapitools.codegen.languages.GoClientExperimentalCodegen

## Installation
Expand Down
4 changes: 2 additions & 2 deletions pkg/coinbase/docs/AccountsApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"context"
"fmt"
"os"
openapiclient "./openapi"
openapiclient "github.com/will7200/go-crypto-sync/pkg/coinbase"
)

func main() {
Expand Down Expand Up @@ -100,7 +100,7 @@ import (
"context"
"fmt"
"os"
openapiclient "./openapi"
openapiclient "github.com/will7200/go-crypto-sync/pkg/coinbase"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/coinbase/docs/ExchangeRatesApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"context"
"fmt"
"os"
openapiclient "./openapi"
openapiclient "github.com/will7200/go-crypto-sync/pkg/coinbase"
)

func main() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/coinbase/docs/UsersApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"context"
"fmt"
"os"
openapiclient "./openapi"
openapiclient "github.com/will7200/go-crypto-sync/pkg/coinbase"
)

func main() {
Expand Down

0 comments on commit 04264ec

Please sign in to comment.