-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TODO: generate tests for C# SDK
- Loading branch information
dphuang2
committed
Sep 29, 2023
1 parent
ac0fa5b
commit 399204c
Showing
8 changed files
with
90 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 34 additions & 39 deletions
73
...ator/konfig-generator-api/src/main/resources/csharp-netcore/api_doc_auth_partial.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,39 @@ | ||
|
||
{{#apiDocumentationAuthenticationPartial}} | ||
{{{apiDocumentationAuthenticationPartial}}} | ||
|
||
{{/apiDocumentationAuthenticationPartial}} | ||
{{^apiDocumentationAuthenticationPartial}} | ||
{{clientName}} client = new {{clientName}}(); | ||
// Configure custom BasePath if desired | ||
client.SetBasePath("{{{basePath}}}"); | ||
{{#clientStateSetterGetterPascalCase}} | ||
client.{{setter}}("{{upperSnakeCase}}"); | ||
{{/clientStateSetterGetterPascalCase}} | ||
{{#clientStateWithExamplesSetterGetterPascalCase}} | ||
client.{{setter}}("{{example}}"); | ||
{{/clientStateWithExamplesSetterGetterPascalCase}} | ||
{{#hasAuthMethods}} | ||
{{#authMethods}} | ||
{{#isBasicBasic}} | ||
// Configure HTTP basic authorization: {{{name}}} | ||
client.SetUsername("YOUR_USERNAME"); | ||
client.SetPassword("YOUR_PASSWORD"); | ||
{{/isBasicBasic}} | ||
{{#isBasicBearer}} | ||
// Configure Bearer token for authorization: {{{name}}} | ||
client.SetAccessToken("YOUR_BEARER_TOKEN"); | ||
{{/isBasicBearer}} | ||
{{#isApiKey}} | ||
// Configure API key authorization: {{{name}}} | ||
client.Set{{> api_key_name}}("YOUR_API_KEY"); | ||
{{/isApiKey}} | ||
{{#isOAuth}} | ||
{{#isApplication}} | ||
// Configure OAuth2 credentials for "{{{flow}}}" OAuth flow | ||
client.SetOAuthClientId(System.Environment.GetEnvironmentVariable("CLIENT_ID")); | ||
client.SetOAuthClientSecret(System.Environment.GetEnvironmentVariable("CLIENT_SECRET")); | ||
{{/isApplication}} | ||
{{^isApplication}} | ||
// Configure OAuth2 access token for authorization: {{{name}}} | ||
client.SetAccessToken("YOUR_ACCESS_TOKEN"); | ||
{{/isApplication}} | ||
{{/isOAuth}} | ||
{{/authMethods}} | ||
{{/hasAuthMethods}} | ||
{{#clientStateSetterGetterPascalCase}} | ||
client.{{setter}}("{{upperSnakeCase}}"); | ||
{{/clientStateSetterGetterPascalCase}} | ||
{{#clientStateWithExamplesSetterGetterPascalCase}} | ||
client.{{setter}}("{{example}}"); | ||
{{/clientStateWithExamplesSetterGetterPascalCase}} | ||
{{#hasAuthMethods}} | ||
{{#authMethods}} | ||
{{#isBasicBasic}} | ||
// Configure HTTP basic authorization | ||
client.SetUsername("YOUR_USERNAME"); | ||
client.SetPassword("YOUR_PASSWORD"); | ||
{{/isBasicBasic}} | ||
{{#isBasicBearer}} | ||
// Configure token for authorization | ||
client.SetAccessToken("YOUR_TOKEN"); | ||
{{/isBasicBearer}} | ||
{{#isApiKey}} | ||
// Configure API key authorization: {{{name}}} | ||
client.Set{{> api_key_name}}("YOUR_API_KEY"); | ||
{{/isApiKey}} | ||
{{#isOAuth}} | ||
{{#isApplication}} | ||
// Configure OAuth2 credentials for "{{{flow}}}" OAuth flow | ||
client.SetOAuthClientId(System.Environment.GetEnvironmentVariable("CLIENT_ID")); | ||
client.SetOAuthClientSecret(System.Environment.GetEnvironmentVariable("CLIENT_SECRET")); | ||
{{/isApplication}} | ||
{{^isApplication}} | ||
// Configure OAuth2 access token for authorization: {{{name}}} | ||
client.SetAccessToken("YOUR_ACCESS_TOKEN"); | ||
{{/isApplication}} | ||
{{/isOAuth}} | ||
{{/authMethods}} | ||
{{/hasAuthMethods}} | ||
{{/apiDocumentationAuthenticationPartial}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...r/konfig-generator-api/src/main/resources/csharp-netcore/api_doc_example_execute.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{{#allParams}} | ||
{{#isPrimitiveType}} | ||
var {{paramName}} = {{{example}}}; // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} | ||
{{/isPrimitiveType}} | ||
{{^isPrimitiveType}} | ||
var {{paramName}} = new {{{dataType}}}(); // {{{dataType}}} | {{{description}}}{{^required}} (optional) {{/required}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} | ||
{{/isPrimitiveType}} | ||
{{/allParams}} | ||
|
||
try | ||
{ | ||
{{#summary}} | ||
// {{{.}}} | ||
{{/summary}} | ||
{{#returnType}}{{{.}}} result = {{/returnType}}client.{{classNamePascalCase}}.{{{operationId}}}{{> api_doc_example_execute_pass_params}};{{#returnType}} | ||
Console.WriteLine(result);{{/returnType}} | ||
} | ||
catch (ApiException e) | ||
{ | ||
Console.WriteLine("Exception when calling {{classname}}.{{operationId}}: " + e.Message); | ||
Console.WriteLine("Status Code: "+ e.ErrorCode); | ||
Console.WriteLine(e.StackTrace); | ||
} | ||
catch (ClientException e) | ||
{ | ||
Console.WriteLine(e.Response.StatusCode); | ||
Console.WriteLine(e.Response.RawContent); | ||
Console.WriteLine(e.InnerException); | ||
} |
1 change: 1 addition & 0 deletions
1
...erator-api/src/main/resources/csharp-netcore/api_doc_example_execute_pass_params.mustache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters