forked from loafle/openapi-generator-original
[csharp][generichost] Handle all responses (#16635)
* handle all responses * update the readme * build samples
This commit is contained in:
@@ -95,6 +95,7 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
|
||||
private LinkedHashMap<String, CodegenMediaType> content;
|
||||
private Map<String, CodegenProperty> requiredVarsMap;
|
||||
private String ref;
|
||||
public CodegenProperty returnProperty;
|
||||
private boolean schemaIsFromAdditionalProperties;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -452,9 +452,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
.put("backslash", new BackSlashLambda())
|
||||
.put("doublequote", new DoubleQuoteLambda())
|
||||
.put("indented", new IndentedLambda())
|
||||
.put("indented_8", new IndentedLambda(8, " ", false))
|
||||
.put("indented_12", new IndentedLambda(12, " ", false))
|
||||
.put("indented_16", new IndentedLambda(16, " ", false));
|
||||
.put("indented_8", new IndentedLambda(8, " ", false, false))
|
||||
.put("indented_12", new IndentedLambda(12, " ", false, false))
|
||||
.put("indented_16", new IndentedLambda(16, " ", false, false));
|
||||
|
||||
}
|
||||
|
||||
@@ -4851,6 +4851,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
CodegenProperty cp = fromProperty("response", responseSchema, false);
|
||||
r.dataType = getTypeDeclaration(responseSchema);
|
||||
r.returnProperty = cp;
|
||||
|
||||
if (!ModelUtils.isArraySchema(responseSchema)) {
|
||||
if (cp.complexType != null) {
|
||||
|
||||
@@ -26,7 +26,6 @@ import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.openapitools.codegen.model.ModelMap;
|
||||
import org.openapitools.codegen.model.ModelsMap;
|
||||
@@ -418,13 +417,14 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
.put("optional", new OptionalParameterLambda().generator(this))
|
||||
.put("joinWithComma", new JoinWithCommaLambda())
|
||||
.put("joinLinesWithComma", new JoinWithCommaLambda(false, "\n", ",\n"))
|
||||
.put("joinConditions", new JoinWithCommaLambda(true, " ", " && "))
|
||||
.put("trimLineBreaks", new TrimLineBreaksLambda())
|
||||
.put("trimTrailingWithNewLine", new TrimTrailingWhiteSpaceLambda(true))
|
||||
.put("trimTrailing", new TrimTrailingWhiteSpaceLambda(false))
|
||||
.put("first", new FirstLambda(" "))
|
||||
.put("firstDot", new FirstLambda("\\."))
|
||||
.put("indent3", new IndentedLambda(12, " ", false))
|
||||
.put("indent4", new IndentedLambda(16, " ", false))
|
||||
.put("indent3", new IndentedLambda(12, " ", false, true))
|
||||
.put("indent4", new IndentedLambda(16, " ", false, true))
|
||||
.put("uniqueLinesWithNewLine", new UniqueLambda("\n", true));
|
||||
}
|
||||
|
||||
@@ -740,14 +740,230 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
}
|
||||
|
||||
private void postProcessResponseCode(CodegenResponse response, String status, Set<String> httpStatusesWithReturn) {
|
||||
response.vendorExtensions.put("x-http-status", status);
|
||||
if (response.dataType != null) {
|
||||
httpStatusesWithReturn.add(status);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
public OperationsMap postProcessOperationsWithModels(OperationsMap objs, List<ModelMap> allModels) {
|
||||
super.postProcessOperationsWithModels(objs, allModels);
|
||||
|
||||
Set<String> httpStatusesWithReturn = additionalProperties.get("x-http-statuses-with-return") instanceof Set<?>
|
||||
? (Set<String>) additionalProperties.get("x-http-statuses-with-return")
|
||||
: new HashSet<String>();
|
||||
|
||||
additionalProperties.put("x-http-statuses-with-return", httpStatusesWithReturn);
|
||||
|
||||
if (objs != null) {
|
||||
OperationMap operations = objs.getOperations();
|
||||
if (operations != null) {
|
||||
List<CodegenOperation> ops = operations.getOperation();
|
||||
for (CodegenOperation operation : ops) {
|
||||
if (operation.responses != null) {
|
||||
for (CodegenResponse response : operation.responses) {
|
||||
|
||||
if (response.returnProperty != null) {
|
||||
Boolean isValueType = isValueType(response.returnProperty);
|
||||
response.vendorExtensions.put("x-is-value-type", isValueType);
|
||||
response.vendorExtensions.put("x-is-reference-type", !isValueType);
|
||||
}
|
||||
|
||||
String code = response.code.toLowerCase(Locale.ROOT);
|
||||
switch(code) {
|
||||
case "default":
|
||||
case "0":
|
||||
postProcessResponseCode(response, "Default", httpStatusesWithReturn);
|
||||
response.vendorExtensions.put("x-http-status-is-default", true);
|
||||
if (operation.responses.stream().count() == 1) {
|
||||
response.vendorExtensions.put("x-only-default", true);
|
||||
}
|
||||
break;
|
||||
case "100":
|
||||
postProcessResponseCode(response, "Continue", httpStatusesWithReturn);
|
||||
break;
|
||||
case "101":
|
||||
postProcessResponseCode(response, "SwitchingProtocols", httpStatusesWithReturn);
|
||||
break;
|
||||
case "102":
|
||||
postProcessResponseCode(response, "Processing", httpStatusesWithReturn);
|
||||
break;
|
||||
case "103":
|
||||
postProcessResponseCode(response, "EarlyHints", httpStatusesWithReturn);
|
||||
break;
|
||||
case "200":
|
||||
postProcessResponseCode(response, "Ok", httpStatusesWithReturn);
|
||||
break;
|
||||
case "201":
|
||||
postProcessResponseCode(response, "Created", httpStatusesWithReturn);
|
||||
break;
|
||||
case "202":
|
||||
postProcessResponseCode(response, "Accepted", httpStatusesWithReturn);
|
||||
break;
|
||||
case "203":
|
||||
postProcessResponseCode(response, "NonAuthoritativeInformation", httpStatusesWithReturn);
|
||||
break;
|
||||
case "204":
|
||||
postProcessResponseCode(response, "NoContent", httpStatusesWithReturn);
|
||||
break;
|
||||
case "205":
|
||||
postProcessResponseCode(response, "ResetContent", httpStatusesWithReturn);
|
||||
break;
|
||||
case "206":
|
||||
postProcessResponseCode(response, "PartialContent", httpStatusesWithReturn);
|
||||
break;
|
||||
case "207":
|
||||
postProcessResponseCode(response, "MultiStatus", httpStatusesWithReturn);
|
||||
break;
|
||||
case "208":
|
||||
postProcessResponseCode(response, "AlreadyImported", httpStatusesWithReturn);
|
||||
break;
|
||||
case "226":
|
||||
postProcessResponseCode(response, "IMUsed", httpStatusesWithReturn);
|
||||
break;
|
||||
case "300":
|
||||
postProcessResponseCode(response, "MultipleChoices", httpStatusesWithReturn);
|
||||
break;
|
||||
case "301":
|
||||
postProcessResponseCode(response, "MovedPermanently", httpStatusesWithReturn);
|
||||
break;
|
||||
case "302":
|
||||
postProcessResponseCode(response, "Found", httpStatusesWithReturn);
|
||||
break;
|
||||
case "303":
|
||||
postProcessResponseCode(response, "SeeOther", httpStatusesWithReturn);
|
||||
break;
|
||||
case "304":
|
||||
postProcessResponseCode(response, "NotModified", httpStatusesWithReturn);
|
||||
break;
|
||||
case "307":
|
||||
postProcessResponseCode(response, "TemporaryRedirect", httpStatusesWithReturn);
|
||||
break;
|
||||
case "308":
|
||||
postProcessResponseCode(response, "PermanentRedirect", httpStatusesWithReturn);
|
||||
break;
|
||||
case "400":
|
||||
postProcessResponseCode(response, "BadRequest", httpStatusesWithReturn);
|
||||
break;
|
||||
case "401":
|
||||
postProcessResponseCode(response, "Unauthorized", httpStatusesWithReturn);
|
||||
break;
|
||||
case "402":
|
||||
postProcessResponseCode(response, "PaymentRequired", httpStatusesWithReturn);
|
||||
break;
|
||||
case "403":
|
||||
postProcessResponseCode(response, "Forbidden", httpStatusesWithReturn);
|
||||
break;
|
||||
case "404":
|
||||
postProcessResponseCode(response, "NotFound", httpStatusesWithReturn);
|
||||
break;
|
||||
case "405":
|
||||
postProcessResponseCode(response, "MethodNotAllowed", httpStatusesWithReturn);
|
||||
break;
|
||||
case "406":
|
||||
postProcessResponseCode(response, "NotAcceptable", httpStatusesWithReturn);
|
||||
break;
|
||||
case "407":
|
||||
postProcessResponseCode(response, "ProxyAuthenticationRequired", httpStatusesWithReturn);
|
||||
break;
|
||||
case "408":
|
||||
postProcessResponseCode(response, "RequestTimeout", httpStatusesWithReturn);
|
||||
break;
|
||||
case "409":
|
||||
postProcessResponseCode(response, "Conflict", httpStatusesWithReturn);
|
||||
break;
|
||||
case "410":
|
||||
postProcessResponseCode(response, "Gone", httpStatusesWithReturn);
|
||||
break;
|
||||
case "411":
|
||||
postProcessResponseCode(response, "LengthRequired", httpStatusesWithReturn);
|
||||
break;
|
||||
case "412":
|
||||
postProcessResponseCode(response, "PreconditionFailed", httpStatusesWithReturn);
|
||||
break;
|
||||
case "413":
|
||||
postProcessResponseCode(response, "ContentTooLarge", httpStatusesWithReturn);
|
||||
break;
|
||||
case "414":
|
||||
postProcessResponseCode(response, "URITooLong", httpStatusesWithReturn);
|
||||
break;
|
||||
case "415":
|
||||
postProcessResponseCode(response, "UnsupportedMediaType", httpStatusesWithReturn);
|
||||
break;
|
||||
case "416":
|
||||
postProcessResponseCode(response, "RangeNotSatisfiable", httpStatusesWithReturn);
|
||||
break;
|
||||
case "417":
|
||||
postProcessResponseCode(response, "ExpectationFailed", httpStatusesWithReturn);
|
||||
break;
|
||||
case "421":
|
||||
postProcessResponseCode(response, "MisdirectedRequest", httpStatusesWithReturn);
|
||||
break;
|
||||
case "422":
|
||||
postProcessResponseCode(response, "UnprocessableContent", httpStatusesWithReturn);
|
||||
break;
|
||||
case "423":
|
||||
postProcessResponseCode(response, "Locked", httpStatusesWithReturn);
|
||||
break;
|
||||
case "424":
|
||||
postProcessResponseCode(response, "FailedDependency", httpStatusesWithReturn);
|
||||
break;
|
||||
case "425":
|
||||
postProcessResponseCode(response, "TooEarly", httpStatusesWithReturn);
|
||||
break;
|
||||
case "426":
|
||||
postProcessResponseCode(response, "UpgradeRequired", httpStatusesWithReturn);
|
||||
break;
|
||||
case "428":
|
||||
postProcessResponseCode(response, "PreconditionRequired", httpStatusesWithReturn);
|
||||
break;
|
||||
case "429":
|
||||
postProcessResponseCode(response, "TooManyRequests", httpStatusesWithReturn);
|
||||
break;
|
||||
case "431":
|
||||
postProcessResponseCode(response, "RequestHeaderFieldsTooLong", httpStatusesWithReturn);
|
||||
break;
|
||||
case "451":
|
||||
postProcessResponseCode(response, "UnavailableForLegalReasons", httpStatusesWithReturn);
|
||||
break;
|
||||
case "500":
|
||||
postProcessResponseCode(response, "InternalServerError", httpStatusesWithReturn);
|
||||
break;
|
||||
case "501":
|
||||
postProcessResponseCode(response, "NotImplemented", httpStatusesWithReturn);
|
||||
break;
|
||||
case "502":
|
||||
postProcessResponseCode(response, "BadGateway", httpStatusesWithReturn);
|
||||
break;
|
||||
case "503":
|
||||
postProcessResponseCode(response, "ServiceUnavailable", httpStatusesWithReturn);
|
||||
break;
|
||||
case "504":
|
||||
postProcessResponseCode(response, "GatewayTimeout", httpStatusesWithReturn);
|
||||
break;
|
||||
case "505":
|
||||
postProcessResponseCode(response, "HttpVersionNotSupported", httpStatusesWithReturn);
|
||||
break;
|
||||
case "506":
|
||||
postProcessResponseCode(response, "VariantAlsoNegotiates", httpStatusesWithReturn);
|
||||
break;
|
||||
case "507":
|
||||
postProcessResponseCode(response, "InsufficientStorage", httpStatusesWithReturn);
|
||||
break;
|
||||
case "508":
|
||||
postProcessResponseCode(response, "LoopDetected", httpStatusesWithReturn);
|
||||
break;
|
||||
case "511":
|
||||
postProcessResponseCode(response, "NetworkAuthenticationRequired", httpStatusesWithReturn);
|
||||
break;
|
||||
default:
|
||||
throw new RuntimeException("Unhandled case: " + code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check return types for collection
|
||||
if (operation.returnType != null) {
|
||||
|
||||
@@ -331,7 +331,7 @@ abstract public class AbstractCppCodegen extends DefaultCodegen implements Codeg
|
||||
@Override
|
||||
protected ImmutableMap.Builder<String, Lambda> addMustacheLambdas() {
|
||||
return super.addMustacheLambdas()
|
||||
.put("multiline_comment_4", new IndentedLambda(4, " ", "///", false));
|
||||
.put("multiline_comment_4", new IndentedLambda(4, " ", "///", false, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -224,7 +224,7 @@ public class ScalaPlayFrameworkServerCodegen extends AbstractScalaCodegen implem
|
||||
@Override
|
||||
protected ImmutableMap.Builder<String, Lambda> addMustacheLambdas() {
|
||||
return super.addMustacheLambdas()
|
||||
.put("indented_4", new IndentedLambda(4, " ", false));
|
||||
.put("indented_4", new IndentedLambda(4, " ", false, false));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -308,8 +308,8 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
|
||||
@Override
|
||||
protected ImmutableMap.Builder<String, Mustache.Lambda> addMustacheLambdas() {
|
||||
ImmutableMap.Builder<String, Mustache.Lambda> lambdas = super.addMustacheLambdas();
|
||||
lambdas.put("indented_star_1", new IndentedLambda(1, " ", "* ", false));
|
||||
lambdas.put("indented_star_4", new IndentedLambda(5, " ", "* ", false));
|
||||
lambdas.put("indented_star_1", new IndentedLambda(1, " ", "* ", false, false));
|
||||
lambdas.put("indented_star_4", new IndentedLambda(5, " ", "* ", false, false));
|
||||
return lambdas;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,12 +46,13 @@ public class IndentedLambda implements Mustache.Lambda {
|
||||
private final String prefix;
|
||||
private final int spaceCode;
|
||||
private final boolean indentFirstLine;
|
||||
private final boolean skipEmptyLines;
|
||||
|
||||
/**
|
||||
* Constructs a new instance of {@link IndentedLambda}, with an indent count of 4 spaces
|
||||
*/
|
||||
public IndentedLambda() {
|
||||
this(4, " ", null, false);
|
||||
this(4, " ", null, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,8 +62,8 @@ public class IndentedLambda implements Mustache.Lambda {
|
||||
* @param indentionCharacter String representation of the character used in the indent (e.g. " ", "\t", ".").
|
||||
* @param indentFirstLine Whether to indent the first line or not. Usually this is handled by the template already.
|
||||
*/
|
||||
public IndentedLambda(int prefixSpaceCount, String indentionCharacter, boolean indentFirstLine) {
|
||||
this(prefixSpaceCount, Character.codePointAt(indentionCharacter, 0), null, indentFirstLine);
|
||||
public IndentedLambda(int prefixSpaceCount, String indentionCharacter, boolean indentFirstLine, boolean skipEmptyLines) {
|
||||
this(prefixSpaceCount, Character.codePointAt(indentionCharacter, 0), null, indentFirstLine, skipEmptyLines);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -73,8 +74,8 @@ public class IndentedLambda implements Mustache.Lambda {
|
||||
* @param prefix An optional prefix to prepend before the line (useful for multi-line comments).
|
||||
* @param indentFirstLine Whether to indent the first line or not. Usually this is handled by the template already.
|
||||
*/
|
||||
public IndentedLambda(int prefixSpaceCount, String indentionCharacter, String prefix, boolean indentFirstLine) {
|
||||
this(prefixSpaceCount, Character.codePointAt(indentionCharacter, 0), prefix, indentFirstLine);
|
||||
public IndentedLambda(int prefixSpaceCount, String indentionCharacter, String prefix, boolean indentFirstLine, boolean skipEmptyLines) {
|
||||
this(prefixSpaceCount, Character.codePointAt(indentionCharacter, 0), prefix, indentFirstLine, skipEmptyLines);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +86,7 @@ public class IndentedLambda implements Mustache.Lambda {
|
||||
* @param prefix An optional prefix to prepend before the line (useful for multi-line comments).
|
||||
* @param indentFirstLine Whether to indent the first line or not. Usually this is handled by the template already.
|
||||
*/
|
||||
private IndentedLambda(int prefixSpaceCount, int indentionCodePoint, String prefix, boolean indentFirstLine) {
|
||||
private IndentedLambda(int prefixSpaceCount, int indentionCodePoint, String prefix, boolean indentFirstLine, boolean skipEmptyLines) {
|
||||
if (prefixSpaceCount <= 0) {
|
||||
throw new IllegalArgumentException("prefixSpaceCount must be greater than 0");
|
||||
}
|
||||
@@ -98,6 +99,7 @@ public class IndentedLambda implements Mustache.Lambda {
|
||||
this.spaceCode = indentionCodePoint;
|
||||
this.prefix = prefix;
|
||||
this.indentFirstLine = indentFirstLine;
|
||||
this.skipEmptyLines = skipEmptyLines;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -116,7 +118,9 @@ public class IndentedLambda implements Mustache.Lambda {
|
||||
// Mustache will apply correct indentation to the first line of a template (to match declaration location).
|
||||
// So, we want to skip the first line.
|
||||
if (this.indentFirstLine || i > 0) {
|
||||
sb.append(prefixedIndention);
|
||||
if (!this.skipEmptyLines || line.trim().length() > 0) {
|
||||
sb.append(prefixedIndention);
|
||||
}
|
||||
if (prefix != null) sb.append(prefix);
|
||||
}
|
||||
|
||||
|
||||
@@ -5,18 +5,18 @@ namespace {{packageName}}.{{clientPackage}}
|
||||
/// <summary>
|
||||
/// Useful for tracking server health
|
||||
/// </summary>
|
||||
{{>visibility}} class ApiResponseEventArgs<T> : EventArgs
|
||||
{{>visibility}} class ApiResponseEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// The ApiResponse
|
||||
/// </summary>
|
||||
public ApiResponse<T> ApiResponse { get; }
|
||||
public ApiResponse ApiResponse { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The ApiResponseEventArgs
|
||||
/// </summary>
|
||||
/// <param name="apiResponse"></param>
|
||||
public ApiResponseEventArgs(ApiResponse<T> apiResponse)
|
||||
public ApiResponseEventArgs(ApiResponse apiResponse)
|
||||
{
|
||||
ApiResponse = apiResponse;
|
||||
}
|
||||
|
||||
@@ -5,8 +5,9 @@
|
||||
|
||||
{{/nrt}}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
{{^netStandard}}
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
{{/netStandard}}
|
||||
using System.Net;
|
||||
|
||||
namespace {{packageName}}.{{clientPackage}}
|
||||
@@ -14,15 +15,15 @@ namespace {{packageName}}.{{clientPackage}}
|
||||
/// <summary>
|
||||
/// Provides a non-generic contract for the ApiResponse wrapper.
|
||||
/// </summary>
|
||||
{{>visibility}} interface IApiResponse
|
||||
{{>visibility}} partial interface IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The type that represents the server's response.
|
||||
/// The IsSuccessStatusCode from the api response
|
||||
/// </summary>
|
||||
Type ResponseType { get; }
|
||||
bool IsSuccessStatusCode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the status code (HTTP status code)
|
||||
/// Gets the status code (HTTP status code)
|
||||
/// </summary>
|
||||
/// <value>The status code.</value>
|
||||
HttpStatusCode StatusCode { get; }
|
||||
@@ -37,11 +38,26 @@ namespace {{packageName}}.{{clientPackage}}
|
||||
/// </summary>
|
||||
DateTime DownloadedAt { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The headers contained in the api response
|
||||
/// </summary>
|
||||
System.Net.Http.Headers.HttpResponseHeaders Headers { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The path used when making the request.
|
||||
/// </summary>
|
||||
string Path { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The reason phrase contained in the api response
|
||||
/// </summary>
|
||||
string{{nrt?}} ReasonPhrase { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The DateTime when the request was sent.
|
||||
/// </summary>
|
||||
DateTime RequestedAt { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The Uri used when making the request.
|
||||
/// </summary>
|
||||
@@ -51,26 +67,18 @@ namespace {{packageName}}.{{clientPackage}}
|
||||
/// <summary>
|
||||
/// API Response
|
||||
/// </summary>
|
||||
{{>visibility}} partial class ApiResponse<T> : IApiResponse
|
||||
{{>visibility}} partial class ApiResponse : IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the status code (HTTP status code)
|
||||
/// Gets the status code (HTTP status code)
|
||||
/// </summary>
|
||||
/// <value>The status code.</value>
|
||||
public HttpStatusCode StatusCode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The type that represents the server's response.
|
||||
/// </summary>
|
||||
public Type ResponseType
|
||||
{
|
||||
get { return typeof(T); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The raw data
|
||||
/// </summary>
|
||||
public string RawContent { get; private set; }
|
||||
public string RawContent { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// The IsSuccessStatusCode from the api response
|
||||
@@ -108,9 +116,9 @@ namespace {{packageName}}.{{clientPackage}}
|
||||
public Uri{{nrt?}} RequestUri { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The JsonSerialzierOptions
|
||||
/// The <see cref="System.Text.Json.JsonSerializerOptions"/>
|
||||
/// </summary>
|
||||
private System.Text.Json.JsonSerializerOptions _jsonSerializerOptions;
|
||||
protected System.Text.Json.JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Construct the response using an HttpResponseMessage
|
||||
@@ -136,32 +144,27 @@ namespace {{packageName}}.{{clientPackage}}
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the server's response
|
||||
/// </summary>
|
||||
public T{{nrt?}} AsModel()
|
||||
{
|
||||
{{#lambda.trimTrailingWithNewLine}}
|
||||
{{>AsModel}}
|
||||
{{/lambda.trimTrailingWithNewLine}}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true when the model can be deserialized
|
||||
/// </summary>
|
||||
public bool TryToModel({{^netStandard}}[NotNullWhen(true)] {{/netStandard}}out T{{nrt?}} model)
|
||||
{
|
||||
try
|
||||
{
|
||||
model = AsModel();
|
||||
return model != null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
model = default(T);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
{{#x-http-statuses-with-return}}
|
||||
|
||||
/// <summary>
|
||||
/// An interface for responses of type {{TType}}
|
||||
/// </summary>
|
||||
/// <typeparam name="TType"></typeparam>
|
||||
{{>visibility}} interface I{{.}}<TType> : IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is {{.}}
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
TType {{.}}();
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is {{.}} and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
bool Try{{.}}({{^netStandard}}[NotNullWhen(true)]{{/netStandard}}out TType{{nrt?}} result);
|
||||
}
|
||||
{{/x-http-statuses-with-return}}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsSuccessStatusCode
|
||||
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, _jsonSerializerOptions)
|
||||
: default(T);
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return Is{{vendorExtensions.x-http-status}}
|
||||
? System.Text.Json.JsonSerializer.Deserialize<{{#isModel}}{{^containerType}}{{packageName}}.{{modelPackage}}.{{/containerType}}{{/isModel}}{{{dataType}}}>(RawContent, _jsonSerializerOptions)
|
||||
: {{^netStandard}}null{{/netStandard}}{{#netStandard}}default{{/netStandard}};
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
@@ -66,8 +66,8 @@ namespace YourProject
|
||||
{{#-first}}
|
||||
{{#operation}}
|
||||
{{#-first}}
|
||||
ApiResponse<{{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}object{{/returnType}}> response = await api.{{operationId}}Async("todo");
|
||||
{{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}object{{/returnType}} model = response.AsModel();
|
||||
{{operationId}}ApiResponse apiResponse = await api.{{operationId}}Async("todo");
|
||||
{{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}object{{/returnType}} model = apiResponse.Ok();
|
||||
{{/-first}}
|
||||
{{/operation}}
|
||||
{{/-first}}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
{{#lambda.trimLineBreaks}}
|
||||
// <auto-generated>
|
||||
{{>partial_header}}
|
||||
{{#nrt}}
|
||||
@@ -13,10 +14,12 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json;
|
||||
using {{packageName}}.{{clientPackage}};
|
||||
using {{packageName}}.{{apiPackage}};
|
||||
{{#hasImport}}
|
||||
using {{packageName}}.{{modelPackage}};
|
||||
{{/hasImport}}
|
||||
{{^netStandard}}
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
{{/netStandard}}
|
||||
|
||||
namespace {{packageName}}.{{apiPackage}}
|
||||
{
|
||||
@@ -44,8 +47,8 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
||||
{{/allParams}}
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}object{{/returnType}}>></returns>
|
||||
Task<ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}object{{/returnType}}>> {{operationId}}Async({{>OperationSignature}});
|
||||
/// <returns><see cref="Task"/><<see cref="{{interfacePrefix}}{{operationId}}ApiResponse"/>></returns>
|
||||
Task<{{interfacePrefix}}{{operationId}}ApiResponse> {{operationId}}Async({{>OperationSignature}});
|
||||
|
||||
/// <summary>
|
||||
/// {{summary}}
|
||||
@@ -57,17 +60,48 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
||||
{{/allParams}}
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}object{{/returnType}}>{{nrt?}}></returns>
|
||||
Task<ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}object{{/returnType}}>{{nrt?}}> {{operationId}}OrDefaultAsync({{>OperationSignature}});
|
||||
/// <returns><see cref="Task"/><<see cref="{{interfacePrefix}}{{operationId}}ApiResponse"/>{{nrt?}}></returns>
|
||||
Task<{{interfacePrefix}}{{operationId}}ApiResponse{{nrt?}}> {{operationId}}OrDefaultAsync({{>OperationSignature}});
|
||||
{{^-last}}
|
||||
|
||||
{{/-last}}
|
||||
{{/operation}}
|
||||
}
|
||||
{{#operation}}
|
||||
{{#responses}}
|
||||
{{#-first}}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="{{interfacePrefix}}{{operationId}}ApiResponse"/>
|
||||
/// </summary>
|
||||
{{>visibility}} interface {{interfacePrefix}}{{operationId}}ApiResponse : {{#lambda.joinWithComma}}{{packageName}}.{{clientPackage}}.{{interfacePrefix}}ApiResponse {{#responses}}{{#dataType}}{{interfacePrefix}}{{vendorExtensions.x-http-status}}<{{#isModel}}{{^containerType}}{{packageName}}.{{modelPackage}}.{{/containerType}}{{/isModel}}{{{dataType}}}{{#nrt}}?{{/nrt}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}}> {{/dataType}}{{/responses}}{{/lambda.joinWithComma}}
|
||||
{
|
||||
{{#responses}}
|
||||
{{#vendorExtensions.x-http-status-is-default}}
|
||||
/// <summary>
|
||||
/// Returns true if the response is the default response type
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool Is{{vendorExtensions.x-http-status}} { get; }
|
||||
{{/vendorExtensions.x-http-status-is-default}}
|
||||
{{^vendorExtensions.x-http-status-is-default}}
|
||||
/// <summary>
|
||||
/// Returns true if the response is {{code}} {{vendorExtensions.x-http-status}}
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool Is{{vendorExtensions.x-http-status}} { get; }
|
||||
{{/vendorExtensions.x-http-status-is-default}}
|
||||
{{^-last}}
|
||||
|
||||
{{/-last}}
|
||||
{{/responses}}
|
||||
}
|
||||
{{/-first}}
|
||||
{{/responses}}
|
||||
{{/operation}}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// This class is registered as transient.
|
||||
/// </summary>
|
||||
{{>visibility}} class {{classname}}Events
|
||||
{
|
||||
@@ -76,16 +110,16 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<{{{returnType}}}{{^returnType}}object{{/returnType}}>>{{nrt?}} On{{operationId}};
|
||||
public event EventHandler<ApiResponseEventArgs>{{nrt?}} On{{operationId}};
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>{{nrt?}} OnError{{operationId}};
|
||||
|
||||
internal void ExecuteOn{{operationId}}(ApiResponse<{{{returnType}}}{{^returnType}}object{{/returnType}}> apiResponse)
|
||||
internal void ExecuteOn{{operationId}}({{classname}}.{{operationId}}ApiResponse apiResponse)
|
||||
{
|
||||
On{{operationId}}?.Invoke(this, new ApiResponseEventArgs<{{{returnType}}}{{^returnType}}object{{/returnType}}>(apiResponse));
|
||||
On{{operationId}}?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnError{{operationId}}(Exception exception)
|
||||
@@ -104,6 +138,11 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
{
|
||||
private JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The logger factory
|
||||
/// </summary>
|
||||
public ILoggerFactory LoggerFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
@@ -148,7 +187,7 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
/// Initializes a new instance of the <see cref="{{classname}}"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public {{classname}}(ILogger<{{classname}}> logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, {{classname}}Events {{#lambda.camelcase_param}}{{classname}}Events{{/lambda.camelcase_param}}{{#hasApiKeyMethods}},
|
||||
public {{classname}}(ILogger<{{classname}}> logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, {{classname}}Events {{#lambda.camelcase_param}}{{classname}}Events{{/lambda.camelcase_param}}{{#hasApiKeyMethods}},
|
||||
TokenProvider<ApiKeyToken> apiKeyProvider{{/hasApiKeyMethods}}{{#hasHttpBearerMethods}},
|
||||
TokenProvider<BearerToken> bearerTokenProvider{{/hasHttpBearerMethods}}{{#hasHttpBasicMethods}},
|
||||
TokenProvider<BasicToken> basicTokenProvider{{/hasHttpBasicMethods}}{{#hasHttpSignatureMethods}},
|
||||
@@ -156,7 +195,8 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
TokenProvider<OAuthToken> oauthTokenProvider{{/hasOAuthMethods}})
|
||||
{
|
||||
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
|
||||
Logger = logger;
|
||||
LoggerFactory = loggerFactory;
|
||||
Logger = LoggerFactory.CreateLogger<{{classname}}>();
|
||||
HttpClient = httpClient;
|
||||
Events = {{#lambda.camelcase_param}}{{classname}}Events{{/lambda.camelcase_param}};{{#hasApiKeyMethods}}
|
||||
ApiKeyProvider = apiKeyProvider;{{/hasApiKeyMethods}}{{#hasHttpBearerMethods}}
|
||||
@@ -211,7 +251,7 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
{{#allParams}}
|
||||
/// <param name="{{paramName}}"></param>
|
||||
{{/allParams}}
|
||||
private void After{{operationId}}DefaultImplementation({{#lambda.joinWithComma}}ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}object{{/returnType}}> apiResponseLocalVar {{#allParams}}{{^required}}Option<{{/required}}{{{dataType}}}{{>NullConditionalParameter}}{{^required}}>{{/required}} {{paramName}} {{/allParams}}{{/lambda.joinWithComma}})
|
||||
private void After{{operationId}}DefaultImplementation({{#lambda.joinWithComma}}{{interfacePrefix}}{{operationId}}ApiResponse apiResponseLocalVar {{#allParams}}{{^required}}Option<{{/required}}{{{dataType}}}{{>NullConditionalParameter}}{{^required}}>{{/required}} {{paramName}} {{/allParams}}{{/lambda.joinWithComma}})
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
After{{operationId}}({{#lambda.joinWithComma}}ref suppressDefaultLog apiResponseLocalVar {{#allParams}}{{paramName}} {{/allParams}}{{/lambda.joinWithComma}});
|
||||
@@ -226,7 +266,7 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
{{#allParams}}
|
||||
/// <param name="{{paramName}}"></param>
|
||||
{{/allParams}}
|
||||
partial void After{{operationId}}({{#lambda.joinWithComma}}ref bool suppressDefaultLog ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}object{{/returnType}}> apiResponseLocalVar {{#allParams}}{{^required}}Option<{{/required}}{{{dataType}}}{{>NullConditionalParameter}}{{^required}}>{{/required}} {{paramName}} {{/allParams}}{{/lambda.joinWithComma}});
|
||||
partial void After{{operationId}}({{#lambda.joinWithComma}}ref bool suppressDefaultLog {{interfacePrefix}}{{operationId}}ApiResponse apiResponseLocalVar {{#allParams}}{{^required}}Option<{{/required}}{{{dataType}}}{{>NullConditionalParameter}}{{^required}}>{{/required}} {{paramName}} {{/allParams}}{{/lambda.joinWithComma}});
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -263,8 +303,8 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
||||
{{/allParams}}
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="{{#returnProperty}}{{baseType}}{{#isContainer}}{{#isMap}}{TKey, TValue}{{/isMap}}{{^isMap}}{TValue}{{/isMap}}{{/isContainer}}{{/returnProperty}}{{^returnProperty}}object{{/returnProperty}}"/></returns>
|
||||
public async Task<ApiResponse<{{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}object{{/returnType}}>{{nrt?}}> {{operationId}}OrDefaultAsync({{>OperationSignature}})
|
||||
/// <returns><see cref="Task"/><<see cref="{{interfacePrefix}}{{operationId}}ApiResponse"/>></returns>
|
||||
public async Task<{{interfacePrefix}}{{operationId}}ApiResponse{{nrt?}}> {{operationId}}OrDefaultAsync({{>OperationSignature}})
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -284,8 +324,8 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
/// <param name="{{paramName}}">{{description}}{{^required}} (optional{{#defaultValue}}, default to {{.}}{{/defaultValue}}){{/required}}</param>
|
||||
{{/allParams}}
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="{{#returnProperty}}{{baseType}}{{#isContainer}}{{#isMap}}{TKey, TValue}{{/isMap}}{{^isMap}}{TValue}{{/isMap}}{{/isContainer}}{{/returnProperty}}{{^returnProperty}}object{{/returnProperty}}"/></returns>
|
||||
public async Task<ApiResponse<{{#returnType}}{{{.}}}{{/returnType}}{{^returnType}}object{{/returnType}}>> {{operationId}}Async({{>OperationSignature}})
|
||||
/// <returns><see cref="Task"/><<see cref="{{interfacePrefix}}{{operationId}}ApiResponse"/>></returns>
|
||||
public async Task<{{interfacePrefix}}{{operationId}}ApiResponse> {{operationId}}Async({{>OperationSignature}})
|
||||
{
|
||||
{{#lambda.trimLineBreaks}}
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
@@ -539,17 +579,21 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync({{#net60OrLater}}cancellationToken{{/net60OrLater}}).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<{{{returnType}}}{{^returnType}}object{{/returnType}}> apiResponseLocalVar = new ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}object{{/returnType}}>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "{{path}}", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<{{operationId}}ApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<{{operationId}}ApiResponse>();
|
||||
|
||||
{{operationId}}ApiResponse apiResponseLocalVar = new{{^net60OrLater}} {{operationId}}ApiResponse{{/net60OrLater}}(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "{{path}}", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
After{{operationId}}DefaultImplementation({{#lambda.joinWithComma}}apiResponseLocalVar {{#allParams}}{{paramName}} {{/allParams}}{{/lambda.joinWithComma}});
|
||||
|
||||
Events.ExecuteOn{{operationId}}(apiResponseLocalVar);
|
||||
|
||||
{{#authMethods}}
|
||||
{{#-first}}
|
||||
if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429)
|
||||
foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars)
|
||||
tokenBaseLocalVar.BeginRateLimit();
|
||||
|
||||
{{/-first}}
|
||||
{{/authMethods}}
|
||||
return apiResponseLocalVar;
|
||||
}
|
||||
@@ -563,7 +607,108 @@ namespace {{packageName}}.{{apiPackage}}
|
||||
}
|
||||
{{/lambda.trimLineBreaks}}
|
||||
}
|
||||
{{#responses}}
|
||||
{{#-first}}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="{{operationId}}ApiResponse"/>
|
||||
/// </summary>
|
||||
{{>visibility}} partial class {{operationId}}ApiResponse : {{packageName}}.{{clientPackage}}.ApiResponse, {{interfacePrefix}}{{operationId}}ApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<{{operationId}}ApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="{{operationId}}ApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public {{operationId}}ApiResponse(ILogger<{{operationId}}ApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
{{#responses}}
|
||||
|
||||
{{#vendorExtensions.x-http-status-is-default}}
|
||||
/// <summary>
|
||||
/// Returns true if the response is the default response type
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool Is{{vendorExtensions.x-http-status}} => {{#vendorExtensions.x-only-default}}true{{/vendorExtensions.x-only-default}}{{^vendorExtensions.x-only-default}}{{#lambda.joinConditions}}{{#responses}}{{^vendorExtensions.x-http-status-is-default}}!Is{{vendorExtensions.x-http-status}} {{/vendorExtensions.x-http-status-is-default}}{{/responses}}{{/lambda.joinConditions}}{{/vendorExtensions.x-only-default}};
|
||||
{{/vendorExtensions.x-http-status-is-default}}
|
||||
{{^vendorExtensions.x-http-status-is-default}}
|
||||
/// <summary>
|
||||
/// Returns true if the response is {{code}} {{vendorExtensions.x-http-status}}
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool Is{{vendorExtensions.x-http-status}} => {{code}} == (int)StatusCode;
|
||||
{{/vendorExtensions.x-http-status-is-default}}
|
||||
{{#dataType}}
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is {{code}} {{vendorExtensions.x-http-status}}
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public {{#isModel}}{{^containerType}}{{packageName}}.{{modelPackage}}.{{/containerType}}{{/isModel}}{{{dataType}}}{{#nrt}}?{{/nrt}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} {{vendorExtensions.x-http-status}}()
|
||||
{
|
||||
{{#lambda.trimTrailingWithNewLine}}
|
||||
{{#lambda.indent4}}
|
||||
{{>AsModel}}
|
||||
{{/lambda.indent4}}
|
||||
{{/lambda.trimTrailingWithNewLine}}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is {{code}} {{vendorExtensions.x-http-status}} and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool Try{{vendorExtensions.x-http-status}}({{^netStandard}}[NotNullWhen(true)]{{/netStandard}}out {{#isModel}}{{^containerType}}{{packageName}}.{{modelPackage}}.{{/containerType}}{{/isModel}}{{{dataType}}}{{#nrt}}?{{/nrt}}{{^nrt}}{{#vendorExtensions.x-is-value-type}}?{{/vendorExtensions.x-is-value-type}}{{/nrt}} result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = {{vendorExtensions.x-http-status}}();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode){{code}});
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
{{/dataType}}
|
||||
{{#-last}}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
{{#lambda.trimTrailingWithNewLine}}
|
||||
{{#lambda.indent4}}
|
||||
{{>OnDeserializationError}}
|
||||
{{/lambda.indent4}}
|
||||
{{/lambda.trimTrailingWithNewLine}}
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
{{/-last}}
|
||||
{{/responses}}
|
||||
}
|
||||
{{/-first}}
|
||||
{{/responses}}
|
||||
{{/operation}}
|
||||
}
|
||||
{{/operations}}
|
||||
}
|
||||
{{/lambda.trimLineBreaks}}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace {{packageName}}.Test.{{apiPackage}}
|
||||
{{/allParams}}
|
||||
{{#returnType}}
|
||||
var response = await _instance.{{operationId}}Async({{#allParams}}{{paramName}}{{^-last}}, {{/-last}}{{/allParams}});
|
||||
var model = response.AsModel();
|
||||
var model = response.{{#lambda.first}}{{#responses}}{{vendorExtensions.x-http-status}} {{/responses}}{{/lambda.first}}();
|
||||
Assert.IsType<{{{.}}}>(model);
|
||||
{{/returnType}}
|
||||
{{^returnType}}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class IndentedLambdaTest extends LambdaTest {
|
||||
@Test
|
||||
public void indentedCountTest() {
|
||||
// Given
|
||||
Map<String, Object> ctx = context("indented", new IndentedLambda(8, " ", false));
|
||||
Map<String, Object> ctx = context("indented", new IndentedLambda(8, " ", false, false));
|
||||
|
||||
// When & Then
|
||||
// IndentedLambda applies indentation from second line on of a template.
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# Org.OpenAPITools.Model.UpdatePet200Response
|
||||
|
||||
## Properties
|
||||
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**VarString** | [**Pet**](Pet.md) | | [optional]
|
||||
|
||||
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
* Generated by: https://github.com/openapitools/openapi-generator.git
|
||||
*/
|
||||
|
||||
|
||||
using Xunit;
|
||||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using Org.OpenAPITools.Model;
|
||||
using Org.OpenAPITools.Client;
|
||||
using System.Reflection;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Org.OpenAPITools.Test.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// Class for testing UpdatePet200Response
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This file is automatically generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
/// Please update the test case below to test the model.
|
||||
/// </remarks>
|
||||
public class UpdatePet200ResponseTests : IDisposable
|
||||
{
|
||||
// TODO uncomment below to declare an instance variable for UpdatePet200Response
|
||||
//private UpdatePet200Response instance;
|
||||
|
||||
public UpdatePet200ResponseTests()
|
||||
{
|
||||
// TODO uncomment below to create an instance of UpdatePet200Response
|
||||
//instance = new UpdatePet200Response();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Cleanup when everything is done.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test an instance of UpdatePet200Response
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void UpdatePet200ResponseInstanceTest()
|
||||
{
|
||||
// TODO uncomment below to test "IsType" UpdatePet200Response
|
||||
//Assert.IsType<UpdatePet200Response>(instance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'VarString'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void VarStringTest()
|
||||
{
|
||||
// TODO unit test for the property 'VarString'
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
*
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* The version of the OpenAPI document: 1.0.0
|
||||
* Generated by: https://github.com/openapitools/openapi-generator.git
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using OpenAPIDateConverter = Org.OpenAPITools.Client.OpenAPIDateConverter;
|
||||
using OpenAPIClientUtils = Org.OpenAPITools.Client.ClientUtils;
|
||||
|
||||
namespace Org.OpenAPITools.Model
|
||||
{
|
||||
/// <summary>
|
||||
/// UpdatePet200Response
|
||||
/// </summary>
|
||||
[DataContract(Name = "updatePet_200_response")]
|
||||
public partial class UpdatePet200Response : IEquatable<UpdatePet200Response>, IValidatableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UpdatePet200Response" /> class.
|
||||
/// </summary>
|
||||
/// <param name="varString">varString.</param>
|
||||
public UpdatePet200Response(Pet varString = default(Pet))
|
||||
{
|
||||
this._VarString = varString;
|
||||
if (this.VarString != null)
|
||||
{
|
||||
this._flagVarString = true;
|
||||
}
|
||||
this.AdditionalProperties = new Dictionary<string, object>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or Sets VarString
|
||||
/// </summary>
|
||||
[DataMember(Name = "string", EmitDefaultValue = false)]
|
||||
public Pet VarString
|
||||
{
|
||||
get{ return _VarString;}
|
||||
set
|
||||
{
|
||||
_VarString = value;
|
||||
_flagVarString = true;
|
||||
}
|
||||
}
|
||||
private Pet _VarString;
|
||||
private bool _flagVarString;
|
||||
|
||||
/// <summary>
|
||||
/// Returns false as VarString should not be serialized given that it's read-only.
|
||||
/// </summary>
|
||||
/// <returns>false (boolean)</returns>
|
||||
public bool ShouldSerializeVarString()
|
||||
{
|
||||
return _flagVarString;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or Sets additional properties
|
||||
/// </summary>
|
||||
[JsonExtensionData]
|
||||
public IDictionary<string, object> AdditionalProperties { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns the string presentation of the object
|
||||
/// </summary>
|
||||
/// <returns>String presentation of the object</returns>
|
||||
public override string ToString()
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.Append("class UpdatePet200Response {\n");
|
||||
sb.Append(" VarString: ").Append(VarString).Append("\n");
|
||||
sb.Append(" AdditionalProperties: ").Append(AdditionalProperties).Append("\n");
|
||||
sb.Append("}\n");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the JSON string presentation of the object
|
||||
/// </summary>
|
||||
/// <returns>JSON string presentation of the object</returns>
|
||||
public virtual string ToJson()
|
||||
{
|
||||
return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if objects are equal
|
||||
/// </summary>
|
||||
/// <param name="input">Object to be compared</param>
|
||||
/// <returns>Boolean</returns>
|
||||
public override bool Equals(object input)
|
||||
{
|
||||
return OpenAPIClientUtils.compareLogic.Compare(this, input as UpdatePet200Response).AreEqual;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if UpdatePet200Response instances are equal
|
||||
/// </summary>
|
||||
/// <param name="input">Instance of UpdatePet200Response to be compared</param>
|
||||
/// <returns>Boolean</returns>
|
||||
public bool Equals(UpdatePet200Response input)
|
||||
{
|
||||
return OpenAPIClientUtils.compareLogic.Compare(this, input).AreEqual;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the hash code
|
||||
/// </summary>
|
||||
/// <returns>Hash code</returns>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
unchecked // Overflow is fine, just wrap
|
||||
{
|
||||
int hashCode = 41;
|
||||
if (this.VarString != null)
|
||||
{
|
||||
hashCode = (hashCode * 59) + this.VarString.GetHashCode();
|
||||
}
|
||||
if (this.AdditionalProperties != null)
|
||||
{
|
||||
hashCode = (hashCode * 59) + this.AdditionalProperties.GetHashCode();
|
||||
}
|
||||
return hashCode;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// To validate all properties of the instance
|
||||
/// </summary>
|
||||
/// <param name="validationContext">Validation context</param>
|
||||
/// <returns>Validation Result</returns>
|
||||
IEnumerable<System.ComponentModel.DataAnnotations.ValidationResult> IValidatableObject.Validate(ValidationContext validationContext)
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -58,7 +58,7 @@ namespace UseSourceGeneration.Test.Api
|
||||
{
|
||||
ModelClient modelClient = default!;
|
||||
var response = await _instance.Call123TestSpecialTagsAsync(modelClient);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<ModelClient>(model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace UseSourceGeneration.Test.Api
|
||||
public async Task FooGetAsyncTest()
|
||||
{
|
||||
var response = await _instance.FooGetAsync();
|
||||
var model = response.AsModel();
|
||||
var model = response.Default();
|
||||
Assert.IsType<FooGetDefaultResponse>(model);
|
||||
}
|
||||
|
||||
@@ -78,8 +78,30 @@ namespace UseSourceGeneration.Test.Api
|
||||
public async Task HelloAsyncTest()
|
||||
{
|
||||
var response = await _instance.HelloAsync();
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<List<Guid>>(model);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test RolesReportGet
|
||||
/// </summary>
|
||||
[Fact (Skip = "not implemented")]
|
||||
public async Task RolesReportGetAsyncTest()
|
||||
{
|
||||
var response = await _instance.RolesReportGetAsync();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<List<List<RolesReportsHash>>>(model);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test Test
|
||||
/// </summary>
|
||||
[Fact (Skip = "not implemented")]
|
||||
public async Task TestAsyncTest()
|
||||
{
|
||||
var response = await _instance.TestAsync();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<NotificationtestGetElementsV1ResponseMPayload>(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace UseSourceGeneration.Test.Api
|
||||
public async Task FakeHealthGetAsyncTest()
|
||||
{
|
||||
var response = await _instance.FakeHealthGetAsync();
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<HealthCheckResult>(model);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace UseSourceGeneration.Test.Api
|
||||
{
|
||||
Client.Option<bool> body = default!;
|
||||
var response = await _instance.FakeOuterBooleanSerializeAsync(body);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<bool>(model);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace UseSourceGeneration.Test.Api
|
||||
{
|
||||
Client.Option<OuterComposite> outerComposite = default!;
|
||||
var response = await _instance.FakeOuterCompositeSerializeAsync(outerComposite);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<OuterComposite>(model);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace UseSourceGeneration.Test.Api
|
||||
{
|
||||
Client.Option<decimal> body = default!;
|
||||
var response = await _instance.FakeOuterNumberSerializeAsync(body);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<decimal>(model);
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace UseSourceGeneration.Test.Api
|
||||
Guid requiredStringUuid = default!;
|
||||
Client.Option<string> body = default!;
|
||||
var response = await _instance.FakeOuterStringSerializeAsync(requiredStringUuid, body);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<string>(model);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace UseSourceGeneration.Test.Api
|
||||
public async Task GetArrayOfEnumsAsyncTest()
|
||||
{
|
||||
var response = await _instance.GetArrayOfEnumsAsync();
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<List<OuterEnum>>(model);
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace UseSourceGeneration.Test.Api
|
||||
{
|
||||
ModelClient modelClient = default!;
|
||||
var response = await _instance.TestClientModelAsync(modelClient);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<ModelClient>(model);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace UseSourceGeneration.Test.Api
|
||||
{
|
||||
ModelClient modelClient = default!;
|
||||
var response = await _instance.TestClassnameAsync(modelClient);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<ModelClient>(model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace UseSourceGeneration.Test.Api
|
||||
{
|
||||
List<string> status = default!;
|
||||
var response = await _instance.FindPetsByStatusAsync(status);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<List<Pet>>(model);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace UseSourceGeneration.Test.Api
|
||||
{
|
||||
List<string> tags = default!;
|
||||
var response = await _instance.FindPetsByTagsAsync(tags);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<List<Pet>>(model);
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace UseSourceGeneration.Test.Api
|
||||
{
|
||||
long petId = default!;
|
||||
var response = await _instance.GetPetByIdAsync(petId);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<Pet>(model);
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace UseSourceGeneration.Test.Api
|
||||
Client.Option<System.IO.Stream> file = default!;
|
||||
Client.Option<string> additionalMetadata = default!;
|
||||
var response = await _instance.UploadFileAsync(petId, file, additionalMetadata);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<ApiResponse>(model);
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace UseSourceGeneration.Test.Api
|
||||
long petId = default!;
|
||||
Client.Option<string> additionalMetadata = default!;
|
||||
var response = await _instance.UploadFileWithRequiredFileAsync(requiredFile, petId, additionalMetadata);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<ApiResponse>(model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace UseSourceGeneration.Test.Api
|
||||
public async Task GetInventoryAsyncTest()
|
||||
{
|
||||
var response = await _instance.GetInventoryAsync();
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<Dictionary<string, int>>(model);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace UseSourceGeneration.Test.Api
|
||||
{
|
||||
long orderId = default!;
|
||||
var response = await _instance.GetOrderByIdAsync(orderId);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<Order>(model);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace UseSourceGeneration.Test.Api
|
||||
{
|
||||
Order order = default!;
|
||||
var response = await _instance.PlaceOrderAsync(order);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<Order>(model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace UseSourceGeneration.Test.Api
|
||||
{
|
||||
string username = default!;
|
||||
var response = await _instance.GetUserByNameAsync(username);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<User>(model);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace UseSourceGeneration.Test.Api
|
||||
string username = default!;
|
||||
string password = default!;
|
||||
var response = await _instance.LoginUserAsync(username, password);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<string>(model);
|
||||
}
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json;
|
||||
using UseSourceGeneration.Client;
|
||||
using UseSourceGeneration.Api;
|
||||
using UseSourceGeneration.Model;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace UseSourceGeneration.Api
|
||||
{
|
||||
@@ -44,8 +44,8 @@ namespace UseSourceGeneration.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<ModelClient>></returns>
|
||||
Task<ApiResponse<ModelClient>> Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="ICall123TestSpecialTagsApiResponse"/>></returns>
|
||||
Task<ICall123TestSpecialTagsApiResponse> Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// To test special tags
|
||||
@@ -55,29 +55,40 @@ namespace UseSourceGeneration.Api
|
||||
/// </remarks>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>ModelClient>?></returns>
|
||||
Task<ApiResponse<ModelClient>?> Call123TestSpecialTagsOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="ICall123TestSpecialTagsApiResponse"/>?></returns>
|
||||
Task<ICall123TestSpecialTagsApiResponse?> Call123TestSpecialTagsOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ICall123TestSpecialTagsApiResponse"/>
|
||||
/// </summary>
|
||||
public interface ICall123TestSpecialTagsApiResponse : UseSourceGeneration.Client.IApiResponse, IOk<UseSourceGeneration.Model.ModelClient?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// This class is registered as transient.
|
||||
/// </summary>
|
||||
public class AnotherFakeApiEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<ModelClient>>? OnCall123TestSpecialTags;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnCall123TestSpecialTags;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorCall123TestSpecialTags;
|
||||
|
||||
internal void ExecuteOnCall123TestSpecialTags(ApiResponse<ModelClient> apiResponse)
|
||||
internal void ExecuteOnCall123TestSpecialTags(AnotherFakeApi.Call123TestSpecialTagsApiResponse apiResponse)
|
||||
{
|
||||
OnCall123TestSpecialTags?.Invoke(this, new ApiResponseEventArgs<ModelClient>(apiResponse));
|
||||
OnCall123TestSpecialTags?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorCall123TestSpecialTags(Exception exception)
|
||||
@@ -93,6 +104,11 @@ namespace UseSourceGeneration.Api
|
||||
{
|
||||
private JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The logger factory
|
||||
/// </summary>
|
||||
public ILoggerFactory LoggerFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
@@ -137,7 +153,7 @@ namespace UseSourceGeneration.Api
|
||||
/// Initializes a new instance of the <see cref="AnotherFakeApi"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public AnotherFakeApi(ILogger<AnotherFakeApi> logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, AnotherFakeApiEvents anotherFakeApiEvents,
|
||||
public AnotherFakeApi(ILogger<AnotherFakeApi> logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, AnotherFakeApiEvents anotherFakeApiEvents,
|
||||
TokenProvider<ApiKeyToken> apiKeyProvider,
|
||||
TokenProvider<BearerToken> bearerTokenProvider,
|
||||
TokenProvider<BasicToken> basicTokenProvider,
|
||||
@@ -145,7 +161,8 @@ namespace UseSourceGeneration.Api
|
||||
TokenProvider<OAuthToken> oauthTokenProvider)
|
||||
{
|
||||
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
|
||||
Logger = logger;
|
||||
LoggerFactory = loggerFactory;
|
||||
Logger = LoggerFactory.CreateLogger<AnotherFakeApi>();
|
||||
HttpClient = httpClient;
|
||||
Events = anotherFakeApiEvents;
|
||||
ApiKeyProvider = apiKeyProvider;
|
||||
@@ -173,7 +190,7 @@ namespace UseSourceGeneration.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="modelClient"></param>
|
||||
private void AfterCall123TestSpecialTagsDefaultImplementation(ApiResponse<ModelClient> apiResponseLocalVar, ModelClient modelClient)
|
||||
private void AfterCall123TestSpecialTagsDefaultImplementation(ICall123TestSpecialTagsApiResponse apiResponseLocalVar, ModelClient modelClient)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterCall123TestSpecialTags(ref suppressDefaultLog, apiResponseLocalVar, modelClient);
|
||||
@@ -187,7 +204,7 @@ namespace UseSourceGeneration.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="modelClient"></param>
|
||||
partial void AfterCall123TestSpecialTags(ref bool suppressDefaultLog, ApiResponse<ModelClient> apiResponseLocalVar, ModelClient modelClient);
|
||||
partial void AfterCall123TestSpecialTags(ref bool suppressDefaultLog, ICall123TestSpecialTagsApiResponse apiResponseLocalVar, ModelClient modelClient);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -219,8 +236,8 @@ namespace UseSourceGeneration.Api
|
||||
/// </summary>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="ModelClient"/></returns>
|
||||
public async Task<ApiResponse<ModelClient>?> Call123TestSpecialTagsOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="ICall123TestSpecialTagsApiResponse"/>></returns>
|
||||
public async Task<ICall123TestSpecialTagsApiResponse?> Call123TestSpecialTagsOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -238,8 +255,8 @@ namespace UseSourceGeneration.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="ModelClient"/></returns>
|
||||
public async Task<ApiResponse<ModelClient>> Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="ICall123TestSpecialTagsApiResponse"/>></returns>
|
||||
public async Task<ICall123TestSpecialTagsApiResponse> Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -288,7 +305,9 @@ namespace UseSourceGeneration.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<ModelClient> apiResponseLocalVar = new ApiResponse<ModelClient>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/another-fake/dummy", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<Call123TestSpecialTagsApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<Call123TestSpecialTagsApiResponse>();
|
||||
|
||||
Call123TestSpecialTagsApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/another-fake/dummy", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterCall123TestSpecialTagsDefaultImplementation(apiResponseLocalVar, modelClient);
|
||||
|
||||
@@ -305,5 +324,82 @@ namespace UseSourceGeneration.Api
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Call123TestSpecialTagsApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class Call123TestSpecialTagsApiResponse : UseSourceGeneration.Client.ApiResponse, ICall123TestSpecialTagsApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<Call123TestSpecialTagsApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Call123TestSpecialTagsApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public Call123TestSpecialTagsApiResponse(ILogger<Call123TestSpecialTagsApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public UseSourceGeneration.Model.ModelClient? Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<UseSourceGeneration.Model.ModelClient>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out UseSourceGeneration.Model.ModelClient? result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json;
|
||||
using UseSourceGeneration.Client;
|
||||
using UseSourceGeneration.Api;
|
||||
using UseSourceGeneration.Model;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace UseSourceGeneration.Api
|
||||
{
|
||||
@@ -43,8 +43,8 @@ namespace UseSourceGeneration.Api
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<FooGetDefaultResponse>></returns>
|
||||
Task<ApiResponse<FooGetDefaultResponse>> FooGetAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IFooGetApiResponse"/>></returns>
|
||||
Task<IFooGetApiResponse> FooGetAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -53,8 +53,8 @@ namespace UseSourceGeneration.Api
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>FooGetDefaultResponse>?></returns>
|
||||
Task<ApiResponse<FooGetDefaultResponse>?> FooGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IFooGetApiResponse"/>?></returns>
|
||||
Task<IFooGetApiResponse?> FooGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -65,8 +65,8 @@ namespace UseSourceGeneration.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="country"></param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<object>></returns>
|
||||
Task<ApiResponse<object>> GetCountryAsync(string country, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IGetCountryApiResponse"/>></returns>
|
||||
Task<IGetCountryApiResponse> GetCountryAsync(string country, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -76,8 +76,8 @@ namespace UseSourceGeneration.Api
|
||||
/// </remarks>
|
||||
/// <param name="country"></param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>object>?></returns>
|
||||
Task<ApiResponse<object>?> GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IGetCountryApiResponse"/>?></returns>
|
||||
Task<IGetCountryApiResponse?> GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Hello
|
||||
@@ -87,8 +87,8 @@ namespace UseSourceGeneration.Api
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<List<Guid>>></returns>
|
||||
Task<ApiResponse<List<Guid>>> HelloAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IHelloApiResponse"/>></returns>
|
||||
Task<IHelloApiResponse> HelloAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Hello
|
||||
@@ -97,8 +97,8 @@ namespace UseSourceGeneration.Api
|
||||
/// Hello
|
||||
/// </remarks>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>List<Guid>>?></returns>
|
||||
Task<ApiResponse<List<Guid>>?> HelloOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IHelloApiResponse"/>?></returns>
|
||||
Task<IHelloApiResponse?> HelloOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -108,8 +108,8 @@ namespace UseSourceGeneration.Api
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<List<List<RolesReportsHash>>>></returns>
|
||||
Task<ApiResponse<List<List<RolesReportsHash>>>> RolesReportGetAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IRolesReportGetApiResponse"/>></returns>
|
||||
Task<IRolesReportGetApiResponse> RolesReportGetAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -118,8 +118,8 @@ namespace UseSourceGeneration.Api
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>List<List<RolesReportsHash>>>?></returns>
|
||||
Task<ApiResponse<List<List<RolesReportsHash>>>?> RolesReportGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IRolesReportGetApiResponse"/>?></returns>
|
||||
Task<IRolesReportGetApiResponse?> RolesReportGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve an existing Notificationtest's Elements
|
||||
@@ -129,8 +129,8 @@ namespace UseSourceGeneration.Api
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<NotificationtestGetElementsV1ResponseMPayload>></returns>
|
||||
Task<ApiResponse<NotificationtestGetElementsV1ResponseMPayload>> TestAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="ITestApiResponse"/>></returns>
|
||||
Task<ITestApiResponse> TestAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve an existing Notificationtest's Elements
|
||||
@@ -139,29 +139,88 @@ namespace UseSourceGeneration.Api
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>NotificationtestGetElementsV1ResponseMPayload>?></returns>
|
||||
Task<ApiResponse<NotificationtestGetElementsV1ResponseMPayload>?> TestOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="ITestApiResponse"/>?></returns>
|
||||
Task<ITestApiResponse?> TestOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IFooGetApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IFooGetApiResponse : UseSourceGeneration.Client.IApiResponse, IDefault<UseSourceGeneration.Model.FooGetDefaultResponse?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is the default response type
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsDefault { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IGetCountryApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IGetCountryApiResponse : UseSourceGeneration.Client.IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IHelloApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IHelloApiResponse : UseSourceGeneration.Client.IApiResponse, IOk<List<Guid>?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IRolesReportGetApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IRolesReportGetApiResponse : UseSourceGeneration.Client.IApiResponse, IOk<List<List>?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ITestApiResponse"/>
|
||||
/// </summary>
|
||||
public interface ITestApiResponse : UseSourceGeneration.Client.IApiResponse, IOk<UseSourceGeneration.Model.NotificationtestGetElementsV1ResponseMPayload?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// This class is registered as transient.
|
||||
/// </summary>
|
||||
public class DefaultApiEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<FooGetDefaultResponse>>? OnFooGet;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnFooGet;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorFooGet;
|
||||
|
||||
internal void ExecuteOnFooGet(ApiResponse<FooGetDefaultResponse> apiResponse)
|
||||
internal void ExecuteOnFooGet(DefaultApi.FooGetApiResponse apiResponse)
|
||||
{
|
||||
OnFooGet?.Invoke(this, new ApiResponseEventArgs<FooGetDefaultResponse>(apiResponse));
|
||||
OnFooGet?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorFooGet(Exception exception)
|
||||
@@ -172,16 +231,16 @@ namespace UseSourceGeneration.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<object>>? OnGetCountry;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnGetCountry;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorGetCountry;
|
||||
|
||||
internal void ExecuteOnGetCountry(ApiResponse<object> apiResponse)
|
||||
internal void ExecuteOnGetCountry(DefaultApi.GetCountryApiResponse apiResponse)
|
||||
{
|
||||
OnGetCountry?.Invoke(this, new ApiResponseEventArgs<object>(apiResponse));
|
||||
OnGetCountry?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorGetCountry(Exception exception)
|
||||
@@ -192,16 +251,16 @@ namespace UseSourceGeneration.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<List<Guid>>>? OnHello;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnHello;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorHello;
|
||||
|
||||
internal void ExecuteOnHello(ApiResponse<List<Guid>> apiResponse)
|
||||
internal void ExecuteOnHello(DefaultApi.HelloApiResponse apiResponse)
|
||||
{
|
||||
OnHello?.Invoke(this, new ApiResponseEventArgs<List<Guid>>(apiResponse));
|
||||
OnHello?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorHello(Exception exception)
|
||||
@@ -212,16 +271,16 @@ namespace UseSourceGeneration.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<List<List<RolesReportsHash>>>>? OnRolesReportGet;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnRolesReportGet;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorRolesReportGet;
|
||||
|
||||
internal void ExecuteOnRolesReportGet(ApiResponse<List<List<RolesReportsHash>>> apiResponse)
|
||||
internal void ExecuteOnRolesReportGet(DefaultApi.RolesReportGetApiResponse apiResponse)
|
||||
{
|
||||
OnRolesReportGet?.Invoke(this, new ApiResponseEventArgs<List<List<RolesReportsHash>>>(apiResponse));
|
||||
OnRolesReportGet?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorRolesReportGet(Exception exception)
|
||||
@@ -232,16 +291,16 @@ namespace UseSourceGeneration.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<NotificationtestGetElementsV1ResponseMPayload>>? OnTest;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnTest;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorTest;
|
||||
|
||||
internal void ExecuteOnTest(ApiResponse<NotificationtestGetElementsV1ResponseMPayload> apiResponse)
|
||||
internal void ExecuteOnTest(DefaultApi.TestApiResponse apiResponse)
|
||||
{
|
||||
OnTest?.Invoke(this, new ApiResponseEventArgs<NotificationtestGetElementsV1ResponseMPayload>(apiResponse));
|
||||
OnTest?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorTest(Exception exception)
|
||||
@@ -257,6 +316,11 @@ namespace UseSourceGeneration.Api
|
||||
{
|
||||
private JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The logger factory
|
||||
/// </summary>
|
||||
public ILoggerFactory LoggerFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
@@ -301,7 +365,7 @@ namespace UseSourceGeneration.Api
|
||||
/// Initializes a new instance of the <see cref="DefaultApi"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public DefaultApi(ILogger<DefaultApi> logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents,
|
||||
public DefaultApi(ILogger<DefaultApi> logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents,
|
||||
TokenProvider<ApiKeyToken> apiKeyProvider,
|
||||
TokenProvider<BearerToken> bearerTokenProvider,
|
||||
TokenProvider<BasicToken> basicTokenProvider,
|
||||
@@ -309,7 +373,8 @@ namespace UseSourceGeneration.Api
|
||||
TokenProvider<OAuthToken> oauthTokenProvider)
|
||||
{
|
||||
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
|
||||
Logger = logger;
|
||||
LoggerFactory = loggerFactory;
|
||||
Logger = LoggerFactory.CreateLogger<DefaultApi>();
|
||||
HttpClient = httpClient;
|
||||
Events = defaultApiEvents;
|
||||
ApiKeyProvider = apiKeyProvider;
|
||||
@@ -323,7 +388,7 @@ namespace UseSourceGeneration.Api
|
||||
/// Processes the server response
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
private void AfterFooGetDefaultImplementation(ApiResponse<FooGetDefaultResponse> apiResponseLocalVar)
|
||||
private void AfterFooGetDefaultImplementation(IFooGetApiResponse apiResponseLocalVar)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterFooGet(ref suppressDefaultLog, apiResponseLocalVar);
|
||||
@@ -336,7 +401,7 @@ namespace UseSourceGeneration.Api
|
||||
/// </summary>
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
partial void AfterFooGet(ref bool suppressDefaultLog, ApiResponse<FooGetDefaultResponse> apiResponseLocalVar);
|
||||
partial void AfterFooGet(ref bool suppressDefaultLog, IFooGetApiResponse apiResponseLocalVar);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -365,8 +430,8 @@ namespace UseSourceGeneration.Api
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="FooGetDefaultResponse"/></returns>
|
||||
public async Task<ApiResponse<FooGetDefaultResponse>?> FooGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IFooGetApiResponse"/>></returns>
|
||||
public async Task<IFooGetApiResponse?> FooGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -383,8 +448,8 @@ namespace UseSourceGeneration.Api
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="FooGetDefaultResponse"/></returns>
|
||||
public async Task<ApiResponse<FooGetDefaultResponse>> FooGetAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IFooGetApiResponse"/>></returns>
|
||||
public async Task<IFooGetApiResponse> FooGetAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -416,7 +481,9 @@ namespace UseSourceGeneration.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<FooGetDefaultResponse> apiResponseLocalVar = new ApiResponse<FooGetDefaultResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/foo", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<FooGetApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<FooGetApiResponse>();
|
||||
|
||||
FooGetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/foo", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterFooGetDefaultImplementation(apiResponseLocalVar);
|
||||
|
||||
@@ -434,6 +501,83 @@ namespace UseSourceGeneration.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="FooGetApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class FooGetApiResponse : UseSourceGeneration.Client.ApiResponse, IFooGetApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<FooGetApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="FooGetApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public FooGetApiResponse(ILogger<FooGetApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is the default response type
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsDefault => true;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 0 Default
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public UseSourceGeneration.Model.FooGetDefaultResponse? Default()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsDefault
|
||||
? System.Text.Json.JsonSerializer.Deserialize<UseSourceGeneration.Model.FooGetDefaultResponse>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 0 Default and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryDefault([NotNullWhen(true)]out UseSourceGeneration.Model.FooGetDefaultResponse? result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Default();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)0);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
partial void FormatGetCountry(ref string country);
|
||||
|
||||
/// <summary>
|
||||
@@ -452,7 +596,7 @@ namespace UseSourceGeneration.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="country"></param>
|
||||
private void AfterGetCountryDefaultImplementation(ApiResponse<object> apiResponseLocalVar, string country)
|
||||
private void AfterGetCountryDefaultImplementation(IGetCountryApiResponse apiResponseLocalVar, string country)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterGetCountry(ref suppressDefaultLog, apiResponseLocalVar, country);
|
||||
@@ -466,7 +610,7 @@ namespace UseSourceGeneration.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="country"></param>
|
||||
partial void AfterGetCountry(ref bool suppressDefaultLog, ApiResponse<object> apiResponseLocalVar, string country);
|
||||
partial void AfterGetCountry(ref bool suppressDefaultLog, IGetCountryApiResponse apiResponseLocalVar, string country);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -498,8 +642,8 @@ namespace UseSourceGeneration.Api
|
||||
/// </summary>
|
||||
/// <param name="country"></param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="object"/></returns>
|
||||
public async Task<ApiResponse<object>?> GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IGetCountryApiResponse"/>></returns>
|
||||
public async Task<IGetCountryApiResponse?> GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -517,8 +661,8 @@ namespace UseSourceGeneration.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="country"></param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="object"/></returns>
|
||||
public async Task<ApiResponse<object>> GetCountryAsync(string country, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IGetCountryApiResponse"/>></returns>
|
||||
public async Task<IGetCountryApiResponse> GetCountryAsync(string country, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -564,7 +708,9 @@ namespace UseSourceGeneration.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<object> apiResponseLocalVar = new ApiResponse<object>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/country", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<GetCountryApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<GetCountryApiResponse>();
|
||||
|
||||
GetCountryApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/country", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterGetCountryDefaultImplementation(apiResponseLocalVar, country);
|
||||
|
||||
@@ -582,11 +728,56 @@ namespace UseSourceGeneration.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GetCountryApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class GetCountryApiResponse : UseSourceGeneration.Client.ApiResponse, IGetCountryApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<GetCountryApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GetCountryApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public GetCountryApiResponse(ILogger<GetCountryApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes the server response
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
private void AfterHelloDefaultImplementation(ApiResponse<List<Guid>> apiResponseLocalVar)
|
||||
private void AfterHelloDefaultImplementation(IHelloApiResponse apiResponseLocalVar)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterHello(ref suppressDefaultLog, apiResponseLocalVar);
|
||||
@@ -599,7 +790,7 @@ namespace UseSourceGeneration.Api
|
||||
/// </summary>
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
partial void AfterHello(ref bool suppressDefaultLog, ApiResponse<List<Guid>> apiResponseLocalVar);
|
||||
partial void AfterHello(ref bool suppressDefaultLog, IHelloApiResponse apiResponseLocalVar);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -628,8 +819,8 @@ namespace UseSourceGeneration.Api
|
||||
/// Hello Hello
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="List{TValue}"/></returns>
|
||||
public async Task<ApiResponse<List<Guid>>?> HelloOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IHelloApiResponse"/>></returns>
|
||||
public async Task<IHelloApiResponse?> HelloOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -646,8 +837,8 @@ namespace UseSourceGeneration.Api
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="List{TValue}"/></returns>
|
||||
public async Task<ApiResponse<List<Guid>>> HelloAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IHelloApiResponse"/>></returns>
|
||||
public async Task<IHelloApiResponse> HelloAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -679,7 +870,9 @@ namespace UseSourceGeneration.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<List<Guid>> apiResponseLocalVar = new ApiResponse<List<Guid>>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/hello", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<HelloApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<HelloApiResponse>();
|
||||
|
||||
HelloApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/hello", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterHelloDefaultImplementation(apiResponseLocalVar);
|
||||
|
||||
@@ -697,11 +890,88 @@ namespace UseSourceGeneration.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="HelloApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class HelloApiResponse : UseSourceGeneration.Client.ApiResponse, IHelloApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<HelloApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="HelloApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public HelloApiResponse(ILogger<HelloApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<Guid>? Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<List<Guid>>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out List<Guid>? result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes the server response
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
private void AfterRolesReportGetDefaultImplementation(ApiResponse<List<List<RolesReportsHash>>> apiResponseLocalVar)
|
||||
private void AfterRolesReportGetDefaultImplementation(IRolesReportGetApiResponse apiResponseLocalVar)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterRolesReportGet(ref suppressDefaultLog, apiResponseLocalVar);
|
||||
@@ -714,7 +984,7 @@ namespace UseSourceGeneration.Api
|
||||
/// </summary>
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
partial void AfterRolesReportGet(ref bool suppressDefaultLog, ApiResponse<List<List<RolesReportsHash>>> apiResponseLocalVar);
|
||||
partial void AfterRolesReportGet(ref bool suppressDefaultLog, IRolesReportGetApiResponse apiResponseLocalVar);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -743,8 +1013,8 @@ namespace UseSourceGeneration.Api
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="List{TValue}"/></returns>
|
||||
public async Task<ApiResponse<List<List<RolesReportsHash>>>?> RolesReportGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IRolesReportGetApiResponse"/>></returns>
|
||||
public async Task<IRolesReportGetApiResponse?> RolesReportGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -761,8 +1031,8 @@ namespace UseSourceGeneration.Api
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="List{TValue}"/></returns>
|
||||
public async Task<ApiResponse<List<List<RolesReportsHash>>>> RolesReportGetAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IRolesReportGetApiResponse"/>></returns>
|
||||
public async Task<IRolesReportGetApiResponse> RolesReportGetAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -794,7 +1064,9 @@ namespace UseSourceGeneration.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<List<List<RolesReportsHash>>> apiResponseLocalVar = new ApiResponse<List<List<RolesReportsHash>>>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/roles/report", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<RolesReportGetApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<RolesReportGetApiResponse>();
|
||||
|
||||
RolesReportGetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/roles/report", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterRolesReportGetDefaultImplementation(apiResponseLocalVar);
|
||||
|
||||
@@ -812,11 +1084,88 @@ namespace UseSourceGeneration.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="RolesReportGetApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class RolesReportGetApiResponse : UseSourceGeneration.Client.ApiResponse, IRolesReportGetApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<RolesReportGetApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="RolesReportGetApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public RolesReportGetApiResponse(ILogger<RolesReportGetApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<List>? Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<List<List>>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out List<List>? result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes the server response
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
private void AfterTestDefaultImplementation(ApiResponse<NotificationtestGetElementsV1ResponseMPayload> apiResponseLocalVar)
|
||||
private void AfterTestDefaultImplementation(ITestApiResponse apiResponseLocalVar)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterTest(ref suppressDefaultLog, apiResponseLocalVar);
|
||||
@@ -829,7 +1178,7 @@ namespace UseSourceGeneration.Api
|
||||
/// </summary>
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
partial void AfterTest(ref bool suppressDefaultLog, ApiResponse<NotificationtestGetElementsV1ResponseMPayload> apiResponseLocalVar);
|
||||
partial void AfterTest(ref bool suppressDefaultLog, ITestApiResponse apiResponseLocalVar);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -858,8 +1207,8 @@ namespace UseSourceGeneration.Api
|
||||
/// Retrieve an existing Notificationtest's Elements
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="NotificationtestGetElementsV1ResponseMPayload"/></returns>
|
||||
public async Task<ApiResponse<NotificationtestGetElementsV1ResponseMPayload>?> TestOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="ITestApiResponse"/>></returns>
|
||||
public async Task<ITestApiResponse?> TestOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -876,8 +1225,8 @@ namespace UseSourceGeneration.Api
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="NotificationtestGetElementsV1ResponseMPayload"/></returns>
|
||||
public async Task<ApiResponse<NotificationtestGetElementsV1ResponseMPayload>> TestAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="ITestApiResponse"/>></returns>
|
||||
public async Task<ITestApiResponse> TestAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -909,7 +1258,9 @@ namespace UseSourceGeneration.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<NotificationtestGetElementsV1ResponseMPayload> apiResponseLocalVar = new ApiResponse<NotificationtestGetElementsV1ResponseMPayload>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/test", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<TestApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<TestApiResponse>();
|
||||
|
||||
TestApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/test", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterTestDefaultImplementation(apiResponseLocalVar);
|
||||
|
||||
@@ -926,5 +1277,82 @@ namespace UseSourceGeneration.Api
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="TestApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class TestApiResponse : UseSourceGeneration.Client.ApiResponse, ITestApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<TestApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="TestApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public TestApiResponse(ILogger<TestApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public UseSourceGeneration.Model.NotificationtestGetElementsV1ResponseMPayload? Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<UseSourceGeneration.Model.NotificationtestGetElementsV1ResponseMPayload>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out UseSourceGeneration.Model.NotificationtestGetElementsV1ResponseMPayload? result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,8 +19,8 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json;
|
||||
using UseSourceGeneration.Client;
|
||||
using UseSourceGeneration.Api;
|
||||
using UseSourceGeneration.Model;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace UseSourceGeneration.Api
|
||||
{
|
||||
@@ -44,8 +44,8 @@ namespace UseSourceGeneration.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<ModelClient>></returns>
|
||||
Task<ApiResponse<ModelClient>> TestClassnameAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="ITestClassnameApiResponse"/>></returns>
|
||||
Task<ITestClassnameApiResponse> TestClassnameAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// To test class name in snake case
|
||||
@@ -55,29 +55,40 @@ namespace UseSourceGeneration.Api
|
||||
/// </remarks>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>ModelClient>?></returns>
|
||||
Task<ApiResponse<ModelClient>?> TestClassnameOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="ITestClassnameApiResponse"/>?></returns>
|
||||
Task<ITestClassnameApiResponse?> TestClassnameOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ITestClassnameApiResponse"/>
|
||||
/// </summary>
|
||||
public interface ITestClassnameApiResponse : UseSourceGeneration.Client.IApiResponse, IOk<UseSourceGeneration.Model.ModelClient?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// This class is registered as transient.
|
||||
/// </summary>
|
||||
public class FakeClassnameTags123ApiEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<ModelClient>>? OnTestClassname;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnTestClassname;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorTestClassname;
|
||||
|
||||
internal void ExecuteOnTestClassname(ApiResponse<ModelClient> apiResponse)
|
||||
internal void ExecuteOnTestClassname(FakeClassnameTags123Api.TestClassnameApiResponse apiResponse)
|
||||
{
|
||||
OnTestClassname?.Invoke(this, new ApiResponseEventArgs<ModelClient>(apiResponse));
|
||||
OnTestClassname?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorTestClassname(Exception exception)
|
||||
@@ -93,6 +104,11 @@ namespace UseSourceGeneration.Api
|
||||
{
|
||||
private JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The logger factory
|
||||
/// </summary>
|
||||
public ILoggerFactory LoggerFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
@@ -137,7 +153,7 @@ namespace UseSourceGeneration.Api
|
||||
/// Initializes a new instance of the <see cref="FakeClassnameTags123Api"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public FakeClassnameTags123Api(ILogger<FakeClassnameTags123Api> logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, FakeClassnameTags123ApiEvents fakeClassnameTags123ApiEvents,
|
||||
public FakeClassnameTags123Api(ILogger<FakeClassnameTags123Api> logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, FakeClassnameTags123ApiEvents fakeClassnameTags123ApiEvents,
|
||||
TokenProvider<ApiKeyToken> apiKeyProvider,
|
||||
TokenProvider<BearerToken> bearerTokenProvider,
|
||||
TokenProvider<BasicToken> basicTokenProvider,
|
||||
@@ -145,7 +161,8 @@ namespace UseSourceGeneration.Api
|
||||
TokenProvider<OAuthToken> oauthTokenProvider)
|
||||
{
|
||||
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
|
||||
Logger = logger;
|
||||
LoggerFactory = loggerFactory;
|
||||
Logger = LoggerFactory.CreateLogger<FakeClassnameTags123Api>();
|
||||
HttpClient = httpClient;
|
||||
Events = fakeClassnameTags123ApiEvents;
|
||||
ApiKeyProvider = apiKeyProvider;
|
||||
@@ -173,7 +190,7 @@ namespace UseSourceGeneration.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="modelClient"></param>
|
||||
private void AfterTestClassnameDefaultImplementation(ApiResponse<ModelClient> apiResponseLocalVar, ModelClient modelClient)
|
||||
private void AfterTestClassnameDefaultImplementation(ITestClassnameApiResponse apiResponseLocalVar, ModelClient modelClient)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterTestClassname(ref suppressDefaultLog, apiResponseLocalVar, modelClient);
|
||||
@@ -187,7 +204,7 @@ namespace UseSourceGeneration.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="modelClient"></param>
|
||||
partial void AfterTestClassname(ref bool suppressDefaultLog, ApiResponse<ModelClient> apiResponseLocalVar, ModelClient modelClient);
|
||||
partial void AfterTestClassname(ref bool suppressDefaultLog, ITestClassnameApiResponse apiResponseLocalVar, ModelClient modelClient);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -219,8 +236,8 @@ namespace UseSourceGeneration.Api
|
||||
/// </summary>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="ModelClient"/></returns>
|
||||
public async Task<ApiResponse<ModelClient>?> TestClassnameOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="ITestClassnameApiResponse"/>></returns>
|
||||
public async Task<ITestClassnameApiResponse?> TestClassnameOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -238,8 +255,8 @@ namespace UseSourceGeneration.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="ModelClient"/></returns>
|
||||
public async Task<ApiResponse<ModelClient>> TestClassnameAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="ITestClassnameApiResponse"/>></returns>
|
||||
public async Task<ITestClassnameApiResponse> TestClassnameAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -299,7 +316,9 @@ namespace UseSourceGeneration.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<ModelClient> apiResponseLocalVar = new ApiResponse<ModelClient>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake_classname_test", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<TestClassnameApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<TestClassnameApiResponse>();
|
||||
|
||||
TestClassnameApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake_classname_test", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterTestClassnameDefaultImplementation(apiResponseLocalVar, modelClient);
|
||||
|
||||
@@ -320,5 +339,82 @@ namespace UseSourceGeneration.Api
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="TestClassnameApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class TestClassnameApiResponse : UseSourceGeneration.Client.ApiResponse, ITestClassnameApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<TestClassnameApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="TestClassnameApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public TestClassnameApiResponse(ILogger<TestClassnameApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public UseSourceGeneration.Model.ModelClient? Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<UseSourceGeneration.Model.ModelClient>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out UseSourceGeneration.Model.ModelClient? result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,8 +19,8 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json;
|
||||
using UseSourceGeneration.Client;
|
||||
using UseSourceGeneration.Api;
|
||||
using UseSourceGeneration.Model;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace UseSourceGeneration.Api
|
||||
{
|
||||
@@ -44,8 +44,8 @@ namespace UseSourceGeneration.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<object>></returns>
|
||||
Task<ApiResponse<object>> DeleteOrderAsync(string orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IDeleteOrderApiResponse"/>></returns>
|
||||
Task<IDeleteOrderApiResponse> DeleteOrderAsync(string orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Delete purchase order by ID
|
||||
@@ -55,8 +55,8 @@ namespace UseSourceGeneration.Api
|
||||
/// </remarks>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>object>?></returns>
|
||||
Task<ApiResponse<object>?> DeleteOrderOrDefaultAsync(string orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IDeleteOrderApiResponse"/>?></returns>
|
||||
Task<IDeleteOrderApiResponse?> DeleteOrderOrDefaultAsync(string orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Returns pet inventories by status
|
||||
@@ -66,8 +66,8 @@ namespace UseSourceGeneration.Api
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<Dictionary<string, int>>></returns>
|
||||
Task<ApiResponse<Dictionary<string, int>>> GetInventoryAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IGetInventoryApiResponse"/>></returns>
|
||||
Task<IGetInventoryApiResponse> GetInventoryAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Returns pet inventories by status
|
||||
@@ -76,8 +76,8 @@ namespace UseSourceGeneration.Api
|
||||
/// Returns a map of status codes to quantities
|
||||
/// </remarks>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>Dictionary<string, int>>?></returns>
|
||||
Task<ApiResponse<Dictionary<string, int>>?> GetInventoryOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IGetInventoryApiResponse"/>?></returns>
|
||||
Task<IGetInventoryApiResponse?> GetInventoryOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Find purchase order by ID
|
||||
@@ -88,8 +88,8 @@ namespace UseSourceGeneration.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<Order>></returns>
|
||||
Task<ApiResponse<Order>> GetOrderByIdAsync(long orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IGetOrderByIdApiResponse"/>></returns>
|
||||
Task<IGetOrderByIdApiResponse> GetOrderByIdAsync(long orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Find purchase order by ID
|
||||
@@ -99,8 +99,8 @@ namespace UseSourceGeneration.Api
|
||||
/// </remarks>
|
||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>Order>?></returns>
|
||||
Task<ApiResponse<Order>?> GetOrderByIdOrDefaultAsync(long orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IGetOrderByIdApiResponse"/>?></returns>
|
||||
Task<IGetOrderByIdApiResponse?> GetOrderByIdOrDefaultAsync(long orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Place an order for a pet
|
||||
@@ -111,8 +111,8 @@ namespace UseSourceGeneration.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="order">order placed for purchasing the pet</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<Order>></returns>
|
||||
Task<ApiResponse<Order>> PlaceOrderAsync(Order order, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IPlaceOrderApiResponse"/>></returns>
|
||||
Task<IPlaceOrderApiResponse> PlaceOrderAsync(Order order, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Place an order for a pet
|
||||
@@ -122,29 +122,100 @@ namespace UseSourceGeneration.Api
|
||||
/// </remarks>
|
||||
/// <param name="order">order placed for purchasing the pet</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>Order>?></returns>
|
||||
Task<ApiResponse<Order>?> PlaceOrderOrDefaultAsync(Order order, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IPlaceOrderApiResponse"/>?></returns>
|
||||
Task<IPlaceOrderApiResponse?> PlaceOrderOrDefaultAsync(Order order, System.Threading.CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IDeleteOrderApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IDeleteOrderApiResponse : UseSourceGeneration.Client.IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 400 BadRequest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsBadRequest { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 404 NotFound
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsNotFound { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IGetInventoryApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IGetInventoryApiResponse : UseSourceGeneration.Client.IApiResponse, IOk<Dictionary<string, int>?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IGetOrderByIdApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IGetOrderByIdApiResponse : UseSourceGeneration.Client.IApiResponse, IOk<UseSourceGeneration.Model.Order?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 400 BadRequest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsBadRequest { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 404 NotFound
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsNotFound { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IPlaceOrderApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IPlaceOrderApiResponse : UseSourceGeneration.Client.IApiResponse, IOk<UseSourceGeneration.Model.Order?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 400 BadRequest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsBadRequest { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// This class is registered as transient.
|
||||
/// </summary>
|
||||
public class StoreApiEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<object>>? OnDeleteOrder;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnDeleteOrder;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorDeleteOrder;
|
||||
|
||||
internal void ExecuteOnDeleteOrder(ApiResponse<object> apiResponse)
|
||||
internal void ExecuteOnDeleteOrder(StoreApi.DeleteOrderApiResponse apiResponse)
|
||||
{
|
||||
OnDeleteOrder?.Invoke(this, new ApiResponseEventArgs<object>(apiResponse));
|
||||
OnDeleteOrder?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorDeleteOrder(Exception exception)
|
||||
@@ -155,16 +226,16 @@ namespace UseSourceGeneration.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<Dictionary<string, int>>>? OnGetInventory;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnGetInventory;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorGetInventory;
|
||||
|
||||
internal void ExecuteOnGetInventory(ApiResponse<Dictionary<string, int>> apiResponse)
|
||||
internal void ExecuteOnGetInventory(StoreApi.GetInventoryApiResponse apiResponse)
|
||||
{
|
||||
OnGetInventory?.Invoke(this, new ApiResponseEventArgs<Dictionary<string, int>>(apiResponse));
|
||||
OnGetInventory?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorGetInventory(Exception exception)
|
||||
@@ -175,16 +246,16 @@ namespace UseSourceGeneration.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<Order>>? OnGetOrderById;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnGetOrderById;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorGetOrderById;
|
||||
|
||||
internal void ExecuteOnGetOrderById(ApiResponse<Order> apiResponse)
|
||||
internal void ExecuteOnGetOrderById(StoreApi.GetOrderByIdApiResponse apiResponse)
|
||||
{
|
||||
OnGetOrderById?.Invoke(this, new ApiResponseEventArgs<Order>(apiResponse));
|
||||
OnGetOrderById?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorGetOrderById(Exception exception)
|
||||
@@ -195,16 +266,16 @@ namespace UseSourceGeneration.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<Order>>? OnPlaceOrder;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnPlaceOrder;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorPlaceOrder;
|
||||
|
||||
internal void ExecuteOnPlaceOrder(ApiResponse<Order> apiResponse)
|
||||
internal void ExecuteOnPlaceOrder(StoreApi.PlaceOrderApiResponse apiResponse)
|
||||
{
|
||||
OnPlaceOrder?.Invoke(this, new ApiResponseEventArgs<Order>(apiResponse));
|
||||
OnPlaceOrder?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorPlaceOrder(Exception exception)
|
||||
@@ -220,6 +291,11 @@ namespace UseSourceGeneration.Api
|
||||
{
|
||||
private JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The logger factory
|
||||
/// </summary>
|
||||
public ILoggerFactory LoggerFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
@@ -264,7 +340,7 @@ namespace UseSourceGeneration.Api
|
||||
/// Initializes a new instance of the <see cref="StoreApi"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public StoreApi(ILogger<StoreApi> logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, StoreApiEvents storeApiEvents,
|
||||
public StoreApi(ILogger<StoreApi> logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, StoreApiEvents storeApiEvents,
|
||||
TokenProvider<ApiKeyToken> apiKeyProvider,
|
||||
TokenProvider<BearerToken> bearerTokenProvider,
|
||||
TokenProvider<BasicToken> basicTokenProvider,
|
||||
@@ -272,7 +348,8 @@ namespace UseSourceGeneration.Api
|
||||
TokenProvider<OAuthToken> oauthTokenProvider)
|
||||
{
|
||||
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
|
||||
Logger = logger;
|
||||
LoggerFactory = loggerFactory;
|
||||
Logger = LoggerFactory.CreateLogger<StoreApi>();
|
||||
HttpClient = httpClient;
|
||||
Events = storeApiEvents;
|
||||
ApiKeyProvider = apiKeyProvider;
|
||||
@@ -300,7 +377,7 @@ namespace UseSourceGeneration.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="orderId"></param>
|
||||
private void AfterDeleteOrderDefaultImplementation(ApiResponse<object> apiResponseLocalVar, string orderId)
|
||||
private void AfterDeleteOrderDefaultImplementation(IDeleteOrderApiResponse apiResponseLocalVar, string orderId)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterDeleteOrder(ref suppressDefaultLog, apiResponseLocalVar, orderId);
|
||||
@@ -314,7 +391,7 @@ namespace UseSourceGeneration.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="orderId"></param>
|
||||
partial void AfterDeleteOrder(ref bool suppressDefaultLog, ApiResponse<object> apiResponseLocalVar, string orderId);
|
||||
partial void AfterDeleteOrder(ref bool suppressDefaultLog, IDeleteOrderApiResponse apiResponseLocalVar, string orderId);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -346,8 +423,8 @@ namespace UseSourceGeneration.Api
|
||||
/// </summary>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="object"/></returns>
|
||||
public async Task<ApiResponse<object>?> DeleteOrderOrDefaultAsync(string orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IDeleteOrderApiResponse"/>></returns>
|
||||
public async Task<IDeleteOrderApiResponse?> DeleteOrderOrDefaultAsync(string orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -365,8 +442,8 @@ namespace UseSourceGeneration.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="object"/></returns>
|
||||
public async Task<ApiResponse<object>> DeleteOrderAsync(string orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IDeleteOrderApiResponse"/>></returns>
|
||||
public async Task<IDeleteOrderApiResponse> DeleteOrderAsync(string orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -394,7 +471,9 @@ namespace UseSourceGeneration.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<object> apiResponseLocalVar = new ApiResponse<object>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<DeleteOrderApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<DeleteOrderApiResponse>();
|
||||
|
||||
DeleteOrderApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterDeleteOrderDefaultImplementation(apiResponseLocalVar, orderId);
|
||||
|
||||
@@ -412,11 +491,62 @@ namespace UseSourceGeneration.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DeleteOrderApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class DeleteOrderApiResponse : UseSourceGeneration.Client.ApiResponse, IDeleteOrderApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<DeleteOrderApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DeleteOrderApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public DeleteOrderApiResponse(ILogger<DeleteOrderApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 400 BadRequest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsBadRequest => 400 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 404 NotFound
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsNotFound => 404 == (int)StatusCode;
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes the server response
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
private void AfterGetInventoryDefaultImplementation(ApiResponse<Dictionary<string, int>> apiResponseLocalVar)
|
||||
private void AfterGetInventoryDefaultImplementation(IGetInventoryApiResponse apiResponseLocalVar)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterGetInventory(ref suppressDefaultLog, apiResponseLocalVar);
|
||||
@@ -429,7 +559,7 @@ namespace UseSourceGeneration.Api
|
||||
/// </summary>
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
partial void AfterGetInventory(ref bool suppressDefaultLog, ApiResponse<Dictionary<string, int>> apiResponseLocalVar);
|
||||
partial void AfterGetInventory(ref bool suppressDefaultLog, IGetInventoryApiResponse apiResponseLocalVar);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -458,8 +588,8 @@ namespace UseSourceGeneration.Api
|
||||
/// Returns pet inventories by status Returns a map of status codes to quantities
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Dictionary{TKey, TValue}"/></returns>
|
||||
public async Task<ApiResponse<Dictionary<string, int>>?> GetInventoryOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IGetInventoryApiResponse"/>></returns>
|
||||
public async Task<IGetInventoryApiResponse?> GetInventoryOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -476,8 +606,8 @@ namespace UseSourceGeneration.Api
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Dictionary{TKey, TValue}"/></returns>
|
||||
public async Task<ApiResponse<Dictionary<string, int>>> GetInventoryAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IGetInventoryApiResponse"/>></returns>
|
||||
public async Task<IGetInventoryApiResponse> GetInventoryAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -517,7 +647,9 @@ namespace UseSourceGeneration.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<Dictionary<string, int>> apiResponseLocalVar = new ApiResponse<Dictionary<string, int>>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/inventory", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<GetInventoryApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<GetInventoryApiResponse>();
|
||||
|
||||
GetInventoryApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/inventory", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterGetInventoryDefaultImplementation(apiResponseLocalVar);
|
||||
|
||||
@@ -539,6 +671,83 @@ namespace UseSourceGeneration.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GetInventoryApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class GetInventoryApiResponse : UseSourceGeneration.Client.ApiResponse, IGetInventoryApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<GetInventoryApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GetInventoryApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public GetInventoryApiResponse(ILogger<GetInventoryApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Dictionary<string, int>? Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Dictionary<string, int>>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out Dictionary<string, int>? result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
partial void FormatGetOrderById(ref long orderId);
|
||||
|
||||
/// <summary>
|
||||
@@ -546,7 +755,7 @@ namespace UseSourceGeneration.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="orderId"></param>
|
||||
private void AfterGetOrderByIdDefaultImplementation(ApiResponse<Order> apiResponseLocalVar, long orderId)
|
||||
private void AfterGetOrderByIdDefaultImplementation(IGetOrderByIdApiResponse apiResponseLocalVar, long orderId)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterGetOrderById(ref suppressDefaultLog, apiResponseLocalVar, orderId);
|
||||
@@ -560,7 +769,7 @@ namespace UseSourceGeneration.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="orderId"></param>
|
||||
partial void AfterGetOrderById(ref bool suppressDefaultLog, ApiResponse<Order> apiResponseLocalVar, long orderId);
|
||||
partial void AfterGetOrderById(ref bool suppressDefaultLog, IGetOrderByIdApiResponse apiResponseLocalVar, long orderId);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -592,8 +801,8 @@ namespace UseSourceGeneration.Api
|
||||
/// </summary>
|
||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Order"/></returns>
|
||||
public async Task<ApiResponse<Order>?> GetOrderByIdOrDefaultAsync(long orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IGetOrderByIdApiResponse"/>></returns>
|
||||
public async Task<IGetOrderByIdApiResponse?> GetOrderByIdOrDefaultAsync(long orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -611,8 +820,8 @@ namespace UseSourceGeneration.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Order"/></returns>
|
||||
public async Task<ApiResponse<Order>> GetOrderByIdAsync(long orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IGetOrderByIdApiResponse"/>></returns>
|
||||
public async Task<IGetOrderByIdApiResponse> GetOrderByIdAsync(long orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -648,7 +857,9 @@ namespace UseSourceGeneration.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<Order> apiResponseLocalVar = new ApiResponse<Order>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<GetOrderByIdApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<GetOrderByIdApiResponse>();
|
||||
|
||||
GetOrderByIdApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterGetOrderByIdDefaultImplementation(apiResponseLocalVar, orderId);
|
||||
|
||||
@@ -666,6 +877,95 @@ namespace UseSourceGeneration.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GetOrderByIdApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class GetOrderByIdApiResponse : UseSourceGeneration.Client.ApiResponse, IGetOrderByIdApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<GetOrderByIdApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GetOrderByIdApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public GetOrderByIdApiResponse(ILogger<GetOrderByIdApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public UseSourceGeneration.Model.Order? Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<UseSourceGeneration.Model.Order>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out UseSourceGeneration.Model.Order? result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 400 BadRequest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsBadRequest => 400 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 404 NotFound
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsNotFound => 404 == (int)StatusCode;
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
partial void FormatPlaceOrder(Order order);
|
||||
|
||||
/// <summary>
|
||||
@@ -684,7 +984,7 @@ namespace UseSourceGeneration.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="order"></param>
|
||||
private void AfterPlaceOrderDefaultImplementation(ApiResponse<Order> apiResponseLocalVar, Order order)
|
||||
private void AfterPlaceOrderDefaultImplementation(IPlaceOrderApiResponse apiResponseLocalVar, Order order)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterPlaceOrder(ref suppressDefaultLog, apiResponseLocalVar, order);
|
||||
@@ -698,7 +998,7 @@ namespace UseSourceGeneration.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="order"></param>
|
||||
partial void AfterPlaceOrder(ref bool suppressDefaultLog, ApiResponse<Order> apiResponseLocalVar, Order order);
|
||||
partial void AfterPlaceOrder(ref bool suppressDefaultLog, IPlaceOrderApiResponse apiResponseLocalVar, Order order);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -730,8 +1030,8 @@ namespace UseSourceGeneration.Api
|
||||
/// </summary>
|
||||
/// <param name="order">order placed for purchasing the pet</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Order"/></returns>
|
||||
public async Task<ApiResponse<Order>?> PlaceOrderOrDefaultAsync(Order order, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IPlaceOrderApiResponse"/>></returns>
|
||||
public async Task<IPlaceOrderApiResponse?> PlaceOrderOrDefaultAsync(Order order, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -749,8 +1049,8 @@ namespace UseSourceGeneration.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="order">order placed for purchasing the pet</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Order"/></returns>
|
||||
public async Task<ApiResponse<Order>> PlaceOrderAsync(Order order, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IPlaceOrderApiResponse"/>></returns>
|
||||
public async Task<IPlaceOrderApiResponse> PlaceOrderAsync(Order order, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -800,7 +1100,9 @@ namespace UseSourceGeneration.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<Order> apiResponseLocalVar = new ApiResponse<Order>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<PlaceOrderApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<PlaceOrderApiResponse>();
|
||||
|
||||
PlaceOrderApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterPlaceOrderDefaultImplementation(apiResponseLocalVar, order);
|
||||
|
||||
@@ -817,5 +1119,88 @@ namespace UseSourceGeneration.Api
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="PlaceOrderApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class PlaceOrderApiResponse : UseSourceGeneration.Client.ApiResponse, IPlaceOrderApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<PlaceOrderApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="PlaceOrderApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public PlaceOrderApiResponse(ILogger<PlaceOrderApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public UseSourceGeneration.Model.Order? Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<UseSourceGeneration.Model.Order>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out UseSourceGeneration.Model.Order? result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 400 BadRequest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsBadRequest => 400 == (int)StatusCode;
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,18 +5,18 @@ namespace UseSourceGeneration.Client
|
||||
/// <summary>
|
||||
/// Useful for tracking server health
|
||||
/// </summary>
|
||||
public class ApiResponseEventArgs<T> : EventArgs
|
||||
public class ApiResponseEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// The ApiResponse
|
||||
/// </summary>
|
||||
public ApiResponse<T> ApiResponse { get; }
|
||||
public ApiResponse ApiResponse { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The ApiResponseEventArgs
|
||||
/// </summary>
|
||||
/// <param name="apiResponse"></param>
|
||||
public ApiResponseEventArgs(ApiResponse<T> apiResponse)
|
||||
public ApiResponseEventArgs(ApiResponse apiResponse)
|
||||
{
|
||||
ApiResponse = apiResponse;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
|
||||
@@ -20,15 +19,15 @@ namespace UseSourceGeneration.Client
|
||||
/// <summary>
|
||||
/// Provides a non-generic contract for the ApiResponse wrapper.
|
||||
/// </summary>
|
||||
public interface IApiResponse
|
||||
public partial interface IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The type that represents the server's response.
|
||||
/// The IsSuccessStatusCode from the api response
|
||||
/// </summary>
|
||||
Type ResponseType { get; }
|
||||
bool IsSuccessStatusCode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the status code (HTTP status code)
|
||||
/// Gets the status code (HTTP status code)
|
||||
/// </summary>
|
||||
/// <value>The status code.</value>
|
||||
HttpStatusCode StatusCode { get; }
|
||||
@@ -43,11 +42,26 @@ namespace UseSourceGeneration.Client
|
||||
/// </summary>
|
||||
DateTime DownloadedAt { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The headers contained in the api response
|
||||
/// </summary>
|
||||
System.Net.Http.Headers.HttpResponseHeaders Headers { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The path used when making the request.
|
||||
/// </summary>
|
||||
string Path { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The reason phrase contained in the api response
|
||||
/// </summary>
|
||||
string? ReasonPhrase { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The DateTime when the request was sent.
|
||||
/// </summary>
|
||||
DateTime RequestedAt { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The Uri used when making the request.
|
||||
/// </summary>
|
||||
@@ -57,26 +71,18 @@ namespace UseSourceGeneration.Client
|
||||
/// <summary>
|
||||
/// API Response
|
||||
/// </summary>
|
||||
public partial class ApiResponse<T> : IApiResponse
|
||||
public partial class ApiResponse : IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the status code (HTTP status code)
|
||||
/// Gets the status code (HTTP status code)
|
||||
/// </summary>
|
||||
/// <value>The status code.</value>
|
||||
public HttpStatusCode StatusCode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The type that represents the server's response.
|
||||
/// </summary>
|
||||
public Type ResponseType
|
||||
{
|
||||
get { return typeof(T); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The raw data
|
||||
/// </summary>
|
||||
public string RawContent { get; private set; }
|
||||
public string RawContent { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// The IsSuccessStatusCode from the api response
|
||||
@@ -114,9 +120,9 @@ namespace UseSourceGeneration.Client
|
||||
public Uri? RequestUri { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The JsonSerialzierOptions
|
||||
/// The <see cref="System.Text.Json.JsonSerializerOptions"/>
|
||||
/// </summary>
|
||||
private System.Text.Json.JsonSerializerOptions _jsonSerializerOptions;
|
||||
protected System.Text.Json.JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Construct the response using an HttpResponseMessage
|
||||
@@ -142,33 +148,45 @@ namespace UseSourceGeneration.Client
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An interface for responses of type
|
||||
/// </summary>
|
||||
/// <typeparam name="TType"></typeparam>
|
||||
public interface IOk<TType> : IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
TType Ok();
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the server's response
|
||||
/// Returns true if the response is Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
public T? AsModel()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsSuccessStatusCode
|
||||
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, _jsonSerializerOptions)
|
||||
: default(T);
|
||||
}
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
bool TryOk([NotNullWhen(true)]out TType? result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An interface for responses of type
|
||||
/// </summary>
|
||||
/// <typeparam name="TType"></typeparam>
|
||||
public interface IDefault<TType> : IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is Default
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
TType Default();
|
||||
|
||||
/// <summary>
|
||||
/// Returns true when the model can be deserialized
|
||||
/// Returns true if the response is Default and the deserialized response is not null
|
||||
/// </summary>
|
||||
public bool TryToModel([NotNullWhen(true)] out T? model)
|
||||
{
|
||||
try
|
||||
{
|
||||
model = AsModel();
|
||||
return model != null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
model = default(T);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
bool TryDefault([NotNullWhen(true)]out TType? result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ namespace YourProject
|
||||
{
|
||||
var host = CreateHostBuilder(args).Build();
|
||||
var api = host.Services.GetRequiredService<IAnotherFakeApi>();
|
||||
ApiResponse<ModelClient> response = await api.Call123TestSpecialTagsAsync("todo");
|
||||
ModelClient model = response.AsModel();
|
||||
Call123TestSpecialTagsApiResponse apiResponse = await api.Call123TestSpecialTagsAsync("todo");
|
||||
ModelClient model = apiResponse.Ok();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args)
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
ModelClient modelClient = default!;
|
||||
var response = await _instance.Call123TestSpecialTagsAsync(modelClient);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<ModelClient>(model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
public async Task FooGetAsyncTest()
|
||||
{
|
||||
var response = await _instance.FooGetAsync();
|
||||
var model = response.AsModel();
|
||||
var model = response.Default();
|
||||
Assert.IsType<FooGetDefaultResponse>(model);
|
||||
}
|
||||
|
||||
@@ -78,8 +78,30 @@ namespace Org.OpenAPITools.Test.Api
|
||||
public async Task HelloAsyncTest()
|
||||
{
|
||||
var response = await _instance.HelloAsync();
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<List<Guid>>(model);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test RolesReportGet
|
||||
/// </summary>
|
||||
[Fact (Skip = "not implemented")]
|
||||
public async Task RolesReportGetAsyncTest()
|
||||
{
|
||||
var response = await _instance.RolesReportGetAsync();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<List<List<RolesReportsHash>>>(model);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test Test
|
||||
/// </summary>
|
||||
[Fact (Skip = "not implemented")]
|
||||
public async Task TestAsyncTest()
|
||||
{
|
||||
var response = await _instance.TestAsync();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<NotificationtestGetElementsV1ResponseMPayload>(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
public async Task FakeHealthGetAsyncTest()
|
||||
{
|
||||
var response = await _instance.FakeHealthGetAsync();
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<HealthCheckResult>(model);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
Client.Option<bool> body = default!;
|
||||
var response = await _instance.FakeOuterBooleanSerializeAsync(body);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<bool>(model);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
Client.Option<OuterComposite> outerComposite = default!;
|
||||
var response = await _instance.FakeOuterCompositeSerializeAsync(outerComposite);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<OuterComposite>(model);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
Client.Option<decimal> body = default!;
|
||||
var response = await _instance.FakeOuterNumberSerializeAsync(body);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<decimal>(model);
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
Guid requiredStringUuid = default!;
|
||||
Client.Option<string> body = default!;
|
||||
var response = await _instance.FakeOuterStringSerializeAsync(requiredStringUuid, body);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<string>(model);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
public async Task GetArrayOfEnumsAsyncTest()
|
||||
{
|
||||
var response = await _instance.GetArrayOfEnumsAsync();
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<List<OuterEnum>>(model);
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
ModelClient modelClient = default!;
|
||||
var response = await _instance.TestClientModelAsync(modelClient);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<ModelClient>(model);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
ModelClient modelClient = default!;
|
||||
var response = await _instance.TestClassnameAsync(modelClient);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<ModelClient>(model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
List<string> status = default!;
|
||||
var response = await _instance.FindPetsByStatusAsync(status);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<List<Pet>>(model);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
List<string> tags = default!;
|
||||
var response = await _instance.FindPetsByTagsAsync(tags);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<List<Pet>>(model);
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
long petId = default!;
|
||||
var response = await _instance.GetPetByIdAsync(petId);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<Pet>(model);
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
Client.Option<System.IO.Stream> file = default!;
|
||||
Client.Option<string> additionalMetadata = default!;
|
||||
var response = await _instance.UploadFileAsync(petId, file, additionalMetadata);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<ApiResponse>(model);
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
long petId = default!;
|
||||
Client.Option<string> additionalMetadata = default!;
|
||||
var response = await _instance.UploadFileWithRequiredFileAsync(requiredFile, petId, additionalMetadata);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<ApiResponse>(model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
public async Task GetInventoryAsyncTest()
|
||||
{
|
||||
var response = await _instance.GetInventoryAsync();
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<Dictionary<string, int>>(model);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
long orderId = default!;
|
||||
var response = await _instance.GetOrderByIdAsync(orderId);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<Order>(model);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
Order order = default!;
|
||||
var response = await _instance.PlaceOrderAsync(order);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<Order>(model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
string username = default!;
|
||||
var response = await _instance.GetUserByNameAsync(username);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<User>(model);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
string username = default!;
|
||||
string password = default!;
|
||||
var response = await _instance.LoginUserAsync(username, password);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<string>(model);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,15 @@ namespace Org.OpenAPITools.Test.Model
|
||||
//Assert.IsType<Apple>(instance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'ColorCode'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void ColorCodeTest()
|
||||
{
|
||||
// TODO unit test for the property 'ColorCode'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'Cultivar'
|
||||
/// </summary>
|
||||
|
||||
@@ -19,8 +19,8 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json;
|
||||
using Org.OpenAPITools.Client;
|
||||
using Org.OpenAPITools.Api;
|
||||
using Org.OpenAPITools.Model;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Org.OpenAPITools.Api
|
||||
{
|
||||
@@ -44,8 +44,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<ModelClient>></returns>
|
||||
Task<ApiResponse<ModelClient>> Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="ICall123TestSpecialTagsApiResponse"/>></returns>
|
||||
Task<ICall123TestSpecialTagsApiResponse> Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// To test special tags
|
||||
@@ -55,29 +55,40 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>ModelClient>?></returns>
|
||||
Task<ApiResponse<ModelClient>?> Call123TestSpecialTagsOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="ICall123TestSpecialTagsApiResponse"/>?></returns>
|
||||
Task<ICall123TestSpecialTagsApiResponse?> Call123TestSpecialTagsOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ICall123TestSpecialTagsApiResponse"/>
|
||||
/// </summary>
|
||||
public interface ICall123TestSpecialTagsApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Org.OpenAPITools.Model.ModelClient?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// This class is registered as transient.
|
||||
/// </summary>
|
||||
public class AnotherFakeApiEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<ModelClient>>? OnCall123TestSpecialTags;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnCall123TestSpecialTags;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorCall123TestSpecialTags;
|
||||
|
||||
internal void ExecuteOnCall123TestSpecialTags(ApiResponse<ModelClient> apiResponse)
|
||||
internal void ExecuteOnCall123TestSpecialTags(AnotherFakeApi.Call123TestSpecialTagsApiResponse apiResponse)
|
||||
{
|
||||
OnCall123TestSpecialTags?.Invoke(this, new ApiResponseEventArgs<ModelClient>(apiResponse));
|
||||
OnCall123TestSpecialTags?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorCall123TestSpecialTags(Exception exception)
|
||||
@@ -93,6 +104,11 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
private JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The logger factory
|
||||
/// </summary>
|
||||
public ILoggerFactory LoggerFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
@@ -137,7 +153,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// Initializes a new instance of the <see cref="AnotherFakeApi"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public AnotherFakeApi(ILogger<AnotherFakeApi> logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, AnotherFakeApiEvents anotherFakeApiEvents,
|
||||
public AnotherFakeApi(ILogger<AnotherFakeApi> logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, AnotherFakeApiEvents anotherFakeApiEvents,
|
||||
TokenProvider<ApiKeyToken> apiKeyProvider,
|
||||
TokenProvider<BearerToken> bearerTokenProvider,
|
||||
TokenProvider<BasicToken> basicTokenProvider,
|
||||
@@ -145,7 +161,8 @@ namespace Org.OpenAPITools.Api
|
||||
TokenProvider<OAuthToken> oauthTokenProvider)
|
||||
{
|
||||
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
|
||||
Logger = logger;
|
||||
LoggerFactory = loggerFactory;
|
||||
Logger = LoggerFactory.CreateLogger<AnotherFakeApi>();
|
||||
HttpClient = httpClient;
|
||||
Events = anotherFakeApiEvents;
|
||||
ApiKeyProvider = apiKeyProvider;
|
||||
@@ -173,7 +190,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="modelClient"></param>
|
||||
private void AfterCall123TestSpecialTagsDefaultImplementation(ApiResponse<ModelClient> apiResponseLocalVar, ModelClient modelClient)
|
||||
private void AfterCall123TestSpecialTagsDefaultImplementation(ICall123TestSpecialTagsApiResponse apiResponseLocalVar, ModelClient modelClient)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterCall123TestSpecialTags(ref suppressDefaultLog, apiResponseLocalVar, modelClient);
|
||||
@@ -187,7 +204,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="modelClient"></param>
|
||||
partial void AfterCall123TestSpecialTags(ref bool suppressDefaultLog, ApiResponse<ModelClient> apiResponseLocalVar, ModelClient modelClient);
|
||||
partial void AfterCall123TestSpecialTags(ref bool suppressDefaultLog, ICall123TestSpecialTagsApiResponse apiResponseLocalVar, ModelClient modelClient);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -219,8 +236,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="ModelClient"/></returns>
|
||||
public async Task<ApiResponse<ModelClient>?> Call123TestSpecialTagsOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="ICall123TestSpecialTagsApiResponse"/>></returns>
|
||||
public async Task<ICall123TestSpecialTagsApiResponse?> Call123TestSpecialTagsOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -238,8 +255,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="ModelClient"/></returns>
|
||||
public async Task<ApiResponse<ModelClient>> Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="ICall123TestSpecialTagsApiResponse"/>></returns>
|
||||
public async Task<ICall123TestSpecialTagsApiResponse> Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -288,7 +305,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<ModelClient> apiResponseLocalVar = new ApiResponse<ModelClient>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/another-fake/dummy", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<Call123TestSpecialTagsApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<Call123TestSpecialTagsApiResponse>();
|
||||
|
||||
Call123TestSpecialTagsApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/another-fake/dummy", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterCall123TestSpecialTagsDefaultImplementation(apiResponseLocalVar, modelClient);
|
||||
|
||||
@@ -305,5 +324,82 @@ namespace Org.OpenAPITools.Api
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Call123TestSpecialTagsApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class Call123TestSpecialTagsApiResponse : Org.OpenAPITools.Client.ApiResponse, ICall123TestSpecialTagsApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<Call123TestSpecialTagsApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Call123TestSpecialTagsApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public Call123TestSpecialTagsApiResponse(ILogger<Call123TestSpecialTagsApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Org.OpenAPITools.Model.ModelClient? Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.ModelClient>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.ModelClient? result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json;
|
||||
using Org.OpenAPITools.Client;
|
||||
using Org.OpenAPITools.Api;
|
||||
using Org.OpenAPITools.Model;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Org.OpenAPITools.Api
|
||||
{
|
||||
@@ -43,8 +43,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<FooGetDefaultResponse>></returns>
|
||||
Task<ApiResponse<FooGetDefaultResponse>> FooGetAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IFooGetApiResponse"/>></returns>
|
||||
Task<IFooGetApiResponse> FooGetAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -53,8 +53,8 @@ namespace Org.OpenAPITools.Api
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>FooGetDefaultResponse>?></returns>
|
||||
Task<ApiResponse<FooGetDefaultResponse>?> FooGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IFooGetApiResponse"/>?></returns>
|
||||
Task<IFooGetApiResponse?> FooGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -65,8 +65,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="country"></param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<object>></returns>
|
||||
Task<ApiResponse<object>> GetCountryAsync(string country, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IGetCountryApiResponse"/>></returns>
|
||||
Task<IGetCountryApiResponse> GetCountryAsync(string country, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -76,8 +76,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <param name="country"></param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>object>?></returns>
|
||||
Task<ApiResponse<object>?> GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IGetCountryApiResponse"/>?></returns>
|
||||
Task<IGetCountryApiResponse?> GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Hello
|
||||
@@ -87,8 +87,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<List<Guid>>></returns>
|
||||
Task<ApiResponse<List<Guid>>> HelloAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IHelloApiResponse"/>></returns>
|
||||
Task<IHelloApiResponse> HelloAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Hello
|
||||
@@ -97,8 +97,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// Hello
|
||||
/// </remarks>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>List<Guid>>?></returns>
|
||||
Task<ApiResponse<List<Guid>>?> HelloOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IHelloApiResponse"/>?></returns>
|
||||
Task<IHelloApiResponse?> HelloOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -108,8 +108,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<List<List<RolesReportsHash>>>></returns>
|
||||
Task<ApiResponse<List<List<RolesReportsHash>>>> RolesReportGetAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IRolesReportGetApiResponse"/>></returns>
|
||||
Task<IRolesReportGetApiResponse> RolesReportGetAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -118,8 +118,8 @@ namespace Org.OpenAPITools.Api
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>List<List<RolesReportsHash>>>?></returns>
|
||||
Task<ApiResponse<List<List<RolesReportsHash>>>?> RolesReportGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IRolesReportGetApiResponse"/>?></returns>
|
||||
Task<IRolesReportGetApiResponse?> RolesReportGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve an existing Notificationtest's Elements
|
||||
@@ -129,8 +129,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<NotificationtestGetElementsV1ResponseMPayload>></returns>
|
||||
Task<ApiResponse<NotificationtestGetElementsV1ResponseMPayload>> TestAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="ITestApiResponse"/>></returns>
|
||||
Task<ITestApiResponse> TestAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve an existing Notificationtest's Elements
|
||||
@@ -139,29 +139,88 @@ namespace Org.OpenAPITools.Api
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>NotificationtestGetElementsV1ResponseMPayload>?></returns>
|
||||
Task<ApiResponse<NotificationtestGetElementsV1ResponseMPayload>?> TestOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="ITestApiResponse"/>?></returns>
|
||||
Task<ITestApiResponse?> TestOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IFooGetApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IFooGetApiResponse : Org.OpenAPITools.Client.IApiResponse, IDefault<Org.OpenAPITools.Model.FooGetDefaultResponse?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is the default response type
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsDefault { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IGetCountryApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IGetCountryApiResponse : Org.OpenAPITools.Client.IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IHelloApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IHelloApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<List<Guid>?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IRolesReportGetApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IRolesReportGetApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<List<List>?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ITestApiResponse"/>
|
||||
/// </summary>
|
||||
public interface ITestApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// This class is registered as transient.
|
||||
/// </summary>
|
||||
public class DefaultApiEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<FooGetDefaultResponse>>? OnFooGet;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnFooGet;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorFooGet;
|
||||
|
||||
internal void ExecuteOnFooGet(ApiResponse<FooGetDefaultResponse> apiResponse)
|
||||
internal void ExecuteOnFooGet(DefaultApi.FooGetApiResponse apiResponse)
|
||||
{
|
||||
OnFooGet?.Invoke(this, new ApiResponseEventArgs<FooGetDefaultResponse>(apiResponse));
|
||||
OnFooGet?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorFooGet(Exception exception)
|
||||
@@ -172,16 +231,16 @@ namespace Org.OpenAPITools.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<object>>? OnGetCountry;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnGetCountry;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorGetCountry;
|
||||
|
||||
internal void ExecuteOnGetCountry(ApiResponse<object> apiResponse)
|
||||
internal void ExecuteOnGetCountry(DefaultApi.GetCountryApiResponse apiResponse)
|
||||
{
|
||||
OnGetCountry?.Invoke(this, new ApiResponseEventArgs<object>(apiResponse));
|
||||
OnGetCountry?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorGetCountry(Exception exception)
|
||||
@@ -192,16 +251,16 @@ namespace Org.OpenAPITools.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<List<Guid>>>? OnHello;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnHello;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorHello;
|
||||
|
||||
internal void ExecuteOnHello(ApiResponse<List<Guid>> apiResponse)
|
||||
internal void ExecuteOnHello(DefaultApi.HelloApiResponse apiResponse)
|
||||
{
|
||||
OnHello?.Invoke(this, new ApiResponseEventArgs<List<Guid>>(apiResponse));
|
||||
OnHello?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorHello(Exception exception)
|
||||
@@ -212,16 +271,16 @@ namespace Org.OpenAPITools.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<List<List<RolesReportsHash>>>>? OnRolesReportGet;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnRolesReportGet;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorRolesReportGet;
|
||||
|
||||
internal void ExecuteOnRolesReportGet(ApiResponse<List<List<RolesReportsHash>>> apiResponse)
|
||||
internal void ExecuteOnRolesReportGet(DefaultApi.RolesReportGetApiResponse apiResponse)
|
||||
{
|
||||
OnRolesReportGet?.Invoke(this, new ApiResponseEventArgs<List<List<RolesReportsHash>>>(apiResponse));
|
||||
OnRolesReportGet?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorRolesReportGet(Exception exception)
|
||||
@@ -232,16 +291,16 @@ namespace Org.OpenAPITools.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<NotificationtestGetElementsV1ResponseMPayload>>? OnTest;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnTest;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorTest;
|
||||
|
||||
internal void ExecuteOnTest(ApiResponse<NotificationtestGetElementsV1ResponseMPayload> apiResponse)
|
||||
internal void ExecuteOnTest(DefaultApi.TestApiResponse apiResponse)
|
||||
{
|
||||
OnTest?.Invoke(this, new ApiResponseEventArgs<NotificationtestGetElementsV1ResponseMPayload>(apiResponse));
|
||||
OnTest?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorTest(Exception exception)
|
||||
@@ -257,6 +316,11 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
private JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The logger factory
|
||||
/// </summary>
|
||||
public ILoggerFactory LoggerFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
@@ -301,7 +365,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// Initializes a new instance of the <see cref="DefaultApi"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public DefaultApi(ILogger<DefaultApi> logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents,
|
||||
public DefaultApi(ILogger<DefaultApi> logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents,
|
||||
TokenProvider<ApiKeyToken> apiKeyProvider,
|
||||
TokenProvider<BearerToken> bearerTokenProvider,
|
||||
TokenProvider<BasicToken> basicTokenProvider,
|
||||
@@ -309,7 +373,8 @@ namespace Org.OpenAPITools.Api
|
||||
TokenProvider<OAuthToken> oauthTokenProvider)
|
||||
{
|
||||
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
|
||||
Logger = logger;
|
||||
LoggerFactory = loggerFactory;
|
||||
Logger = LoggerFactory.CreateLogger<DefaultApi>();
|
||||
HttpClient = httpClient;
|
||||
Events = defaultApiEvents;
|
||||
ApiKeyProvider = apiKeyProvider;
|
||||
@@ -323,7 +388,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// Processes the server response
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
private void AfterFooGetDefaultImplementation(ApiResponse<FooGetDefaultResponse> apiResponseLocalVar)
|
||||
private void AfterFooGetDefaultImplementation(IFooGetApiResponse apiResponseLocalVar)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterFooGet(ref suppressDefaultLog, apiResponseLocalVar);
|
||||
@@ -336,7 +401,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
partial void AfterFooGet(ref bool suppressDefaultLog, ApiResponse<FooGetDefaultResponse> apiResponseLocalVar);
|
||||
partial void AfterFooGet(ref bool suppressDefaultLog, IFooGetApiResponse apiResponseLocalVar);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -365,8 +430,8 @@ namespace Org.OpenAPITools.Api
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="FooGetDefaultResponse"/></returns>
|
||||
public async Task<ApiResponse<FooGetDefaultResponse>?> FooGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IFooGetApiResponse"/>></returns>
|
||||
public async Task<IFooGetApiResponse?> FooGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -383,8 +448,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="FooGetDefaultResponse"/></returns>
|
||||
public async Task<ApiResponse<FooGetDefaultResponse>> FooGetAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IFooGetApiResponse"/>></returns>
|
||||
public async Task<IFooGetApiResponse> FooGetAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -416,7 +481,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<FooGetDefaultResponse> apiResponseLocalVar = new ApiResponse<FooGetDefaultResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/foo", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<FooGetApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<FooGetApiResponse>();
|
||||
|
||||
FooGetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/foo", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterFooGetDefaultImplementation(apiResponseLocalVar);
|
||||
|
||||
@@ -434,6 +501,83 @@ namespace Org.OpenAPITools.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="FooGetApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class FooGetApiResponse : Org.OpenAPITools.Client.ApiResponse, IFooGetApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<FooGetApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="FooGetApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public FooGetApiResponse(ILogger<FooGetApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is the default response type
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsDefault => true;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 0 Default
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Org.OpenAPITools.Model.FooGetDefaultResponse? Default()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsDefault
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.FooGetDefaultResponse>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 0 Default and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryDefault([NotNullWhen(true)]out Org.OpenAPITools.Model.FooGetDefaultResponse? result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Default();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)0);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
partial void FormatGetCountry(ref string country);
|
||||
|
||||
/// <summary>
|
||||
@@ -452,7 +596,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="country"></param>
|
||||
private void AfterGetCountryDefaultImplementation(ApiResponse<object> apiResponseLocalVar, string country)
|
||||
private void AfterGetCountryDefaultImplementation(IGetCountryApiResponse apiResponseLocalVar, string country)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterGetCountry(ref suppressDefaultLog, apiResponseLocalVar, country);
|
||||
@@ -466,7 +610,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="country"></param>
|
||||
partial void AfterGetCountry(ref bool suppressDefaultLog, ApiResponse<object> apiResponseLocalVar, string country);
|
||||
partial void AfterGetCountry(ref bool suppressDefaultLog, IGetCountryApiResponse apiResponseLocalVar, string country);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -498,8 +642,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="country"></param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="object"/></returns>
|
||||
public async Task<ApiResponse<object>?> GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IGetCountryApiResponse"/>></returns>
|
||||
public async Task<IGetCountryApiResponse?> GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -517,8 +661,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="country"></param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="object"/></returns>
|
||||
public async Task<ApiResponse<object>> GetCountryAsync(string country, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IGetCountryApiResponse"/>></returns>
|
||||
public async Task<IGetCountryApiResponse> GetCountryAsync(string country, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -564,7 +708,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<object> apiResponseLocalVar = new ApiResponse<object>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/country", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<GetCountryApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<GetCountryApiResponse>();
|
||||
|
||||
GetCountryApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/country", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterGetCountryDefaultImplementation(apiResponseLocalVar, country);
|
||||
|
||||
@@ -582,11 +728,56 @@ namespace Org.OpenAPITools.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GetCountryApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class GetCountryApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetCountryApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<GetCountryApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GetCountryApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public GetCountryApiResponse(ILogger<GetCountryApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes the server response
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
private void AfterHelloDefaultImplementation(ApiResponse<List<Guid>> apiResponseLocalVar)
|
||||
private void AfterHelloDefaultImplementation(IHelloApiResponse apiResponseLocalVar)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterHello(ref suppressDefaultLog, apiResponseLocalVar);
|
||||
@@ -599,7 +790,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
partial void AfterHello(ref bool suppressDefaultLog, ApiResponse<List<Guid>> apiResponseLocalVar);
|
||||
partial void AfterHello(ref bool suppressDefaultLog, IHelloApiResponse apiResponseLocalVar);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -628,8 +819,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// Hello Hello
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="List{TValue}"/></returns>
|
||||
public async Task<ApiResponse<List<Guid>>?> HelloOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IHelloApiResponse"/>></returns>
|
||||
public async Task<IHelloApiResponse?> HelloOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -646,8 +837,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="List{TValue}"/></returns>
|
||||
public async Task<ApiResponse<List<Guid>>> HelloAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IHelloApiResponse"/>></returns>
|
||||
public async Task<IHelloApiResponse> HelloAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -679,7 +870,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<List<Guid>> apiResponseLocalVar = new ApiResponse<List<Guid>>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/hello", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<HelloApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<HelloApiResponse>();
|
||||
|
||||
HelloApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/hello", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterHelloDefaultImplementation(apiResponseLocalVar);
|
||||
|
||||
@@ -697,11 +890,88 @@ namespace Org.OpenAPITools.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="HelloApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class HelloApiResponse : Org.OpenAPITools.Client.ApiResponse, IHelloApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<HelloApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="HelloApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public HelloApiResponse(ILogger<HelloApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<Guid>? Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<List<Guid>>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out List<Guid>? result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes the server response
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
private void AfterRolesReportGetDefaultImplementation(ApiResponse<List<List<RolesReportsHash>>> apiResponseLocalVar)
|
||||
private void AfterRolesReportGetDefaultImplementation(IRolesReportGetApiResponse apiResponseLocalVar)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterRolesReportGet(ref suppressDefaultLog, apiResponseLocalVar);
|
||||
@@ -714,7 +984,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
partial void AfterRolesReportGet(ref bool suppressDefaultLog, ApiResponse<List<List<RolesReportsHash>>> apiResponseLocalVar);
|
||||
partial void AfterRolesReportGet(ref bool suppressDefaultLog, IRolesReportGetApiResponse apiResponseLocalVar);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -743,8 +1013,8 @@ namespace Org.OpenAPITools.Api
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="List{TValue}"/></returns>
|
||||
public async Task<ApiResponse<List<List<RolesReportsHash>>>?> RolesReportGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IRolesReportGetApiResponse"/>></returns>
|
||||
public async Task<IRolesReportGetApiResponse?> RolesReportGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -761,8 +1031,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="List{TValue}"/></returns>
|
||||
public async Task<ApiResponse<List<List<RolesReportsHash>>>> RolesReportGetAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IRolesReportGetApiResponse"/>></returns>
|
||||
public async Task<IRolesReportGetApiResponse> RolesReportGetAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -794,7 +1064,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<List<List<RolesReportsHash>>> apiResponseLocalVar = new ApiResponse<List<List<RolesReportsHash>>>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/roles/report", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<RolesReportGetApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<RolesReportGetApiResponse>();
|
||||
|
||||
RolesReportGetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/roles/report", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterRolesReportGetDefaultImplementation(apiResponseLocalVar);
|
||||
|
||||
@@ -812,11 +1084,88 @@ namespace Org.OpenAPITools.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="RolesReportGetApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class RolesReportGetApiResponse : Org.OpenAPITools.Client.ApiResponse, IRolesReportGetApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<RolesReportGetApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="RolesReportGetApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public RolesReportGetApiResponse(ILogger<RolesReportGetApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<List>? Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<List<List>>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out List<List>? result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes the server response
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
private void AfterTestDefaultImplementation(ApiResponse<NotificationtestGetElementsV1ResponseMPayload> apiResponseLocalVar)
|
||||
private void AfterTestDefaultImplementation(ITestApiResponse apiResponseLocalVar)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterTest(ref suppressDefaultLog, apiResponseLocalVar);
|
||||
@@ -829,7 +1178,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
partial void AfterTest(ref bool suppressDefaultLog, ApiResponse<NotificationtestGetElementsV1ResponseMPayload> apiResponseLocalVar);
|
||||
partial void AfterTest(ref bool suppressDefaultLog, ITestApiResponse apiResponseLocalVar);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -858,8 +1207,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// Retrieve an existing Notificationtest's Elements
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="NotificationtestGetElementsV1ResponseMPayload"/></returns>
|
||||
public async Task<ApiResponse<NotificationtestGetElementsV1ResponseMPayload>?> TestOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="ITestApiResponse"/>></returns>
|
||||
public async Task<ITestApiResponse?> TestOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -876,8 +1225,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="NotificationtestGetElementsV1ResponseMPayload"/></returns>
|
||||
public async Task<ApiResponse<NotificationtestGetElementsV1ResponseMPayload>> TestAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="ITestApiResponse"/>></returns>
|
||||
public async Task<ITestApiResponse> TestAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -909,7 +1258,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<NotificationtestGetElementsV1ResponseMPayload> apiResponseLocalVar = new ApiResponse<NotificationtestGetElementsV1ResponseMPayload>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/test", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<TestApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<TestApiResponse>();
|
||||
|
||||
TestApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/test", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterTestDefaultImplementation(apiResponseLocalVar);
|
||||
|
||||
@@ -926,5 +1277,82 @@ namespace Org.OpenAPITools.Api
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="TestApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class TestApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<TestApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="TestApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public TestApiResponse(ILogger<TestApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload? Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload? result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,8 +19,8 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json;
|
||||
using Org.OpenAPITools.Client;
|
||||
using Org.OpenAPITools.Api;
|
||||
using Org.OpenAPITools.Model;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Org.OpenAPITools.Api
|
||||
{
|
||||
@@ -44,8 +44,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<ModelClient>></returns>
|
||||
Task<ApiResponse<ModelClient>> TestClassnameAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="ITestClassnameApiResponse"/>></returns>
|
||||
Task<ITestClassnameApiResponse> TestClassnameAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// To test class name in snake case
|
||||
@@ -55,29 +55,40 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>ModelClient>?></returns>
|
||||
Task<ApiResponse<ModelClient>?> TestClassnameOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="ITestClassnameApiResponse"/>?></returns>
|
||||
Task<ITestClassnameApiResponse?> TestClassnameOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ITestClassnameApiResponse"/>
|
||||
/// </summary>
|
||||
public interface ITestClassnameApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Org.OpenAPITools.Model.ModelClient?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// This class is registered as transient.
|
||||
/// </summary>
|
||||
public class FakeClassnameTags123ApiEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<ModelClient>>? OnTestClassname;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnTestClassname;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorTestClassname;
|
||||
|
||||
internal void ExecuteOnTestClassname(ApiResponse<ModelClient> apiResponse)
|
||||
internal void ExecuteOnTestClassname(FakeClassnameTags123Api.TestClassnameApiResponse apiResponse)
|
||||
{
|
||||
OnTestClassname?.Invoke(this, new ApiResponseEventArgs<ModelClient>(apiResponse));
|
||||
OnTestClassname?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorTestClassname(Exception exception)
|
||||
@@ -93,6 +104,11 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
private JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The logger factory
|
||||
/// </summary>
|
||||
public ILoggerFactory LoggerFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
@@ -137,7 +153,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// Initializes a new instance of the <see cref="FakeClassnameTags123Api"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public FakeClassnameTags123Api(ILogger<FakeClassnameTags123Api> logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, FakeClassnameTags123ApiEvents fakeClassnameTags123ApiEvents,
|
||||
public FakeClassnameTags123Api(ILogger<FakeClassnameTags123Api> logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, FakeClassnameTags123ApiEvents fakeClassnameTags123ApiEvents,
|
||||
TokenProvider<ApiKeyToken> apiKeyProvider,
|
||||
TokenProvider<BearerToken> bearerTokenProvider,
|
||||
TokenProvider<BasicToken> basicTokenProvider,
|
||||
@@ -145,7 +161,8 @@ namespace Org.OpenAPITools.Api
|
||||
TokenProvider<OAuthToken> oauthTokenProvider)
|
||||
{
|
||||
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
|
||||
Logger = logger;
|
||||
LoggerFactory = loggerFactory;
|
||||
Logger = LoggerFactory.CreateLogger<FakeClassnameTags123Api>();
|
||||
HttpClient = httpClient;
|
||||
Events = fakeClassnameTags123ApiEvents;
|
||||
ApiKeyProvider = apiKeyProvider;
|
||||
@@ -173,7 +190,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="modelClient"></param>
|
||||
private void AfterTestClassnameDefaultImplementation(ApiResponse<ModelClient> apiResponseLocalVar, ModelClient modelClient)
|
||||
private void AfterTestClassnameDefaultImplementation(ITestClassnameApiResponse apiResponseLocalVar, ModelClient modelClient)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterTestClassname(ref suppressDefaultLog, apiResponseLocalVar, modelClient);
|
||||
@@ -187,7 +204,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="modelClient"></param>
|
||||
partial void AfterTestClassname(ref bool suppressDefaultLog, ApiResponse<ModelClient> apiResponseLocalVar, ModelClient modelClient);
|
||||
partial void AfterTestClassname(ref bool suppressDefaultLog, ITestClassnameApiResponse apiResponseLocalVar, ModelClient modelClient);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -219,8 +236,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="ModelClient"/></returns>
|
||||
public async Task<ApiResponse<ModelClient>?> TestClassnameOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="ITestClassnameApiResponse"/>></returns>
|
||||
public async Task<ITestClassnameApiResponse?> TestClassnameOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -238,8 +255,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="ModelClient"/></returns>
|
||||
public async Task<ApiResponse<ModelClient>> TestClassnameAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="ITestClassnameApiResponse"/>></returns>
|
||||
public async Task<ITestClassnameApiResponse> TestClassnameAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -299,7 +316,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<ModelClient> apiResponseLocalVar = new ApiResponse<ModelClient>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake_classname_test", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<TestClassnameApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<TestClassnameApiResponse>();
|
||||
|
||||
TestClassnameApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake_classname_test", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterTestClassnameDefaultImplementation(apiResponseLocalVar, modelClient);
|
||||
|
||||
@@ -320,5 +339,82 @@ namespace Org.OpenAPITools.Api
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="TestClassnameApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class TestClassnameApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestClassnameApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<TestClassnameApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="TestClassnameApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public TestClassnameApiResponse(ILogger<TestClassnameApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Org.OpenAPITools.Model.ModelClient? Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.ModelClient>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.ModelClient? result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,8 +19,8 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json;
|
||||
using Org.OpenAPITools.Client;
|
||||
using Org.OpenAPITools.Api;
|
||||
using Org.OpenAPITools.Model;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Org.OpenAPITools.Api
|
||||
{
|
||||
@@ -44,8 +44,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<object>></returns>
|
||||
Task<ApiResponse<object>> DeleteOrderAsync(string orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IDeleteOrderApiResponse"/>></returns>
|
||||
Task<IDeleteOrderApiResponse> DeleteOrderAsync(string orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Delete purchase order by ID
|
||||
@@ -55,8 +55,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>object>?></returns>
|
||||
Task<ApiResponse<object>?> DeleteOrderOrDefaultAsync(string orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IDeleteOrderApiResponse"/>?></returns>
|
||||
Task<IDeleteOrderApiResponse?> DeleteOrderOrDefaultAsync(string orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Returns pet inventories by status
|
||||
@@ -66,8 +66,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<Dictionary<string, int>>></returns>
|
||||
Task<ApiResponse<Dictionary<string, int>>> GetInventoryAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IGetInventoryApiResponse"/>></returns>
|
||||
Task<IGetInventoryApiResponse> GetInventoryAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Returns pet inventories by status
|
||||
@@ -76,8 +76,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// Returns a map of status codes to quantities
|
||||
/// </remarks>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>Dictionary<string, int>>?></returns>
|
||||
Task<ApiResponse<Dictionary<string, int>>?> GetInventoryOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IGetInventoryApiResponse"/>?></returns>
|
||||
Task<IGetInventoryApiResponse?> GetInventoryOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Find purchase order by ID
|
||||
@@ -88,8 +88,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<Order>></returns>
|
||||
Task<ApiResponse<Order>> GetOrderByIdAsync(long orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IGetOrderByIdApiResponse"/>></returns>
|
||||
Task<IGetOrderByIdApiResponse> GetOrderByIdAsync(long orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Find purchase order by ID
|
||||
@@ -99,8 +99,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>Order>?></returns>
|
||||
Task<ApiResponse<Order>?> GetOrderByIdOrDefaultAsync(long orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IGetOrderByIdApiResponse"/>?></returns>
|
||||
Task<IGetOrderByIdApiResponse?> GetOrderByIdOrDefaultAsync(long orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Place an order for a pet
|
||||
@@ -111,8 +111,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="order">order placed for purchasing the pet</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<Order>></returns>
|
||||
Task<ApiResponse<Order>> PlaceOrderAsync(Order order, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IPlaceOrderApiResponse"/>></returns>
|
||||
Task<IPlaceOrderApiResponse> PlaceOrderAsync(Order order, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Place an order for a pet
|
||||
@@ -122,29 +122,100 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <param name="order">order placed for purchasing the pet</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>Order>?></returns>
|
||||
Task<ApiResponse<Order>?> PlaceOrderOrDefaultAsync(Order order, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IPlaceOrderApiResponse"/>?></returns>
|
||||
Task<IPlaceOrderApiResponse?> PlaceOrderOrDefaultAsync(Order order, System.Threading.CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IDeleteOrderApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IDeleteOrderApiResponse : Org.OpenAPITools.Client.IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 400 BadRequest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsBadRequest { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 404 NotFound
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsNotFound { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IGetInventoryApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IGetInventoryApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Dictionary<string, int>?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IGetOrderByIdApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IGetOrderByIdApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Org.OpenAPITools.Model.Order?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 400 BadRequest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsBadRequest { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 404 NotFound
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsNotFound { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IPlaceOrderApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IPlaceOrderApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Org.OpenAPITools.Model.Order?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 400 BadRequest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsBadRequest { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// This class is registered as transient.
|
||||
/// </summary>
|
||||
public class StoreApiEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<object>>? OnDeleteOrder;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnDeleteOrder;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorDeleteOrder;
|
||||
|
||||
internal void ExecuteOnDeleteOrder(ApiResponse<object> apiResponse)
|
||||
internal void ExecuteOnDeleteOrder(StoreApi.DeleteOrderApiResponse apiResponse)
|
||||
{
|
||||
OnDeleteOrder?.Invoke(this, new ApiResponseEventArgs<object>(apiResponse));
|
||||
OnDeleteOrder?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorDeleteOrder(Exception exception)
|
||||
@@ -155,16 +226,16 @@ namespace Org.OpenAPITools.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<Dictionary<string, int>>>? OnGetInventory;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnGetInventory;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorGetInventory;
|
||||
|
||||
internal void ExecuteOnGetInventory(ApiResponse<Dictionary<string, int>> apiResponse)
|
||||
internal void ExecuteOnGetInventory(StoreApi.GetInventoryApiResponse apiResponse)
|
||||
{
|
||||
OnGetInventory?.Invoke(this, new ApiResponseEventArgs<Dictionary<string, int>>(apiResponse));
|
||||
OnGetInventory?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorGetInventory(Exception exception)
|
||||
@@ -175,16 +246,16 @@ namespace Org.OpenAPITools.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<Order>>? OnGetOrderById;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnGetOrderById;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorGetOrderById;
|
||||
|
||||
internal void ExecuteOnGetOrderById(ApiResponse<Order> apiResponse)
|
||||
internal void ExecuteOnGetOrderById(StoreApi.GetOrderByIdApiResponse apiResponse)
|
||||
{
|
||||
OnGetOrderById?.Invoke(this, new ApiResponseEventArgs<Order>(apiResponse));
|
||||
OnGetOrderById?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorGetOrderById(Exception exception)
|
||||
@@ -195,16 +266,16 @@ namespace Org.OpenAPITools.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<Order>>? OnPlaceOrder;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnPlaceOrder;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorPlaceOrder;
|
||||
|
||||
internal void ExecuteOnPlaceOrder(ApiResponse<Order> apiResponse)
|
||||
internal void ExecuteOnPlaceOrder(StoreApi.PlaceOrderApiResponse apiResponse)
|
||||
{
|
||||
OnPlaceOrder?.Invoke(this, new ApiResponseEventArgs<Order>(apiResponse));
|
||||
OnPlaceOrder?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorPlaceOrder(Exception exception)
|
||||
@@ -220,6 +291,11 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
private JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The logger factory
|
||||
/// </summary>
|
||||
public ILoggerFactory LoggerFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
@@ -264,7 +340,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// Initializes a new instance of the <see cref="StoreApi"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public StoreApi(ILogger<StoreApi> logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, StoreApiEvents storeApiEvents,
|
||||
public StoreApi(ILogger<StoreApi> logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, StoreApiEvents storeApiEvents,
|
||||
TokenProvider<ApiKeyToken> apiKeyProvider,
|
||||
TokenProvider<BearerToken> bearerTokenProvider,
|
||||
TokenProvider<BasicToken> basicTokenProvider,
|
||||
@@ -272,7 +348,8 @@ namespace Org.OpenAPITools.Api
|
||||
TokenProvider<OAuthToken> oauthTokenProvider)
|
||||
{
|
||||
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
|
||||
Logger = logger;
|
||||
LoggerFactory = loggerFactory;
|
||||
Logger = LoggerFactory.CreateLogger<StoreApi>();
|
||||
HttpClient = httpClient;
|
||||
Events = storeApiEvents;
|
||||
ApiKeyProvider = apiKeyProvider;
|
||||
@@ -300,7 +377,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="orderId"></param>
|
||||
private void AfterDeleteOrderDefaultImplementation(ApiResponse<object> apiResponseLocalVar, string orderId)
|
||||
private void AfterDeleteOrderDefaultImplementation(IDeleteOrderApiResponse apiResponseLocalVar, string orderId)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterDeleteOrder(ref suppressDefaultLog, apiResponseLocalVar, orderId);
|
||||
@@ -314,7 +391,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="orderId"></param>
|
||||
partial void AfterDeleteOrder(ref bool suppressDefaultLog, ApiResponse<object> apiResponseLocalVar, string orderId);
|
||||
partial void AfterDeleteOrder(ref bool suppressDefaultLog, IDeleteOrderApiResponse apiResponseLocalVar, string orderId);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -346,8 +423,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="object"/></returns>
|
||||
public async Task<ApiResponse<object>?> DeleteOrderOrDefaultAsync(string orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IDeleteOrderApiResponse"/>></returns>
|
||||
public async Task<IDeleteOrderApiResponse?> DeleteOrderOrDefaultAsync(string orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -365,8 +442,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="object"/></returns>
|
||||
public async Task<ApiResponse<object>> DeleteOrderAsync(string orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IDeleteOrderApiResponse"/>></returns>
|
||||
public async Task<IDeleteOrderApiResponse> DeleteOrderAsync(string orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -394,7 +471,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<object> apiResponseLocalVar = new ApiResponse<object>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<DeleteOrderApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<DeleteOrderApiResponse>();
|
||||
|
||||
DeleteOrderApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterDeleteOrderDefaultImplementation(apiResponseLocalVar, orderId);
|
||||
|
||||
@@ -412,11 +491,62 @@ namespace Org.OpenAPITools.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DeleteOrderApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class DeleteOrderApiResponse : Org.OpenAPITools.Client.ApiResponse, IDeleteOrderApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<DeleteOrderApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DeleteOrderApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public DeleteOrderApiResponse(ILogger<DeleteOrderApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 400 BadRequest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsBadRequest => 400 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 404 NotFound
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsNotFound => 404 == (int)StatusCode;
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes the server response
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
private void AfterGetInventoryDefaultImplementation(ApiResponse<Dictionary<string, int>> apiResponseLocalVar)
|
||||
private void AfterGetInventoryDefaultImplementation(IGetInventoryApiResponse apiResponseLocalVar)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterGetInventory(ref suppressDefaultLog, apiResponseLocalVar);
|
||||
@@ -429,7 +559,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
partial void AfterGetInventory(ref bool suppressDefaultLog, ApiResponse<Dictionary<string, int>> apiResponseLocalVar);
|
||||
partial void AfterGetInventory(ref bool suppressDefaultLog, IGetInventoryApiResponse apiResponseLocalVar);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -458,8 +588,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// Returns pet inventories by status Returns a map of status codes to quantities
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Dictionary{TKey, TValue}"/></returns>
|
||||
public async Task<ApiResponse<Dictionary<string, int>>?> GetInventoryOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IGetInventoryApiResponse"/>></returns>
|
||||
public async Task<IGetInventoryApiResponse?> GetInventoryOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -476,8 +606,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Dictionary{TKey, TValue}"/></returns>
|
||||
public async Task<ApiResponse<Dictionary<string, int>>> GetInventoryAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IGetInventoryApiResponse"/>></returns>
|
||||
public async Task<IGetInventoryApiResponse> GetInventoryAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -517,7 +647,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<Dictionary<string, int>> apiResponseLocalVar = new ApiResponse<Dictionary<string, int>>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/inventory", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<GetInventoryApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<GetInventoryApiResponse>();
|
||||
|
||||
GetInventoryApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/inventory", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterGetInventoryDefaultImplementation(apiResponseLocalVar);
|
||||
|
||||
@@ -539,6 +671,83 @@ namespace Org.OpenAPITools.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GetInventoryApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class GetInventoryApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetInventoryApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<GetInventoryApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GetInventoryApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public GetInventoryApiResponse(ILogger<GetInventoryApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Dictionary<string, int>? Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Dictionary<string, int>>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out Dictionary<string, int>? result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
partial void FormatGetOrderById(ref long orderId);
|
||||
|
||||
/// <summary>
|
||||
@@ -546,7 +755,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="orderId"></param>
|
||||
private void AfterGetOrderByIdDefaultImplementation(ApiResponse<Order> apiResponseLocalVar, long orderId)
|
||||
private void AfterGetOrderByIdDefaultImplementation(IGetOrderByIdApiResponse apiResponseLocalVar, long orderId)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterGetOrderById(ref suppressDefaultLog, apiResponseLocalVar, orderId);
|
||||
@@ -560,7 +769,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="orderId"></param>
|
||||
partial void AfterGetOrderById(ref bool suppressDefaultLog, ApiResponse<Order> apiResponseLocalVar, long orderId);
|
||||
partial void AfterGetOrderById(ref bool suppressDefaultLog, IGetOrderByIdApiResponse apiResponseLocalVar, long orderId);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -592,8 +801,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Order"/></returns>
|
||||
public async Task<ApiResponse<Order>?> GetOrderByIdOrDefaultAsync(long orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IGetOrderByIdApiResponse"/>></returns>
|
||||
public async Task<IGetOrderByIdApiResponse?> GetOrderByIdOrDefaultAsync(long orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -611,8 +820,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Order"/></returns>
|
||||
public async Task<ApiResponse<Order>> GetOrderByIdAsync(long orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IGetOrderByIdApiResponse"/>></returns>
|
||||
public async Task<IGetOrderByIdApiResponse> GetOrderByIdAsync(long orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -648,7 +857,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<Order> apiResponseLocalVar = new ApiResponse<Order>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<GetOrderByIdApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<GetOrderByIdApiResponse>();
|
||||
|
||||
GetOrderByIdApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterGetOrderByIdDefaultImplementation(apiResponseLocalVar, orderId);
|
||||
|
||||
@@ -666,6 +877,95 @@ namespace Org.OpenAPITools.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GetOrderByIdApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class GetOrderByIdApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetOrderByIdApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<GetOrderByIdApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GetOrderByIdApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public GetOrderByIdApiResponse(ILogger<GetOrderByIdApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Org.OpenAPITools.Model.Order? Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.Order>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.Order? result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 400 BadRequest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsBadRequest => 400 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 404 NotFound
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsNotFound => 404 == (int)StatusCode;
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
partial void FormatPlaceOrder(Order order);
|
||||
|
||||
/// <summary>
|
||||
@@ -684,7 +984,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="order"></param>
|
||||
private void AfterPlaceOrderDefaultImplementation(ApiResponse<Order> apiResponseLocalVar, Order order)
|
||||
private void AfterPlaceOrderDefaultImplementation(IPlaceOrderApiResponse apiResponseLocalVar, Order order)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterPlaceOrder(ref suppressDefaultLog, apiResponseLocalVar, order);
|
||||
@@ -698,7 +998,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="order"></param>
|
||||
partial void AfterPlaceOrder(ref bool suppressDefaultLog, ApiResponse<Order> apiResponseLocalVar, Order order);
|
||||
partial void AfterPlaceOrder(ref bool suppressDefaultLog, IPlaceOrderApiResponse apiResponseLocalVar, Order order);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -730,8 +1030,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="order">order placed for purchasing the pet</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Order"/></returns>
|
||||
public async Task<ApiResponse<Order>?> PlaceOrderOrDefaultAsync(Order order, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IPlaceOrderApiResponse"/>></returns>
|
||||
public async Task<IPlaceOrderApiResponse?> PlaceOrderOrDefaultAsync(Order order, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -749,8 +1049,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="order">order placed for purchasing the pet</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Order"/></returns>
|
||||
public async Task<ApiResponse<Order>> PlaceOrderAsync(Order order, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IPlaceOrderApiResponse"/>></returns>
|
||||
public async Task<IPlaceOrderApiResponse> PlaceOrderAsync(Order order, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -800,7 +1100,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<Order> apiResponseLocalVar = new ApiResponse<Order>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<PlaceOrderApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<PlaceOrderApiResponse>();
|
||||
|
||||
PlaceOrderApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterPlaceOrderDefaultImplementation(apiResponseLocalVar, order);
|
||||
|
||||
@@ -817,5 +1119,88 @@ namespace Org.OpenAPITools.Api
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="PlaceOrderApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class PlaceOrderApiResponse : Org.OpenAPITools.Client.ApiResponse, IPlaceOrderApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<PlaceOrderApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="PlaceOrderApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public PlaceOrderApiResponse(ILogger<PlaceOrderApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Org.OpenAPITools.Model.Order? Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.Order>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.Order? result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 400 BadRequest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsBadRequest => 400 == (int)StatusCode;
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,18 +5,18 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// Useful for tracking server health
|
||||
/// </summary>
|
||||
public class ApiResponseEventArgs<T> : EventArgs
|
||||
public class ApiResponseEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// The ApiResponse
|
||||
/// </summary>
|
||||
public ApiResponse<T> ApiResponse { get; }
|
||||
public ApiResponse ApiResponse { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The ApiResponseEventArgs
|
||||
/// </summary>
|
||||
/// <param name="apiResponse"></param>
|
||||
public ApiResponseEventArgs(ApiResponse<T> apiResponse)
|
||||
public ApiResponseEventArgs(ApiResponse apiResponse)
|
||||
{
|
||||
ApiResponse = apiResponse;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
|
||||
@@ -20,15 +19,15 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// Provides a non-generic contract for the ApiResponse wrapper.
|
||||
/// </summary>
|
||||
public interface IApiResponse
|
||||
public partial interface IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The type that represents the server's response.
|
||||
/// The IsSuccessStatusCode from the api response
|
||||
/// </summary>
|
||||
Type ResponseType { get; }
|
||||
bool IsSuccessStatusCode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the status code (HTTP status code)
|
||||
/// Gets the status code (HTTP status code)
|
||||
/// </summary>
|
||||
/// <value>The status code.</value>
|
||||
HttpStatusCode StatusCode { get; }
|
||||
@@ -43,11 +42,26 @@ namespace Org.OpenAPITools.Client
|
||||
/// </summary>
|
||||
DateTime DownloadedAt { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The headers contained in the api response
|
||||
/// </summary>
|
||||
System.Net.Http.Headers.HttpResponseHeaders Headers { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The path used when making the request.
|
||||
/// </summary>
|
||||
string Path { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The reason phrase contained in the api response
|
||||
/// </summary>
|
||||
string? ReasonPhrase { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The DateTime when the request was sent.
|
||||
/// </summary>
|
||||
DateTime RequestedAt { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The Uri used when making the request.
|
||||
/// </summary>
|
||||
@@ -57,26 +71,18 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// API Response
|
||||
/// </summary>
|
||||
public partial class ApiResponse<T> : IApiResponse
|
||||
public partial class ApiResponse : IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the status code (HTTP status code)
|
||||
/// Gets the status code (HTTP status code)
|
||||
/// </summary>
|
||||
/// <value>The status code.</value>
|
||||
public HttpStatusCode StatusCode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The type that represents the server's response.
|
||||
/// </summary>
|
||||
public Type ResponseType
|
||||
{
|
||||
get { return typeof(T); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The raw data
|
||||
/// </summary>
|
||||
public string RawContent { get; private set; }
|
||||
public string RawContent { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// The IsSuccessStatusCode from the api response
|
||||
@@ -114,9 +120,9 @@ namespace Org.OpenAPITools.Client
|
||||
public Uri? RequestUri { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The JsonSerialzierOptions
|
||||
/// The <see cref="System.Text.Json.JsonSerializerOptions"/>
|
||||
/// </summary>
|
||||
private System.Text.Json.JsonSerializerOptions _jsonSerializerOptions;
|
||||
protected System.Text.Json.JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Construct the response using an HttpResponseMessage
|
||||
@@ -142,33 +148,45 @@ namespace Org.OpenAPITools.Client
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An interface for responses of type
|
||||
/// </summary>
|
||||
/// <typeparam name="TType"></typeparam>
|
||||
public interface IOk<TType> : IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
TType Ok();
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the server's response
|
||||
/// Returns true if the response is Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
public T? AsModel()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsSuccessStatusCode
|
||||
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, _jsonSerializerOptions)
|
||||
: default(T);
|
||||
}
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
bool TryOk([NotNullWhen(true)]out TType? result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An interface for responses of type
|
||||
/// </summary>
|
||||
/// <typeparam name="TType"></typeparam>
|
||||
public interface IDefault<TType> : IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is Default
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
TType Default();
|
||||
|
||||
/// <summary>
|
||||
/// Returns true when the model can be deserialized
|
||||
/// Returns true if the response is Default and the deserialized response is not null
|
||||
/// </summary>
|
||||
public bool TryToModel([NotNullWhen(true)] out T? model)
|
||||
{
|
||||
try
|
||||
{
|
||||
model = AsModel();
|
||||
return model != null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
model = default(T);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
bool TryDefault([NotNullWhen(true)]out TType? result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ namespace YourProject
|
||||
{
|
||||
var host = CreateHostBuilder(args).Build();
|
||||
var api = host.Services.GetRequiredService<IAnotherFakeApi>();
|
||||
ApiResponse<ModelClient> response = await api.Call123TestSpecialTagsAsync("todo");
|
||||
ModelClient model = response.AsModel();
|
||||
Call123TestSpecialTagsApiResponse apiResponse = await api.Call123TestSpecialTagsAsync("todo");
|
||||
ModelClient model = apiResponse.Ok();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args)
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
ModelClient modelClient = default;
|
||||
var response = await _instance.Call123TestSpecialTagsAsync(modelClient);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<ModelClient>(model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
public async Task FooGetAsyncTest()
|
||||
{
|
||||
var response = await _instance.FooGetAsync();
|
||||
var model = response.AsModel();
|
||||
var model = response.Default();
|
||||
Assert.IsType<FooGetDefaultResponse>(model);
|
||||
}
|
||||
|
||||
@@ -78,8 +78,30 @@ namespace Org.OpenAPITools.Test.Api
|
||||
public async Task HelloAsyncTest()
|
||||
{
|
||||
var response = await _instance.HelloAsync();
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<List<Guid>>(model);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test RolesReportGet
|
||||
/// </summary>
|
||||
[Fact (Skip = "not implemented")]
|
||||
public async Task RolesReportGetAsyncTest()
|
||||
{
|
||||
var response = await _instance.RolesReportGetAsync();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<List<List<RolesReportsHash>>>(model);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test Test
|
||||
/// </summary>
|
||||
[Fact (Skip = "not implemented")]
|
||||
public async Task TestAsyncTest()
|
||||
{
|
||||
var response = await _instance.TestAsync();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<NotificationtestGetElementsV1ResponseMPayload>(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
public async Task FakeHealthGetAsyncTest()
|
||||
{
|
||||
var response = await _instance.FakeHealthGetAsync();
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<HealthCheckResult>(model);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
Client.Option<bool> body = default;
|
||||
var response = await _instance.FakeOuterBooleanSerializeAsync(body);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<bool>(model);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
Client.Option<OuterComposite> outerComposite = default;
|
||||
var response = await _instance.FakeOuterCompositeSerializeAsync(outerComposite);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<OuterComposite>(model);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
Client.Option<decimal> body = default;
|
||||
var response = await _instance.FakeOuterNumberSerializeAsync(body);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<decimal>(model);
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
Guid requiredStringUuid = default;
|
||||
Client.Option<string> body = default;
|
||||
var response = await _instance.FakeOuterStringSerializeAsync(requiredStringUuid, body);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<string>(model);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
public async Task GetArrayOfEnumsAsyncTest()
|
||||
{
|
||||
var response = await _instance.GetArrayOfEnumsAsync();
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<List<OuterEnum>>(model);
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
ModelClient modelClient = default;
|
||||
var response = await _instance.TestClientModelAsync(modelClient);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<ModelClient>(model);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
ModelClient modelClient = default;
|
||||
var response = await _instance.TestClassnameAsync(modelClient);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<ModelClient>(model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
List<string> status = default;
|
||||
var response = await _instance.FindPetsByStatusAsync(status);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<List<Pet>>(model);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
List<string> tags = default;
|
||||
var response = await _instance.FindPetsByTagsAsync(tags);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<List<Pet>>(model);
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
long petId = default;
|
||||
var response = await _instance.GetPetByIdAsync(petId);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<Pet>(model);
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
Client.Option<System.IO.Stream> file = default;
|
||||
Client.Option<string> additionalMetadata = default;
|
||||
var response = await _instance.UploadFileAsync(petId, file, additionalMetadata);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<ApiResponse>(model);
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
long petId = default;
|
||||
Client.Option<string> additionalMetadata = default;
|
||||
var response = await _instance.UploadFileWithRequiredFileAsync(requiredFile, petId, additionalMetadata);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<ApiResponse>(model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
public async Task GetInventoryAsyncTest()
|
||||
{
|
||||
var response = await _instance.GetInventoryAsync();
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<Dictionary<string, int>>(model);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
long orderId = default;
|
||||
var response = await _instance.GetOrderByIdAsync(orderId);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<Order>(model);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
Order order = default;
|
||||
var response = await _instance.PlaceOrderAsync(order);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<Order>(model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
string username = default;
|
||||
var response = await _instance.GetUserByNameAsync(username);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<User>(model);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
string username = default;
|
||||
string password = default;
|
||||
var response = await _instance.LoginUserAsync(username, password);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<string>(model);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,15 @@ namespace Org.OpenAPITools.Test.Model
|
||||
//Assert.IsType<Apple>(instance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'ColorCode'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void ColorCodeTest()
|
||||
{
|
||||
// TODO unit test for the property 'ColorCode'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'Cultivar'
|
||||
/// </summary>
|
||||
|
||||
@@ -17,8 +17,8 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json;
|
||||
using Org.OpenAPITools.Client;
|
||||
using Org.OpenAPITools.Api;
|
||||
using Org.OpenAPITools.Model;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Org.OpenAPITools.Api
|
||||
{
|
||||
@@ -42,8 +42,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<ModelClient>></returns>
|
||||
Task<ApiResponse<ModelClient>> Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="ICall123TestSpecialTagsApiResponse"/>></returns>
|
||||
Task<ICall123TestSpecialTagsApiResponse> Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// To test special tags
|
||||
@@ -53,29 +53,40 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>ModelClient>></returns>
|
||||
Task<ApiResponse<ModelClient>> Call123TestSpecialTagsOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="ICall123TestSpecialTagsApiResponse"/>></returns>
|
||||
Task<ICall123TestSpecialTagsApiResponse> Call123TestSpecialTagsOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ICall123TestSpecialTagsApiResponse"/>
|
||||
/// </summary>
|
||||
public interface ICall123TestSpecialTagsApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Org.OpenAPITools.Model.ModelClient>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// This class is registered as transient.
|
||||
/// </summary>
|
||||
public class AnotherFakeApiEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<ModelClient>> OnCall123TestSpecialTags;
|
||||
public event EventHandler<ApiResponseEventArgs> OnCall123TestSpecialTags;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs> OnErrorCall123TestSpecialTags;
|
||||
|
||||
internal void ExecuteOnCall123TestSpecialTags(ApiResponse<ModelClient> apiResponse)
|
||||
internal void ExecuteOnCall123TestSpecialTags(AnotherFakeApi.Call123TestSpecialTagsApiResponse apiResponse)
|
||||
{
|
||||
OnCall123TestSpecialTags?.Invoke(this, new ApiResponseEventArgs<ModelClient>(apiResponse));
|
||||
OnCall123TestSpecialTags?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorCall123TestSpecialTags(Exception exception)
|
||||
@@ -91,6 +102,11 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
private JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The logger factory
|
||||
/// </summary>
|
||||
public ILoggerFactory LoggerFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
@@ -135,7 +151,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// Initializes a new instance of the <see cref="AnotherFakeApi"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public AnotherFakeApi(ILogger<AnotherFakeApi> logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, AnotherFakeApiEvents anotherFakeApiEvents,
|
||||
public AnotherFakeApi(ILogger<AnotherFakeApi> logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, AnotherFakeApiEvents anotherFakeApiEvents,
|
||||
TokenProvider<ApiKeyToken> apiKeyProvider,
|
||||
TokenProvider<BearerToken> bearerTokenProvider,
|
||||
TokenProvider<BasicToken> basicTokenProvider,
|
||||
@@ -143,7 +159,8 @@ namespace Org.OpenAPITools.Api
|
||||
TokenProvider<OAuthToken> oauthTokenProvider)
|
||||
{
|
||||
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
|
||||
Logger = logger;
|
||||
LoggerFactory = loggerFactory;
|
||||
Logger = LoggerFactory.CreateLogger<AnotherFakeApi>();
|
||||
HttpClient = httpClient;
|
||||
Events = anotherFakeApiEvents;
|
||||
ApiKeyProvider = apiKeyProvider;
|
||||
@@ -171,7 +188,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="modelClient"></param>
|
||||
private void AfterCall123TestSpecialTagsDefaultImplementation(ApiResponse<ModelClient> apiResponseLocalVar, ModelClient modelClient)
|
||||
private void AfterCall123TestSpecialTagsDefaultImplementation(ICall123TestSpecialTagsApiResponse apiResponseLocalVar, ModelClient modelClient)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterCall123TestSpecialTags(ref suppressDefaultLog, apiResponseLocalVar, modelClient);
|
||||
@@ -185,7 +202,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="modelClient"></param>
|
||||
partial void AfterCall123TestSpecialTags(ref bool suppressDefaultLog, ApiResponse<ModelClient> apiResponseLocalVar, ModelClient modelClient);
|
||||
partial void AfterCall123TestSpecialTags(ref bool suppressDefaultLog, ICall123TestSpecialTagsApiResponse apiResponseLocalVar, ModelClient modelClient);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -217,8 +234,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="ModelClient"/></returns>
|
||||
public async Task<ApiResponse<ModelClient>> Call123TestSpecialTagsOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="ICall123TestSpecialTagsApiResponse"/>></returns>
|
||||
public async Task<ICall123TestSpecialTagsApiResponse> Call123TestSpecialTagsOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -236,8 +253,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="ModelClient"/></returns>
|
||||
public async Task<ApiResponse<ModelClient>> Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="ICall123TestSpecialTagsApiResponse"/>></returns>
|
||||
public async Task<ICall123TestSpecialTagsApiResponse> Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -286,7 +303,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<ModelClient> apiResponseLocalVar = new ApiResponse<ModelClient>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/another-fake/dummy", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<Call123TestSpecialTagsApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<Call123TestSpecialTagsApiResponse>();
|
||||
|
||||
Call123TestSpecialTagsApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/another-fake/dummy", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterCall123TestSpecialTagsDefaultImplementation(apiResponseLocalVar, modelClient);
|
||||
|
||||
@@ -303,5 +322,82 @@ namespace Org.OpenAPITools.Api
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Call123TestSpecialTagsApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class Call123TestSpecialTagsApiResponse : Org.OpenAPITools.Client.ApiResponse, ICall123TestSpecialTagsApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<Call123TestSpecialTagsApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Call123TestSpecialTagsApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public Call123TestSpecialTagsApiResponse(ILogger<Call123TestSpecialTagsApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Org.OpenAPITools.Model.ModelClient Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.ModelClient>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.ModelClient result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json;
|
||||
using Org.OpenAPITools.Client;
|
||||
using Org.OpenAPITools.Api;
|
||||
using Org.OpenAPITools.Model;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Org.OpenAPITools.Api
|
||||
{
|
||||
@@ -41,8 +41,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<FooGetDefaultResponse>></returns>
|
||||
Task<ApiResponse<FooGetDefaultResponse>> FooGetAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IFooGetApiResponse"/>></returns>
|
||||
Task<IFooGetApiResponse> FooGetAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -51,8 +51,8 @@ namespace Org.OpenAPITools.Api
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>FooGetDefaultResponse>></returns>
|
||||
Task<ApiResponse<FooGetDefaultResponse>> FooGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IFooGetApiResponse"/>></returns>
|
||||
Task<IFooGetApiResponse> FooGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -63,8 +63,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="country"></param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<object>></returns>
|
||||
Task<ApiResponse<object>> GetCountryAsync(string country, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IGetCountryApiResponse"/>></returns>
|
||||
Task<IGetCountryApiResponse> GetCountryAsync(string country, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -74,8 +74,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <param name="country"></param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>object>></returns>
|
||||
Task<ApiResponse<object>> GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IGetCountryApiResponse"/>></returns>
|
||||
Task<IGetCountryApiResponse> GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Hello
|
||||
@@ -85,8 +85,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<List<Guid>>></returns>
|
||||
Task<ApiResponse<List<Guid>>> HelloAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IHelloApiResponse"/>></returns>
|
||||
Task<IHelloApiResponse> HelloAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Hello
|
||||
@@ -95,8 +95,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// Hello
|
||||
/// </remarks>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>List<Guid>>></returns>
|
||||
Task<ApiResponse<List<Guid>>> HelloOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IHelloApiResponse"/>></returns>
|
||||
Task<IHelloApiResponse> HelloOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -106,8 +106,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<List<List<RolesReportsHash>>>></returns>
|
||||
Task<ApiResponse<List<List<RolesReportsHash>>>> RolesReportGetAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IRolesReportGetApiResponse"/>></returns>
|
||||
Task<IRolesReportGetApiResponse> RolesReportGetAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -116,8 +116,8 @@ namespace Org.OpenAPITools.Api
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>List<List<RolesReportsHash>>>></returns>
|
||||
Task<ApiResponse<List<List<RolesReportsHash>>>> RolesReportGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IRolesReportGetApiResponse"/>></returns>
|
||||
Task<IRolesReportGetApiResponse> RolesReportGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve an existing Notificationtest's Elements
|
||||
@@ -127,8 +127,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<NotificationtestGetElementsV1ResponseMPayload>></returns>
|
||||
Task<ApiResponse<NotificationtestGetElementsV1ResponseMPayload>> TestAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="ITestApiResponse"/>></returns>
|
||||
Task<ITestApiResponse> TestAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve an existing Notificationtest's Elements
|
||||
@@ -137,29 +137,88 @@ namespace Org.OpenAPITools.Api
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>NotificationtestGetElementsV1ResponseMPayload>></returns>
|
||||
Task<ApiResponse<NotificationtestGetElementsV1ResponseMPayload>> TestOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="ITestApiResponse"/>></returns>
|
||||
Task<ITestApiResponse> TestOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IFooGetApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IFooGetApiResponse : Org.OpenAPITools.Client.IApiResponse, IDefault<Org.OpenAPITools.Model.FooGetDefaultResponse>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is the default response type
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsDefault { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IGetCountryApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IGetCountryApiResponse : Org.OpenAPITools.Client.IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IHelloApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IHelloApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<List<Guid>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IRolesReportGetApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IRolesReportGetApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<List<List>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ITestApiResponse"/>
|
||||
/// </summary>
|
||||
public interface ITestApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// This class is registered as transient.
|
||||
/// </summary>
|
||||
public class DefaultApiEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<FooGetDefaultResponse>> OnFooGet;
|
||||
public event EventHandler<ApiResponseEventArgs> OnFooGet;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs> OnErrorFooGet;
|
||||
|
||||
internal void ExecuteOnFooGet(ApiResponse<FooGetDefaultResponse> apiResponse)
|
||||
internal void ExecuteOnFooGet(DefaultApi.FooGetApiResponse apiResponse)
|
||||
{
|
||||
OnFooGet?.Invoke(this, new ApiResponseEventArgs<FooGetDefaultResponse>(apiResponse));
|
||||
OnFooGet?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorFooGet(Exception exception)
|
||||
@@ -170,16 +229,16 @@ namespace Org.OpenAPITools.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<object>> OnGetCountry;
|
||||
public event EventHandler<ApiResponseEventArgs> OnGetCountry;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs> OnErrorGetCountry;
|
||||
|
||||
internal void ExecuteOnGetCountry(ApiResponse<object> apiResponse)
|
||||
internal void ExecuteOnGetCountry(DefaultApi.GetCountryApiResponse apiResponse)
|
||||
{
|
||||
OnGetCountry?.Invoke(this, new ApiResponseEventArgs<object>(apiResponse));
|
||||
OnGetCountry?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorGetCountry(Exception exception)
|
||||
@@ -190,16 +249,16 @@ namespace Org.OpenAPITools.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<List<Guid>>> OnHello;
|
||||
public event EventHandler<ApiResponseEventArgs> OnHello;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs> OnErrorHello;
|
||||
|
||||
internal void ExecuteOnHello(ApiResponse<List<Guid>> apiResponse)
|
||||
internal void ExecuteOnHello(DefaultApi.HelloApiResponse apiResponse)
|
||||
{
|
||||
OnHello?.Invoke(this, new ApiResponseEventArgs<List<Guid>>(apiResponse));
|
||||
OnHello?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorHello(Exception exception)
|
||||
@@ -210,16 +269,16 @@ namespace Org.OpenAPITools.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<List<List<RolesReportsHash>>>> OnRolesReportGet;
|
||||
public event EventHandler<ApiResponseEventArgs> OnRolesReportGet;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs> OnErrorRolesReportGet;
|
||||
|
||||
internal void ExecuteOnRolesReportGet(ApiResponse<List<List<RolesReportsHash>>> apiResponse)
|
||||
internal void ExecuteOnRolesReportGet(DefaultApi.RolesReportGetApiResponse apiResponse)
|
||||
{
|
||||
OnRolesReportGet?.Invoke(this, new ApiResponseEventArgs<List<List<RolesReportsHash>>>(apiResponse));
|
||||
OnRolesReportGet?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorRolesReportGet(Exception exception)
|
||||
@@ -230,16 +289,16 @@ namespace Org.OpenAPITools.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<NotificationtestGetElementsV1ResponseMPayload>> OnTest;
|
||||
public event EventHandler<ApiResponseEventArgs> OnTest;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs> OnErrorTest;
|
||||
|
||||
internal void ExecuteOnTest(ApiResponse<NotificationtestGetElementsV1ResponseMPayload> apiResponse)
|
||||
internal void ExecuteOnTest(DefaultApi.TestApiResponse apiResponse)
|
||||
{
|
||||
OnTest?.Invoke(this, new ApiResponseEventArgs<NotificationtestGetElementsV1ResponseMPayload>(apiResponse));
|
||||
OnTest?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorTest(Exception exception)
|
||||
@@ -255,6 +314,11 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
private JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The logger factory
|
||||
/// </summary>
|
||||
public ILoggerFactory LoggerFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
@@ -299,7 +363,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// Initializes a new instance of the <see cref="DefaultApi"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public DefaultApi(ILogger<DefaultApi> logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents,
|
||||
public DefaultApi(ILogger<DefaultApi> logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents,
|
||||
TokenProvider<ApiKeyToken> apiKeyProvider,
|
||||
TokenProvider<BearerToken> bearerTokenProvider,
|
||||
TokenProvider<BasicToken> basicTokenProvider,
|
||||
@@ -307,7 +371,8 @@ namespace Org.OpenAPITools.Api
|
||||
TokenProvider<OAuthToken> oauthTokenProvider)
|
||||
{
|
||||
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
|
||||
Logger = logger;
|
||||
LoggerFactory = loggerFactory;
|
||||
Logger = LoggerFactory.CreateLogger<DefaultApi>();
|
||||
HttpClient = httpClient;
|
||||
Events = defaultApiEvents;
|
||||
ApiKeyProvider = apiKeyProvider;
|
||||
@@ -321,7 +386,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// Processes the server response
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
private void AfterFooGetDefaultImplementation(ApiResponse<FooGetDefaultResponse> apiResponseLocalVar)
|
||||
private void AfterFooGetDefaultImplementation(IFooGetApiResponse apiResponseLocalVar)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterFooGet(ref suppressDefaultLog, apiResponseLocalVar);
|
||||
@@ -334,7 +399,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
partial void AfterFooGet(ref bool suppressDefaultLog, ApiResponse<FooGetDefaultResponse> apiResponseLocalVar);
|
||||
partial void AfterFooGet(ref bool suppressDefaultLog, IFooGetApiResponse apiResponseLocalVar);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -363,8 +428,8 @@ namespace Org.OpenAPITools.Api
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="FooGetDefaultResponse"/></returns>
|
||||
public async Task<ApiResponse<FooGetDefaultResponse>> FooGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IFooGetApiResponse"/>></returns>
|
||||
public async Task<IFooGetApiResponse> FooGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -381,8 +446,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="FooGetDefaultResponse"/></returns>
|
||||
public async Task<ApiResponse<FooGetDefaultResponse>> FooGetAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IFooGetApiResponse"/>></returns>
|
||||
public async Task<IFooGetApiResponse> FooGetAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -414,7 +479,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<FooGetDefaultResponse> apiResponseLocalVar = new ApiResponse<FooGetDefaultResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/foo", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<FooGetApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<FooGetApiResponse>();
|
||||
|
||||
FooGetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/foo", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterFooGetDefaultImplementation(apiResponseLocalVar);
|
||||
|
||||
@@ -432,6 +499,83 @@ namespace Org.OpenAPITools.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="FooGetApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class FooGetApiResponse : Org.OpenAPITools.Client.ApiResponse, IFooGetApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<FooGetApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="FooGetApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public FooGetApiResponse(ILogger<FooGetApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is the default response type
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsDefault => true;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 0 Default
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Org.OpenAPITools.Model.FooGetDefaultResponse Default()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsDefault
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.FooGetDefaultResponse>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 0 Default and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryDefault([NotNullWhen(true)]out Org.OpenAPITools.Model.FooGetDefaultResponse result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Default();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)0);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
partial void FormatGetCountry(ref string country);
|
||||
|
||||
/// <summary>
|
||||
@@ -450,7 +594,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="country"></param>
|
||||
private void AfterGetCountryDefaultImplementation(ApiResponse<object> apiResponseLocalVar, string country)
|
||||
private void AfterGetCountryDefaultImplementation(IGetCountryApiResponse apiResponseLocalVar, string country)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterGetCountry(ref suppressDefaultLog, apiResponseLocalVar, country);
|
||||
@@ -464,7 +608,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="country"></param>
|
||||
partial void AfterGetCountry(ref bool suppressDefaultLog, ApiResponse<object> apiResponseLocalVar, string country);
|
||||
partial void AfterGetCountry(ref bool suppressDefaultLog, IGetCountryApiResponse apiResponseLocalVar, string country);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -496,8 +640,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="country"></param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="object"/></returns>
|
||||
public async Task<ApiResponse<object>> GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IGetCountryApiResponse"/>></returns>
|
||||
public async Task<IGetCountryApiResponse> GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -515,8 +659,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="country"></param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="object"/></returns>
|
||||
public async Task<ApiResponse<object>> GetCountryAsync(string country, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IGetCountryApiResponse"/>></returns>
|
||||
public async Task<IGetCountryApiResponse> GetCountryAsync(string country, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -562,7 +706,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<object> apiResponseLocalVar = new ApiResponse<object>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/country", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<GetCountryApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<GetCountryApiResponse>();
|
||||
|
||||
GetCountryApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/country", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterGetCountryDefaultImplementation(apiResponseLocalVar, country);
|
||||
|
||||
@@ -580,11 +726,56 @@ namespace Org.OpenAPITools.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GetCountryApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class GetCountryApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetCountryApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<GetCountryApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GetCountryApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public GetCountryApiResponse(ILogger<GetCountryApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes the server response
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
private void AfterHelloDefaultImplementation(ApiResponse<List<Guid>> apiResponseLocalVar)
|
||||
private void AfterHelloDefaultImplementation(IHelloApiResponse apiResponseLocalVar)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterHello(ref suppressDefaultLog, apiResponseLocalVar);
|
||||
@@ -597,7 +788,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
partial void AfterHello(ref bool suppressDefaultLog, ApiResponse<List<Guid>> apiResponseLocalVar);
|
||||
partial void AfterHello(ref bool suppressDefaultLog, IHelloApiResponse apiResponseLocalVar);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -626,8 +817,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// Hello Hello
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="List{TValue}"/></returns>
|
||||
public async Task<ApiResponse<List<Guid>>> HelloOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IHelloApiResponse"/>></returns>
|
||||
public async Task<IHelloApiResponse> HelloOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -644,8 +835,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="List{TValue}"/></returns>
|
||||
public async Task<ApiResponse<List<Guid>>> HelloAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IHelloApiResponse"/>></returns>
|
||||
public async Task<IHelloApiResponse> HelloAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -677,7 +868,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<List<Guid>> apiResponseLocalVar = new ApiResponse<List<Guid>>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/hello", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<HelloApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<HelloApiResponse>();
|
||||
|
||||
HelloApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/hello", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterHelloDefaultImplementation(apiResponseLocalVar);
|
||||
|
||||
@@ -695,11 +888,88 @@ namespace Org.OpenAPITools.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="HelloApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class HelloApiResponse : Org.OpenAPITools.Client.ApiResponse, IHelloApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<HelloApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="HelloApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public HelloApiResponse(ILogger<HelloApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<Guid> Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<List<Guid>>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out List<Guid> result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes the server response
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
private void AfterRolesReportGetDefaultImplementation(ApiResponse<List<List<RolesReportsHash>>> apiResponseLocalVar)
|
||||
private void AfterRolesReportGetDefaultImplementation(IRolesReportGetApiResponse apiResponseLocalVar)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterRolesReportGet(ref suppressDefaultLog, apiResponseLocalVar);
|
||||
@@ -712,7 +982,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
partial void AfterRolesReportGet(ref bool suppressDefaultLog, ApiResponse<List<List<RolesReportsHash>>> apiResponseLocalVar);
|
||||
partial void AfterRolesReportGet(ref bool suppressDefaultLog, IRolesReportGetApiResponse apiResponseLocalVar);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -741,8 +1011,8 @@ namespace Org.OpenAPITools.Api
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="List{TValue}"/></returns>
|
||||
public async Task<ApiResponse<List<List<RolesReportsHash>>>> RolesReportGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IRolesReportGetApiResponse"/>></returns>
|
||||
public async Task<IRolesReportGetApiResponse> RolesReportGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -759,8 +1029,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="List{TValue}"/></returns>
|
||||
public async Task<ApiResponse<List<List<RolesReportsHash>>>> RolesReportGetAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IRolesReportGetApiResponse"/>></returns>
|
||||
public async Task<IRolesReportGetApiResponse> RolesReportGetAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -792,7 +1062,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<List<List<RolesReportsHash>>> apiResponseLocalVar = new ApiResponse<List<List<RolesReportsHash>>>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/roles/report", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<RolesReportGetApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<RolesReportGetApiResponse>();
|
||||
|
||||
RolesReportGetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/roles/report", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterRolesReportGetDefaultImplementation(apiResponseLocalVar);
|
||||
|
||||
@@ -810,11 +1082,88 @@ namespace Org.OpenAPITools.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="RolesReportGetApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class RolesReportGetApiResponse : Org.OpenAPITools.Client.ApiResponse, IRolesReportGetApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<RolesReportGetApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="RolesReportGetApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public RolesReportGetApiResponse(ILogger<RolesReportGetApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<List> Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<List<List>>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out List<List> result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes the server response
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
private void AfterTestDefaultImplementation(ApiResponse<NotificationtestGetElementsV1ResponseMPayload> apiResponseLocalVar)
|
||||
private void AfterTestDefaultImplementation(ITestApiResponse apiResponseLocalVar)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterTest(ref suppressDefaultLog, apiResponseLocalVar);
|
||||
@@ -827,7 +1176,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
partial void AfterTest(ref bool suppressDefaultLog, ApiResponse<NotificationtestGetElementsV1ResponseMPayload> apiResponseLocalVar);
|
||||
partial void AfterTest(ref bool suppressDefaultLog, ITestApiResponse apiResponseLocalVar);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -856,8 +1205,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// Retrieve an existing Notificationtest's Elements
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="NotificationtestGetElementsV1ResponseMPayload"/></returns>
|
||||
public async Task<ApiResponse<NotificationtestGetElementsV1ResponseMPayload>> TestOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="ITestApiResponse"/>></returns>
|
||||
public async Task<ITestApiResponse> TestOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -874,8 +1223,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="NotificationtestGetElementsV1ResponseMPayload"/></returns>
|
||||
public async Task<ApiResponse<NotificationtestGetElementsV1ResponseMPayload>> TestAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="ITestApiResponse"/>></returns>
|
||||
public async Task<ITestApiResponse> TestAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -907,7 +1256,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<NotificationtestGetElementsV1ResponseMPayload> apiResponseLocalVar = new ApiResponse<NotificationtestGetElementsV1ResponseMPayload>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/test", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<TestApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<TestApiResponse>();
|
||||
|
||||
TestApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/test", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterTestDefaultImplementation(apiResponseLocalVar);
|
||||
|
||||
@@ -924,5 +1275,82 @@ namespace Org.OpenAPITools.Api
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="TestApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class TestApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<TestApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="TestApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public TestApiResponse(ILogger<TestApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -17,8 +17,8 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json;
|
||||
using Org.OpenAPITools.Client;
|
||||
using Org.OpenAPITools.Api;
|
||||
using Org.OpenAPITools.Model;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Org.OpenAPITools.Api
|
||||
{
|
||||
@@ -42,8 +42,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<ModelClient>></returns>
|
||||
Task<ApiResponse<ModelClient>> TestClassnameAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="ITestClassnameApiResponse"/>></returns>
|
||||
Task<ITestClassnameApiResponse> TestClassnameAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// To test class name in snake case
|
||||
@@ -53,29 +53,40 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>ModelClient>></returns>
|
||||
Task<ApiResponse<ModelClient>> TestClassnameOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="ITestClassnameApiResponse"/>></returns>
|
||||
Task<ITestClassnameApiResponse> TestClassnameOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ITestClassnameApiResponse"/>
|
||||
/// </summary>
|
||||
public interface ITestClassnameApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Org.OpenAPITools.Model.ModelClient>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// This class is registered as transient.
|
||||
/// </summary>
|
||||
public class FakeClassnameTags123ApiEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<ModelClient>> OnTestClassname;
|
||||
public event EventHandler<ApiResponseEventArgs> OnTestClassname;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs> OnErrorTestClassname;
|
||||
|
||||
internal void ExecuteOnTestClassname(ApiResponse<ModelClient> apiResponse)
|
||||
internal void ExecuteOnTestClassname(FakeClassnameTags123Api.TestClassnameApiResponse apiResponse)
|
||||
{
|
||||
OnTestClassname?.Invoke(this, new ApiResponseEventArgs<ModelClient>(apiResponse));
|
||||
OnTestClassname?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorTestClassname(Exception exception)
|
||||
@@ -91,6 +102,11 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
private JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The logger factory
|
||||
/// </summary>
|
||||
public ILoggerFactory LoggerFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
@@ -135,7 +151,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// Initializes a new instance of the <see cref="FakeClassnameTags123Api"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public FakeClassnameTags123Api(ILogger<FakeClassnameTags123Api> logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, FakeClassnameTags123ApiEvents fakeClassnameTags123ApiEvents,
|
||||
public FakeClassnameTags123Api(ILogger<FakeClassnameTags123Api> logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, FakeClassnameTags123ApiEvents fakeClassnameTags123ApiEvents,
|
||||
TokenProvider<ApiKeyToken> apiKeyProvider,
|
||||
TokenProvider<BearerToken> bearerTokenProvider,
|
||||
TokenProvider<BasicToken> basicTokenProvider,
|
||||
@@ -143,7 +159,8 @@ namespace Org.OpenAPITools.Api
|
||||
TokenProvider<OAuthToken> oauthTokenProvider)
|
||||
{
|
||||
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
|
||||
Logger = logger;
|
||||
LoggerFactory = loggerFactory;
|
||||
Logger = LoggerFactory.CreateLogger<FakeClassnameTags123Api>();
|
||||
HttpClient = httpClient;
|
||||
Events = fakeClassnameTags123ApiEvents;
|
||||
ApiKeyProvider = apiKeyProvider;
|
||||
@@ -171,7 +188,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="modelClient"></param>
|
||||
private void AfterTestClassnameDefaultImplementation(ApiResponse<ModelClient> apiResponseLocalVar, ModelClient modelClient)
|
||||
private void AfterTestClassnameDefaultImplementation(ITestClassnameApiResponse apiResponseLocalVar, ModelClient modelClient)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterTestClassname(ref suppressDefaultLog, apiResponseLocalVar, modelClient);
|
||||
@@ -185,7 +202,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="modelClient"></param>
|
||||
partial void AfterTestClassname(ref bool suppressDefaultLog, ApiResponse<ModelClient> apiResponseLocalVar, ModelClient modelClient);
|
||||
partial void AfterTestClassname(ref bool suppressDefaultLog, ITestClassnameApiResponse apiResponseLocalVar, ModelClient modelClient);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -217,8 +234,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="ModelClient"/></returns>
|
||||
public async Task<ApiResponse<ModelClient>> TestClassnameOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="ITestClassnameApiResponse"/>></returns>
|
||||
public async Task<ITestClassnameApiResponse> TestClassnameOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -236,8 +253,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="ModelClient"/></returns>
|
||||
public async Task<ApiResponse<ModelClient>> TestClassnameAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="ITestClassnameApiResponse"/>></returns>
|
||||
public async Task<ITestClassnameApiResponse> TestClassnameAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -297,7 +314,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<ModelClient> apiResponseLocalVar = new ApiResponse<ModelClient>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake_classname_test", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<TestClassnameApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<TestClassnameApiResponse>();
|
||||
|
||||
TestClassnameApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake_classname_test", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterTestClassnameDefaultImplementation(apiResponseLocalVar, modelClient);
|
||||
|
||||
@@ -318,5 +337,82 @@ namespace Org.OpenAPITools.Api
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="TestClassnameApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class TestClassnameApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestClassnameApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<TestClassnameApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="TestClassnameApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public TestClassnameApiResponse(ILogger<TestClassnameApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Org.OpenAPITools.Model.ModelClient Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.ModelClient>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.ModelClient result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -17,8 +17,8 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json;
|
||||
using Org.OpenAPITools.Client;
|
||||
using Org.OpenAPITools.Api;
|
||||
using Org.OpenAPITools.Model;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Org.OpenAPITools.Api
|
||||
{
|
||||
@@ -42,8 +42,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<object>></returns>
|
||||
Task<ApiResponse<object>> DeleteOrderAsync(string orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IDeleteOrderApiResponse"/>></returns>
|
||||
Task<IDeleteOrderApiResponse> DeleteOrderAsync(string orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Delete purchase order by ID
|
||||
@@ -53,8 +53,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>object>></returns>
|
||||
Task<ApiResponse<object>> DeleteOrderOrDefaultAsync(string orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IDeleteOrderApiResponse"/>></returns>
|
||||
Task<IDeleteOrderApiResponse> DeleteOrderOrDefaultAsync(string orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Returns pet inventories by status
|
||||
@@ -64,8 +64,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<Dictionary<string, int>>></returns>
|
||||
Task<ApiResponse<Dictionary<string, int>>> GetInventoryAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IGetInventoryApiResponse"/>></returns>
|
||||
Task<IGetInventoryApiResponse> GetInventoryAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Returns pet inventories by status
|
||||
@@ -74,8 +74,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// Returns a map of status codes to quantities
|
||||
/// </remarks>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>Dictionary<string, int>>></returns>
|
||||
Task<ApiResponse<Dictionary<string, int>>> GetInventoryOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IGetInventoryApiResponse"/>></returns>
|
||||
Task<IGetInventoryApiResponse> GetInventoryOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Find purchase order by ID
|
||||
@@ -86,8 +86,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<Order>></returns>
|
||||
Task<ApiResponse<Order>> GetOrderByIdAsync(long orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IGetOrderByIdApiResponse"/>></returns>
|
||||
Task<IGetOrderByIdApiResponse> GetOrderByIdAsync(long orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Find purchase order by ID
|
||||
@@ -97,8 +97,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>Order>></returns>
|
||||
Task<ApiResponse<Order>> GetOrderByIdOrDefaultAsync(long orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IGetOrderByIdApiResponse"/>></returns>
|
||||
Task<IGetOrderByIdApiResponse> GetOrderByIdOrDefaultAsync(long orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Place an order for a pet
|
||||
@@ -109,8 +109,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="order">order placed for purchasing the pet</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<Order>></returns>
|
||||
Task<ApiResponse<Order>> PlaceOrderAsync(Order order, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IPlaceOrderApiResponse"/>></returns>
|
||||
Task<IPlaceOrderApiResponse> PlaceOrderAsync(Order order, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Place an order for a pet
|
||||
@@ -120,29 +120,100 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <param name="order">order placed for purchasing the pet</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>Order>></returns>
|
||||
Task<ApiResponse<Order>> PlaceOrderOrDefaultAsync(Order order, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IPlaceOrderApiResponse"/>></returns>
|
||||
Task<IPlaceOrderApiResponse> PlaceOrderOrDefaultAsync(Order order, System.Threading.CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IDeleteOrderApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IDeleteOrderApiResponse : Org.OpenAPITools.Client.IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 400 BadRequest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsBadRequest { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 404 NotFound
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsNotFound { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IGetInventoryApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IGetInventoryApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Dictionary<string, int>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IGetOrderByIdApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IGetOrderByIdApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Org.OpenAPITools.Model.Order>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 400 BadRequest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsBadRequest { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 404 NotFound
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsNotFound { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IPlaceOrderApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IPlaceOrderApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Org.OpenAPITools.Model.Order>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 400 BadRequest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsBadRequest { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// This class is registered as transient.
|
||||
/// </summary>
|
||||
public class StoreApiEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<object>> OnDeleteOrder;
|
||||
public event EventHandler<ApiResponseEventArgs> OnDeleteOrder;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs> OnErrorDeleteOrder;
|
||||
|
||||
internal void ExecuteOnDeleteOrder(ApiResponse<object> apiResponse)
|
||||
internal void ExecuteOnDeleteOrder(StoreApi.DeleteOrderApiResponse apiResponse)
|
||||
{
|
||||
OnDeleteOrder?.Invoke(this, new ApiResponseEventArgs<object>(apiResponse));
|
||||
OnDeleteOrder?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorDeleteOrder(Exception exception)
|
||||
@@ -153,16 +224,16 @@ namespace Org.OpenAPITools.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<Dictionary<string, int>>> OnGetInventory;
|
||||
public event EventHandler<ApiResponseEventArgs> OnGetInventory;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs> OnErrorGetInventory;
|
||||
|
||||
internal void ExecuteOnGetInventory(ApiResponse<Dictionary<string, int>> apiResponse)
|
||||
internal void ExecuteOnGetInventory(StoreApi.GetInventoryApiResponse apiResponse)
|
||||
{
|
||||
OnGetInventory?.Invoke(this, new ApiResponseEventArgs<Dictionary<string, int>>(apiResponse));
|
||||
OnGetInventory?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorGetInventory(Exception exception)
|
||||
@@ -173,16 +244,16 @@ namespace Org.OpenAPITools.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<Order>> OnGetOrderById;
|
||||
public event EventHandler<ApiResponseEventArgs> OnGetOrderById;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs> OnErrorGetOrderById;
|
||||
|
||||
internal void ExecuteOnGetOrderById(ApiResponse<Order> apiResponse)
|
||||
internal void ExecuteOnGetOrderById(StoreApi.GetOrderByIdApiResponse apiResponse)
|
||||
{
|
||||
OnGetOrderById?.Invoke(this, new ApiResponseEventArgs<Order>(apiResponse));
|
||||
OnGetOrderById?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorGetOrderById(Exception exception)
|
||||
@@ -193,16 +264,16 @@ namespace Org.OpenAPITools.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<Order>> OnPlaceOrder;
|
||||
public event EventHandler<ApiResponseEventArgs> OnPlaceOrder;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs> OnErrorPlaceOrder;
|
||||
|
||||
internal void ExecuteOnPlaceOrder(ApiResponse<Order> apiResponse)
|
||||
internal void ExecuteOnPlaceOrder(StoreApi.PlaceOrderApiResponse apiResponse)
|
||||
{
|
||||
OnPlaceOrder?.Invoke(this, new ApiResponseEventArgs<Order>(apiResponse));
|
||||
OnPlaceOrder?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorPlaceOrder(Exception exception)
|
||||
@@ -218,6 +289,11 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
private JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The logger factory
|
||||
/// </summary>
|
||||
public ILoggerFactory LoggerFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
@@ -262,7 +338,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// Initializes a new instance of the <see cref="StoreApi"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public StoreApi(ILogger<StoreApi> logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, StoreApiEvents storeApiEvents,
|
||||
public StoreApi(ILogger<StoreApi> logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, StoreApiEvents storeApiEvents,
|
||||
TokenProvider<ApiKeyToken> apiKeyProvider,
|
||||
TokenProvider<BearerToken> bearerTokenProvider,
|
||||
TokenProvider<BasicToken> basicTokenProvider,
|
||||
@@ -270,7 +346,8 @@ namespace Org.OpenAPITools.Api
|
||||
TokenProvider<OAuthToken> oauthTokenProvider)
|
||||
{
|
||||
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
|
||||
Logger = logger;
|
||||
LoggerFactory = loggerFactory;
|
||||
Logger = LoggerFactory.CreateLogger<StoreApi>();
|
||||
HttpClient = httpClient;
|
||||
Events = storeApiEvents;
|
||||
ApiKeyProvider = apiKeyProvider;
|
||||
@@ -298,7 +375,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="orderId"></param>
|
||||
private void AfterDeleteOrderDefaultImplementation(ApiResponse<object> apiResponseLocalVar, string orderId)
|
||||
private void AfterDeleteOrderDefaultImplementation(IDeleteOrderApiResponse apiResponseLocalVar, string orderId)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterDeleteOrder(ref suppressDefaultLog, apiResponseLocalVar, orderId);
|
||||
@@ -312,7 +389,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="orderId"></param>
|
||||
partial void AfterDeleteOrder(ref bool suppressDefaultLog, ApiResponse<object> apiResponseLocalVar, string orderId);
|
||||
partial void AfterDeleteOrder(ref bool suppressDefaultLog, IDeleteOrderApiResponse apiResponseLocalVar, string orderId);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -344,8 +421,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="object"/></returns>
|
||||
public async Task<ApiResponse<object>> DeleteOrderOrDefaultAsync(string orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IDeleteOrderApiResponse"/>></returns>
|
||||
public async Task<IDeleteOrderApiResponse> DeleteOrderOrDefaultAsync(string orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -363,8 +440,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="object"/></returns>
|
||||
public async Task<ApiResponse<object>> DeleteOrderAsync(string orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IDeleteOrderApiResponse"/>></returns>
|
||||
public async Task<IDeleteOrderApiResponse> DeleteOrderAsync(string orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -392,7 +469,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<object> apiResponseLocalVar = new ApiResponse<object>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<DeleteOrderApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<DeleteOrderApiResponse>();
|
||||
|
||||
DeleteOrderApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterDeleteOrderDefaultImplementation(apiResponseLocalVar, orderId);
|
||||
|
||||
@@ -410,11 +489,62 @@ namespace Org.OpenAPITools.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DeleteOrderApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class DeleteOrderApiResponse : Org.OpenAPITools.Client.ApiResponse, IDeleteOrderApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<DeleteOrderApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DeleteOrderApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public DeleteOrderApiResponse(ILogger<DeleteOrderApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 400 BadRequest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsBadRequest => 400 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 404 NotFound
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsNotFound => 404 == (int)StatusCode;
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes the server response
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
private void AfterGetInventoryDefaultImplementation(ApiResponse<Dictionary<string, int>> apiResponseLocalVar)
|
||||
private void AfterGetInventoryDefaultImplementation(IGetInventoryApiResponse apiResponseLocalVar)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterGetInventory(ref suppressDefaultLog, apiResponseLocalVar);
|
||||
@@ -427,7 +557,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
partial void AfterGetInventory(ref bool suppressDefaultLog, ApiResponse<Dictionary<string, int>> apiResponseLocalVar);
|
||||
partial void AfterGetInventory(ref bool suppressDefaultLog, IGetInventoryApiResponse apiResponseLocalVar);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -456,8 +586,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// Returns pet inventories by status Returns a map of status codes to quantities
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Dictionary{TKey, TValue}"/></returns>
|
||||
public async Task<ApiResponse<Dictionary<string, int>>> GetInventoryOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IGetInventoryApiResponse"/>></returns>
|
||||
public async Task<IGetInventoryApiResponse> GetInventoryOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -474,8 +604,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Dictionary{TKey, TValue}"/></returns>
|
||||
public async Task<ApiResponse<Dictionary<string, int>>> GetInventoryAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IGetInventoryApiResponse"/>></returns>
|
||||
public async Task<IGetInventoryApiResponse> GetInventoryAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -515,7 +645,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<Dictionary<string, int>> apiResponseLocalVar = new ApiResponse<Dictionary<string, int>>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/inventory", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<GetInventoryApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<GetInventoryApiResponse>();
|
||||
|
||||
GetInventoryApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/inventory", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterGetInventoryDefaultImplementation(apiResponseLocalVar);
|
||||
|
||||
@@ -537,6 +669,83 @@ namespace Org.OpenAPITools.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GetInventoryApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class GetInventoryApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetInventoryApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<GetInventoryApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GetInventoryApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public GetInventoryApiResponse(ILogger<GetInventoryApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Dictionary<string, int> Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Dictionary<string, int>>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out Dictionary<string, int> result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
partial void FormatGetOrderById(ref long orderId);
|
||||
|
||||
/// <summary>
|
||||
@@ -544,7 +753,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="orderId"></param>
|
||||
private void AfterGetOrderByIdDefaultImplementation(ApiResponse<Order> apiResponseLocalVar, long orderId)
|
||||
private void AfterGetOrderByIdDefaultImplementation(IGetOrderByIdApiResponse apiResponseLocalVar, long orderId)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterGetOrderById(ref suppressDefaultLog, apiResponseLocalVar, orderId);
|
||||
@@ -558,7 +767,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="orderId"></param>
|
||||
partial void AfterGetOrderById(ref bool suppressDefaultLog, ApiResponse<Order> apiResponseLocalVar, long orderId);
|
||||
partial void AfterGetOrderById(ref bool suppressDefaultLog, IGetOrderByIdApiResponse apiResponseLocalVar, long orderId);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -590,8 +799,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Order"/></returns>
|
||||
public async Task<ApiResponse<Order>> GetOrderByIdOrDefaultAsync(long orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IGetOrderByIdApiResponse"/>></returns>
|
||||
public async Task<IGetOrderByIdApiResponse> GetOrderByIdOrDefaultAsync(long orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -609,8 +818,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Order"/></returns>
|
||||
public async Task<ApiResponse<Order>> GetOrderByIdAsync(long orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IGetOrderByIdApiResponse"/>></returns>
|
||||
public async Task<IGetOrderByIdApiResponse> GetOrderByIdAsync(long orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -646,7 +855,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<Order> apiResponseLocalVar = new ApiResponse<Order>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<GetOrderByIdApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<GetOrderByIdApiResponse>();
|
||||
|
||||
GetOrderByIdApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterGetOrderByIdDefaultImplementation(apiResponseLocalVar, orderId);
|
||||
|
||||
@@ -664,6 +875,95 @@ namespace Org.OpenAPITools.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GetOrderByIdApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class GetOrderByIdApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetOrderByIdApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<GetOrderByIdApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GetOrderByIdApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public GetOrderByIdApiResponse(ILogger<GetOrderByIdApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Org.OpenAPITools.Model.Order Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.Order>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.Order result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 400 BadRequest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsBadRequest => 400 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 404 NotFound
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsNotFound => 404 == (int)StatusCode;
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
partial void FormatPlaceOrder(Order order);
|
||||
|
||||
/// <summary>
|
||||
@@ -682,7 +982,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="order"></param>
|
||||
private void AfterPlaceOrderDefaultImplementation(ApiResponse<Order> apiResponseLocalVar, Order order)
|
||||
private void AfterPlaceOrderDefaultImplementation(IPlaceOrderApiResponse apiResponseLocalVar, Order order)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterPlaceOrder(ref suppressDefaultLog, apiResponseLocalVar, order);
|
||||
@@ -696,7 +996,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="order"></param>
|
||||
partial void AfterPlaceOrder(ref bool suppressDefaultLog, ApiResponse<Order> apiResponseLocalVar, Order order);
|
||||
partial void AfterPlaceOrder(ref bool suppressDefaultLog, IPlaceOrderApiResponse apiResponseLocalVar, Order order);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -728,8 +1028,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="order">order placed for purchasing the pet</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Order"/></returns>
|
||||
public async Task<ApiResponse<Order>> PlaceOrderOrDefaultAsync(Order order, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IPlaceOrderApiResponse"/>></returns>
|
||||
public async Task<IPlaceOrderApiResponse> PlaceOrderOrDefaultAsync(Order order, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -747,8 +1047,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="order">order placed for purchasing the pet</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Order"/></returns>
|
||||
public async Task<ApiResponse<Order>> PlaceOrderAsync(Order order, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IPlaceOrderApiResponse"/>></returns>
|
||||
public async Task<IPlaceOrderApiResponse> PlaceOrderAsync(Order order, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -798,7 +1098,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<Order> apiResponseLocalVar = new ApiResponse<Order>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<PlaceOrderApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<PlaceOrderApiResponse>();
|
||||
|
||||
PlaceOrderApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterPlaceOrderDefaultImplementation(apiResponseLocalVar, order);
|
||||
|
||||
@@ -815,5 +1117,88 @@ namespace Org.OpenAPITools.Api
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="PlaceOrderApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class PlaceOrderApiResponse : Org.OpenAPITools.Client.ApiResponse, IPlaceOrderApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<PlaceOrderApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="PlaceOrderApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public PlaceOrderApiResponse(ILogger<PlaceOrderApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Org.OpenAPITools.Model.Order Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.Order>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.Order result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 400 BadRequest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsBadRequest => 400 == (int)StatusCode;
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,18 +5,18 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// Useful for tracking server health
|
||||
/// </summary>
|
||||
public class ApiResponseEventArgs<T> : EventArgs
|
||||
public class ApiResponseEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// The ApiResponse
|
||||
/// </summary>
|
||||
public ApiResponse<T> ApiResponse { get; }
|
||||
public ApiResponse ApiResponse { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The ApiResponseEventArgs
|
||||
/// </summary>
|
||||
/// <param name="apiResponse"></param>
|
||||
public ApiResponseEventArgs(ApiResponse<T> apiResponse)
|
||||
public ApiResponseEventArgs(ApiResponse apiResponse)
|
||||
{
|
||||
ApiResponse = apiResponse;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
|
||||
@@ -18,15 +17,15 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// Provides a non-generic contract for the ApiResponse wrapper.
|
||||
/// </summary>
|
||||
public interface IApiResponse
|
||||
public partial interface IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The type that represents the server's response.
|
||||
/// The IsSuccessStatusCode from the api response
|
||||
/// </summary>
|
||||
Type ResponseType { get; }
|
||||
bool IsSuccessStatusCode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the status code (HTTP status code)
|
||||
/// Gets the status code (HTTP status code)
|
||||
/// </summary>
|
||||
/// <value>The status code.</value>
|
||||
HttpStatusCode StatusCode { get; }
|
||||
@@ -41,11 +40,26 @@ namespace Org.OpenAPITools.Client
|
||||
/// </summary>
|
||||
DateTime DownloadedAt { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The headers contained in the api response
|
||||
/// </summary>
|
||||
System.Net.Http.Headers.HttpResponseHeaders Headers { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The path used when making the request.
|
||||
/// </summary>
|
||||
string Path { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The reason phrase contained in the api response
|
||||
/// </summary>
|
||||
string ReasonPhrase { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The DateTime when the request was sent.
|
||||
/// </summary>
|
||||
DateTime RequestedAt { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The Uri used when making the request.
|
||||
/// </summary>
|
||||
@@ -55,26 +69,18 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// API Response
|
||||
/// </summary>
|
||||
public partial class ApiResponse<T> : IApiResponse
|
||||
public partial class ApiResponse : IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the status code (HTTP status code)
|
||||
/// Gets the status code (HTTP status code)
|
||||
/// </summary>
|
||||
/// <value>The status code.</value>
|
||||
public HttpStatusCode StatusCode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The type that represents the server's response.
|
||||
/// </summary>
|
||||
public Type ResponseType
|
||||
{
|
||||
get { return typeof(T); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The raw data
|
||||
/// </summary>
|
||||
public string RawContent { get; private set; }
|
||||
public string RawContent { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// The IsSuccessStatusCode from the api response
|
||||
@@ -112,9 +118,9 @@ namespace Org.OpenAPITools.Client
|
||||
public Uri RequestUri { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The JsonSerialzierOptions
|
||||
/// The <see cref="System.Text.Json.JsonSerializerOptions"/>
|
||||
/// </summary>
|
||||
private System.Text.Json.JsonSerializerOptions _jsonSerializerOptions;
|
||||
protected System.Text.Json.JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Construct the response using an HttpResponseMessage
|
||||
@@ -140,33 +146,45 @@ namespace Org.OpenAPITools.Client
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An interface for responses of type
|
||||
/// </summary>
|
||||
/// <typeparam name="TType"></typeparam>
|
||||
public interface IOk<TType> : IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
TType Ok();
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the server's response
|
||||
/// Returns true if the response is Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
public T AsModel()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsSuccessStatusCode
|
||||
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, _jsonSerializerOptions)
|
||||
: default(T);
|
||||
}
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
bool TryOk([NotNullWhen(true)]out TType result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An interface for responses of type
|
||||
/// </summary>
|
||||
/// <typeparam name="TType"></typeparam>
|
||||
public interface IDefault<TType> : IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is Default
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
TType Default();
|
||||
|
||||
/// <summary>
|
||||
/// Returns true when the model can be deserialized
|
||||
/// Returns true if the response is Default and the deserialized response is not null
|
||||
/// </summary>
|
||||
public bool TryToModel([NotNullWhen(true)] out T model)
|
||||
{
|
||||
try
|
||||
{
|
||||
model = AsModel();
|
||||
return model != null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
model = default(T);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
bool TryDefault([NotNullWhen(true)]out TType result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ namespace YourProject
|
||||
{
|
||||
var host = CreateHostBuilder(args).Build();
|
||||
var api = host.Services.GetRequiredService<IAnotherFakeApi>();
|
||||
ApiResponse<ModelClient> response = await api.Call123TestSpecialTagsAsync("todo");
|
||||
ModelClient model = response.AsModel();
|
||||
Call123TestSpecialTagsApiResponse apiResponse = await api.Call123TestSpecialTagsAsync("todo");
|
||||
ModelClient model = apiResponse.Ok();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args)
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
string personId = default!;
|
||||
var response = await _instance.ListAsync(personId);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<Person>(model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json;
|
||||
using Org.OpenAPITools.Client;
|
||||
using Org.OpenAPITools.Api;
|
||||
using Org.OpenAPITools.Model;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Org.OpenAPITools.Api
|
||||
{
|
||||
@@ -44,8 +44,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="personId">The id of the person to retrieve</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<Person>></returns>
|
||||
Task<ApiResponse<Person>> ListAsync(string personId, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IListApiResponse"/>></returns>
|
||||
Task<IListApiResponse> ListAsync(string personId, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -55,29 +55,40 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <param name="personId">The id of the person to retrieve</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>Person>?></returns>
|
||||
Task<ApiResponse<Person>?> ListOrDefaultAsync(string personId, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IListApiResponse"/>?></returns>
|
||||
Task<IListApiResponse?> ListOrDefaultAsync(string personId, System.Threading.CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IListApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IListApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Org.OpenAPITools.Model.Person?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// This class is registered as transient.
|
||||
/// </summary>
|
||||
public class DefaultApiEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<Person>>? OnList;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnList;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorList;
|
||||
|
||||
internal void ExecuteOnList(ApiResponse<Person> apiResponse)
|
||||
internal void ExecuteOnList(DefaultApi.ListApiResponse apiResponse)
|
||||
{
|
||||
OnList?.Invoke(this, new ApiResponseEventArgs<Person>(apiResponse));
|
||||
OnList?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorList(Exception exception)
|
||||
@@ -93,6 +104,11 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
private JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The logger factory
|
||||
/// </summary>
|
||||
public ILoggerFactory LoggerFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
@@ -112,10 +128,11 @@ namespace Org.OpenAPITools.Api
|
||||
/// Initializes a new instance of the <see cref="DefaultApi"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public DefaultApi(ILogger<DefaultApi> logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents)
|
||||
public DefaultApi(ILogger<DefaultApi> logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents)
|
||||
{
|
||||
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
|
||||
Logger = logger;
|
||||
LoggerFactory = loggerFactory;
|
||||
Logger = LoggerFactory.CreateLogger<DefaultApi>();
|
||||
HttpClient = httpClient;
|
||||
Events = defaultApiEvents;
|
||||
}
|
||||
@@ -138,7 +155,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="personId"></param>
|
||||
private void AfterListDefaultImplementation(ApiResponse<Person> apiResponseLocalVar, string personId)
|
||||
private void AfterListDefaultImplementation(IListApiResponse apiResponseLocalVar, string personId)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterList(ref suppressDefaultLog, apiResponseLocalVar, personId);
|
||||
@@ -152,7 +169,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="personId"></param>
|
||||
partial void AfterList(ref bool suppressDefaultLog, ApiResponse<Person> apiResponseLocalVar, string personId);
|
||||
partial void AfterList(ref bool suppressDefaultLog, IListApiResponse apiResponseLocalVar, string personId);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -184,8 +201,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="personId">The id of the person to retrieve</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Person"/></returns>
|
||||
public async Task<ApiResponse<Person>?> ListOrDefaultAsync(string personId, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IListApiResponse"/>></returns>
|
||||
public async Task<IListApiResponse?> ListOrDefaultAsync(string personId, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -203,8 +220,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="personId">The id of the person to retrieve</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Person"/></returns>
|
||||
public async Task<ApiResponse<Person>> ListAsync(string personId, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IListApiResponse"/>></returns>
|
||||
public async Task<IListApiResponse> ListAsync(string personId, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -241,7 +258,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<Person> apiResponseLocalVar = new ApiResponse<Person>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/person/display/{personId}", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<ListApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<ListApiResponse>();
|
||||
|
||||
ListApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/person/display/{personId}", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterListDefaultImplementation(apiResponseLocalVar, personId);
|
||||
|
||||
@@ -258,5 +277,82 @@ namespace Org.OpenAPITools.Api
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ListApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class ListApiResponse : Org.OpenAPITools.Client.ApiResponse, IListApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<ListApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ListApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public ListApiResponse(ILogger<ListApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Org.OpenAPITools.Model.Person? Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.Person>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.Person? result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,18 +5,18 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// Useful for tracking server health
|
||||
/// </summary>
|
||||
public class ApiResponseEventArgs<T> : EventArgs
|
||||
public class ApiResponseEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// The ApiResponse
|
||||
/// </summary>
|
||||
public ApiResponse<T> ApiResponse { get; }
|
||||
public ApiResponse ApiResponse { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The ApiResponseEventArgs
|
||||
/// </summary>
|
||||
/// <param name="apiResponse"></param>
|
||||
public ApiResponseEventArgs(ApiResponse<T> apiResponse)
|
||||
public ApiResponseEventArgs(ApiResponse apiResponse)
|
||||
{
|
||||
ApiResponse = apiResponse;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
|
||||
@@ -20,15 +19,15 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// Provides a non-generic contract for the ApiResponse wrapper.
|
||||
/// </summary>
|
||||
public interface IApiResponse
|
||||
public partial interface IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The type that represents the server's response.
|
||||
/// The IsSuccessStatusCode from the api response
|
||||
/// </summary>
|
||||
Type ResponseType { get; }
|
||||
bool IsSuccessStatusCode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the status code (HTTP status code)
|
||||
/// Gets the status code (HTTP status code)
|
||||
/// </summary>
|
||||
/// <value>The status code.</value>
|
||||
HttpStatusCode StatusCode { get; }
|
||||
@@ -43,11 +42,26 @@ namespace Org.OpenAPITools.Client
|
||||
/// </summary>
|
||||
DateTime DownloadedAt { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The headers contained in the api response
|
||||
/// </summary>
|
||||
System.Net.Http.Headers.HttpResponseHeaders Headers { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The path used when making the request.
|
||||
/// </summary>
|
||||
string Path { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The reason phrase contained in the api response
|
||||
/// </summary>
|
||||
string? ReasonPhrase { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The DateTime when the request was sent.
|
||||
/// </summary>
|
||||
DateTime RequestedAt { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The Uri used when making the request.
|
||||
/// </summary>
|
||||
@@ -57,26 +71,18 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// API Response
|
||||
/// </summary>
|
||||
public partial class ApiResponse<T> : IApiResponse
|
||||
public partial class ApiResponse : IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the status code (HTTP status code)
|
||||
/// Gets the status code (HTTP status code)
|
||||
/// </summary>
|
||||
/// <value>The status code.</value>
|
||||
public HttpStatusCode StatusCode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The type that represents the server's response.
|
||||
/// </summary>
|
||||
public Type ResponseType
|
||||
{
|
||||
get { return typeof(T); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The raw data
|
||||
/// </summary>
|
||||
public string RawContent { get; private set; }
|
||||
public string RawContent { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// The IsSuccessStatusCode from the api response
|
||||
@@ -114,9 +120,9 @@ namespace Org.OpenAPITools.Client
|
||||
public Uri? RequestUri { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The JsonSerialzierOptions
|
||||
/// The <see cref="System.Text.Json.JsonSerializerOptions"/>
|
||||
/// </summary>
|
||||
private System.Text.Json.JsonSerializerOptions _jsonSerializerOptions;
|
||||
protected System.Text.Json.JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Construct the response using an HttpResponseMessage
|
||||
@@ -142,33 +148,25 @@ namespace Org.OpenAPITools.Client
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An interface for responses of type
|
||||
/// </summary>
|
||||
/// <typeparam name="TType"></typeparam>
|
||||
public interface IOk<TType> : IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
TType Ok();
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the server's response
|
||||
/// Returns true if the response is Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
public T? AsModel()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsSuccessStatusCode
|
||||
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, _jsonSerializerOptions)
|
||||
: default(T);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true when the model can be deserialized
|
||||
/// </summary>
|
||||
public bool TryToModel([NotNullWhen(true)] out T? model)
|
||||
{
|
||||
try
|
||||
{
|
||||
model = AsModel();
|
||||
return model != null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
model = default(T);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
bool TryOk([NotNullWhen(true)]out TType? result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ namespace YourProject
|
||||
{
|
||||
var host = CreateHostBuilder(args).Build();
|
||||
var api = host.Services.GetRequiredService<IDefaultApi>();
|
||||
ApiResponse<Person> response = await api.ListAsync("todo");
|
||||
Person model = response.AsModel();
|
||||
ListApiResponse apiResponse = await api.ListAsync("todo");
|
||||
Person model = apiResponse.Ok();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args)
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
public async Task RootGetAsyncTest()
|
||||
{
|
||||
var response = await _instance.RootGetAsync();
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<Fruit>(model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json;
|
||||
using Org.OpenAPITools.Client;
|
||||
using Org.OpenAPITools.Api;
|
||||
using Org.OpenAPITools.Model;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Org.OpenAPITools.Api
|
||||
{
|
||||
@@ -43,8 +43,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<Fruit>></returns>
|
||||
Task<ApiResponse<Fruit>> RootGetAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IRootGetApiResponse"/>></returns>
|
||||
Task<IRootGetApiResponse> RootGetAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -53,29 +53,40 @@ namespace Org.OpenAPITools.Api
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>Fruit>?></returns>
|
||||
Task<ApiResponse<Fruit>?> RootGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IRootGetApiResponse"/>?></returns>
|
||||
Task<IRootGetApiResponse?> RootGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IRootGetApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IRootGetApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Org.OpenAPITools.Model.Fruit?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// This class is registered as transient.
|
||||
/// </summary>
|
||||
public class DefaultApiEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<Fruit>>? OnRootGet;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnRootGet;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorRootGet;
|
||||
|
||||
internal void ExecuteOnRootGet(ApiResponse<Fruit> apiResponse)
|
||||
internal void ExecuteOnRootGet(DefaultApi.RootGetApiResponse apiResponse)
|
||||
{
|
||||
OnRootGet?.Invoke(this, new ApiResponseEventArgs<Fruit>(apiResponse));
|
||||
OnRootGet?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorRootGet(Exception exception)
|
||||
@@ -91,6 +102,11 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
private JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The logger factory
|
||||
/// </summary>
|
||||
public ILoggerFactory LoggerFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
@@ -110,10 +126,11 @@ namespace Org.OpenAPITools.Api
|
||||
/// Initializes a new instance of the <see cref="DefaultApi"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public DefaultApi(ILogger<DefaultApi> logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents)
|
||||
public DefaultApi(ILogger<DefaultApi> logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents)
|
||||
{
|
||||
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
|
||||
Logger = logger;
|
||||
LoggerFactory = loggerFactory;
|
||||
Logger = LoggerFactory.CreateLogger<DefaultApi>();
|
||||
HttpClient = httpClient;
|
||||
Events = defaultApiEvents;
|
||||
}
|
||||
@@ -122,7 +139,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// Processes the server response
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
private void AfterRootGetDefaultImplementation(ApiResponse<Fruit> apiResponseLocalVar)
|
||||
private void AfterRootGetDefaultImplementation(IRootGetApiResponse apiResponseLocalVar)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterRootGet(ref suppressDefaultLog, apiResponseLocalVar);
|
||||
@@ -135,7 +152,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
partial void AfterRootGet(ref bool suppressDefaultLog, ApiResponse<Fruit> apiResponseLocalVar);
|
||||
partial void AfterRootGet(ref bool suppressDefaultLog, IRootGetApiResponse apiResponseLocalVar);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -164,8 +181,8 @@ namespace Org.OpenAPITools.Api
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Fruit"/></returns>
|
||||
public async Task<ApiResponse<Fruit>?> RootGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IRootGetApiResponse"/>></returns>
|
||||
public async Task<IRootGetApiResponse?> RootGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -182,8 +199,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Fruit"/></returns>
|
||||
public async Task<ApiResponse<Fruit>> RootGetAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IRootGetApiResponse"/>></returns>
|
||||
public async Task<IRootGetApiResponse> RootGetAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -215,7 +232,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<Fruit> apiResponseLocalVar = new ApiResponse<Fruit>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<RootGetApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<RootGetApiResponse>();
|
||||
|
||||
RootGetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterRootGetDefaultImplementation(apiResponseLocalVar);
|
||||
|
||||
@@ -232,5 +251,82 @@ namespace Org.OpenAPITools.Api
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="RootGetApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class RootGetApiResponse : Org.OpenAPITools.Client.ApiResponse, IRootGetApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<RootGetApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="RootGetApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public RootGetApiResponse(ILogger<RootGetApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Org.OpenAPITools.Model.Fruit? Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.Fruit>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.Fruit? result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,18 +5,18 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// Useful for tracking server health
|
||||
/// </summary>
|
||||
public class ApiResponseEventArgs<T> : EventArgs
|
||||
public class ApiResponseEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// The ApiResponse
|
||||
/// </summary>
|
||||
public ApiResponse<T> ApiResponse { get; }
|
||||
public ApiResponse ApiResponse { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The ApiResponseEventArgs
|
||||
/// </summary>
|
||||
/// <param name="apiResponse"></param>
|
||||
public ApiResponseEventArgs(ApiResponse<T> apiResponse)
|
||||
public ApiResponseEventArgs(ApiResponse apiResponse)
|
||||
{
|
||||
ApiResponse = apiResponse;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
|
||||
@@ -20,15 +19,15 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// Provides a non-generic contract for the ApiResponse wrapper.
|
||||
/// </summary>
|
||||
public interface IApiResponse
|
||||
public partial interface IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The type that represents the server's response.
|
||||
/// The IsSuccessStatusCode from the api response
|
||||
/// </summary>
|
||||
Type ResponseType { get; }
|
||||
bool IsSuccessStatusCode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the status code (HTTP status code)
|
||||
/// Gets the status code (HTTP status code)
|
||||
/// </summary>
|
||||
/// <value>The status code.</value>
|
||||
HttpStatusCode StatusCode { get; }
|
||||
@@ -43,11 +42,26 @@ namespace Org.OpenAPITools.Client
|
||||
/// </summary>
|
||||
DateTime DownloadedAt { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The headers contained in the api response
|
||||
/// </summary>
|
||||
System.Net.Http.Headers.HttpResponseHeaders Headers { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The path used when making the request.
|
||||
/// </summary>
|
||||
string Path { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The reason phrase contained in the api response
|
||||
/// </summary>
|
||||
string? ReasonPhrase { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The DateTime when the request was sent.
|
||||
/// </summary>
|
||||
DateTime RequestedAt { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The Uri used when making the request.
|
||||
/// </summary>
|
||||
@@ -57,26 +71,18 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// API Response
|
||||
/// </summary>
|
||||
public partial class ApiResponse<T> : IApiResponse
|
||||
public partial class ApiResponse : IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the status code (HTTP status code)
|
||||
/// Gets the status code (HTTP status code)
|
||||
/// </summary>
|
||||
/// <value>The status code.</value>
|
||||
public HttpStatusCode StatusCode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The type that represents the server's response.
|
||||
/// </summary>
|
||||
public Type ResponseType
|
||||
{
|
||||
get { return typeof(T); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The raw data
|
||||
/// </summary>
|
||||
public string RawContent { get; private set; }
|
||||
public string RawContent { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// The IsSuccessStatusCode from the api response
|
||||
@@ -114,9 +120,9 @@ namespace Org.OpenAPITools.Client
|
||||
public Uri? RequestUri { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The JsonSerialzierOptions
|
||||
/// The <see cref="System.Text.Json.JsonSerializerOptions"/>
|
||||
/// </summary>
|
||||
private System.Text.Json.JsonSerializerOptions _jsonSerializerOptions;
|
||||
protected System.Text.Json.JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Construct the response using an HttpResponseMessage
|
||||
@@ -142,33 +148,25 @@ namespace Org.OpenAPITools.Client
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An interface for responses of type
|
||||
/// </summary>
|
||||
/// <typeparam name="TType"></typeparam>
|
||||
public interface IOk<TType> : IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
TType Ok();
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the server's response
|
||||
/// Returns true if the response is Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
public T? AsModel()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsSuccessStatusCode
|
||||
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, _jsonSerializerOptions)
|
||||
: default(T);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true when the model can be deserialized
|
||||
/// </summary>
|
||||
public bool TryToModel([NotNullWhen(true)] out T? model)
|
||||
{
|
||||
try
|
||||
{
|
||||
model = AsModel();
|
||||
return model != null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
model = default(T);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
bool TryOk([NotNullWhen(true)]out TType? result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ namespace YourProject
|
||||
{
|
||||
var host = CreateHostBuilder(args).Build();
|
||||
var api = host.Services.GetRequiredService<IDefaultApi>();
|
||||
ApiResponse<Fruit> response = await api.RootGetAsync("todo");
|
||||
Fruit model = response.AsModel();
|
||||
RootGetApiResponse apiResponse = await api.RootGetAsync("todo");
|
||||
Fruit model = apiResponse.Ok();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args)
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
public async Task RootGetAsyncTest()
|
||||
{
|
||||
var response = await _instance.RootGetAsync();
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<Fruit>(model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json;
|
||||
using Org.OpenAPITools.Client;
|
||||
using Org.OpenAPITools.Api;
|
||||
using Org.OpenAPITools.Model;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Org.OpenAPITools.Api
|
||||
{
|
||||
@@ -43,8 +43,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<Fruit>></returns>
|
||||
Task<ApiResponse<Fruit>> RootGetAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IRootGetApiResponse"/>></returns>
|
||||
Task<IRootGetApiResponse> RootGetAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -53,29 +53,40 @@ namespace Org.OpenAPITools.Api
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>Fruit>?></returns>
|
||||
Task<ApiResponse<Fruit>?> RootGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IRootGetApiResponse"/>?></returns>
|
||||
Task<IRootGetApiResponse?> RootGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IRootGetApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IRootGetApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Org.OpenAPITools.Model.Fruit?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// This class is registered as transient.
|
||||
/// </summary>
|
||||
public class DefaultApiEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<Fruit>>? OnRootGet;
|
||||
public event EventHandler<ApiResponseEventArgs>? OnRootGet;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs>? OnErrorRootGet;
|
||||
|
||||
internal void ExecuteOnRootGet(ApiResponse<Fruit> apiResponse)
|
||||
internal void ExecuteOnRootGet(DefaultApi.RootGetApiResponse apiResponse)
|
||||
{
|
||||
OnRootGet?.Invoke(this, new ApiResponseEventArgs<Fruit>(apiResponse));
|
||||
OnRootGet?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorRootGet(Exception exception)
|
||||
@@ -91,6 +102,11 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
private JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The logger factory
|
||||
/// </summary>
|
||||
public ILoggerFactory LoggerFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
@@ -110,10 +126,11 @@ namespace Org.OpenAPITools.Api
|
||||
/// Initializes a new instance of the <see cref="DefaultApi"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public DefaultApi(ILogger<DefaultApi> logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents)
|
||||
public DefaultApi(ILogger<DefaultApi> logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents)
|
||||
{
|
||||
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
|
||||
Logger = logger;
|
||||
LoggerFactory = loggerFactory;
|
||||
Logger = LoggerFactory.CreateLogger<DefaultApi>();
|
||||
HttpClient = httpClient;
|
||||
Events = defaultApiEvents;
|
||||
}
|
||||
@@ -122,7 +139,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// Processes the server response
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
private void AfterRootGetDefaultImplementation(ApiResponse<Fruit> apiResponseLocalVar)
|
||||
private void AfterRootGetDefaultImplementation(IRootGetApiResponse apiResponseLocalVar)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterRootGet(ref suppressDefaultLog, apiResponseLocalVar);
|
||||
@@ -135,7 +152,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
partial void AfterRootGet(ref bool suppressDefaultLog, ApiResponse<Fruit> apiResponseLocalVar);
|
||||
partial void AfterRootGet(ref bool suppressDefaultLog, IRootGetApiResponse apiResponseLocalVar);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -164,8 +181,8 @@ namespace Org.OpenAPITools.Api
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Fruit"/></returns>
|
||||
public async Task<ApiResponse<Fruit>?> RootGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IRootGetApiResponse"/>></returns>
|
||||
public async Task<IRootGetApiResponse?> RootGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -182,8 +199,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Fruit"/></returns>
|
||||
public async Task<ApiResponse<Fruit>> RootGetAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IRootGetApiResponse"/>></returns>
|
||||
public async Task<IRootGetApiResponse> RootGetAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -215,7 +232,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
ApiResponse<Fruit> apiResponseLocalVar = new ApiResponse<Fruit>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<RootGetApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<RootGetApiResponse>();
|
||||
|
||||
RootGetApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterRootGetDefaultImplementation(apiResponseLocalVar);
|
||||
|
||||
@@ -232,5 +251,82 @@ namespace Org.OpenAPITools.Api
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="RootGetApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class RootGetApiResponse : Org.OpenAPITools.Client.ApiResponse, IRootGetApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<RootGetApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="RootGetApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public RootGetApiResponse(ILogger<RootGetApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Org.OpenAPITools.Model.Fruit? Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.Fruit>(RawContent, _jsonSerializerOptions)
|
||||
: null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk([NotNullWhen(true)]out Org.OpenAPITools.Model.Fruit? result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,18 +5,18 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// Useful for tracking server health
|
||||
/// </summary>
|
||||
public class ApiResponseEventArgs<T> : EventArgs
|
||||
public class ApiResponseEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// The ApiResponse
|
||||
/// </summary>
|
||||
public ApiResponse<T> ApiResponse { get; }
|
||||
public ApiResponse ApiResponse { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The ApiResponseEventArgs
|
||||
/// </summary>
|
||||
/// <param name="apiResponse"></param>
|
||||
public ApiResponseEventArgs(ApiResponse<T> apiResponse)
|
||||
public ApiResponseEventArgs(ApiResponse apiResponse)
|
||||
{
|
||||
ApiResponse = apiResponse;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#nullable enable
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Net;
|
||||
|
||||
@@ -20,15 +19,15 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// Provides a non-generic contract for the ApiResponse wrapper.
|
||||
/// </summary>
|
||||
public interface IApiResponse
|
||||
public partial interface IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The type that represents the server's response.
|
||||
/// The IsSuccessStatusCode from the api response
|
||||
/// </summary>
|
||||
Type ResponseType { get; }
|
||||
bool IsSuccessStatusCode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the status code (HTTP status code)
|
||||
/// Gets the status code (HTTP status code)
|
||||
/// </summary>
|
||||
/// <value>The status code.</value>
|
||||
HttpStatusCode StatusCode { get; }
|
||||
@@ -43,11 +42,26 @@ namespace Org.OpenAPITools.Client
|
||||
/// </summary>
|
||||
DateTime DownloadedAt { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The headers contained in the api response
|
||||
/// </summary>
|
||||
System.Net.Http.Headers.HttpResponseHeaders Headers { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The path used when making the request.
|
||||
/// </summary>
|
||||
string Path { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The reason phrase contained in the api response
|
||||
/// </summary>
|
||||
string? ReasonPhrase { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The DateTime when the request was sent.
|
||||
/// </summary>
|
||||
DateTime RequestedAt { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The Uri used when making the request.
|
||||
/// </summary>
|
||||
@@ -57,26 +71,18 @@ namespace Org.OpenAPITools.Client
|
||||
/// <summary>
|
||||
/// API Response
|
||||
/// </summary>
|
||||
public partial class ApiResponse<T> : IApiResponse
|
||||
public partial class ApiResponse : IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the status code (HTTP status code)
|
||||
/// Gets the status code (HTTP status code)
|
||||
/// </summary>
|
||||
/// <value>The status code.</value>
|
||||
public HttpStatusCode StatusCode { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The type that represents the server's response.
|
||||
/// </summary>
|
||||
public Type ResponseType
|
||||
{
|
||||
get { return typeof(T); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The raw data
|
||||
/// </summary>
|
||||
public string RawContent { get; private set; }
|
||||
public string RawContent { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// The IsSuccessStatusCode from the api response
|
||||
@@ -114,9 +120,9 @@ namespace Org.OpenAPITools.Client
|
||||
public Uri? RequestUri { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The JsonSerialzierOptions
|
||||
/// The <see cref="System.Text.Json.JsonSerializerOptions"/>
|
||||
/// </summary>
|
||||
private System.Text.Json.JsonSerializerOptions _jsonSerializerOptions;
|
||||
protected System.Text.Json.JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// Construct the response using an HttpResponseMessage
|
||||
@@ -142,33 +148,25 @@ namespace Org.OpenAPITools.Client
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An interface for responses of type
|
||||
/// </summary>
|
||||
/// <typeparam name="TType"></typeparam>
|
||||
public interface IOk<TType> : IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
TType Ok();
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the server's response
|
||||
/// Returns true if the response is Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
public T? AsModel()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsSuccessStatusCode
|
||||
? System.Text.Json.JsonSerializer.Deserialize<T>(RawContent, _jsonSerializerOptions)
|
||||
: default(T);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true when the model can be deserialized
|
||||
/// </summary>
|
||||
public bool TryToModel([NotNullWhen(true)] out T? model)
|
||||
{
|
||||
try
|
||||
{
|
||||
model = AsModel();
|
||||
return model != null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
model = default(T);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
bool TryOk([NotNullWhen(true)]out TType? result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,8 +61,8 @@ namespace YourProject
|
||||
{
|
||||
var host = CreateHostBuilder(args).Build();
|
||||
var api = host.Services.GetRequiredService<IDefaultApi>();
|
||||
ApiResponse<Fruit> response = await api.RootGetAsync("todo");
|
||||
Fruit model = response.AsModel();
|
||||
RootGetApiResponse apiResponse = await api.RootGetAsync("todo");
|
||||
Fruit model = apiResponse.Ok();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args)
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
ModelClient modelClient = default;
|
||||
var response = await _instance.Call123TestSpecialTagsAsync(modelClient);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<ModelClient>(model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
public async Task FooGetAsyncTest()
|
||||
{
|
||||
var response = await _instance.FooGetAsync();
|
||||
var model = response.AsModel();
|
||||
var model = response.Default();
|
||||
Assert.IsType<FooGetDefaultResponse>(model);
|
||||
}
|
||||
|
||||
@@ -78,8 +78,30 @@ namespace Org.OpenAPITools.Test.Api
|
||||
public async Task HelloAsyncTest()
|
||||
{
|
||||
var response = await _instance.HelloAsync();
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<List<Guid>>(model);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test RolesReportGet
|
||||
/// </summary>
|
||||
[Fact (Skip = "not implemented")]
|
||||
public async Task RolesReportGetAsyncTest()
|
||||
{
|
||||
var response = await _instance.RolesReportGetAsync();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<List<List<RolesReportsHash>>>(model);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test Test
|
||||
/// </summary>
|
||||
[Fact (Skip = "not implemented")]
|
||||
public async Task TestAsyncTest()
|
||||
{
|
||||
var response = await _instance.TestAsync();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<NotificationtestGetElementsV1ResponseMPayload>(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
public async Task FakeHealthGetAsyncTest()
|
||||
{
|
||||
var response = await _instance.FakeHealthGetAsync();
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<HealthCheckResult>(model);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
Client.Option<bool> body = default;
|
||||
var response = await _instance.FakeOuterBooleanSerializeAsync(body);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<bool>(model);
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
Client.Option<OuterComposite> outerComposite = default;
|
||||
var response = await _instance.FakeOuterCompositeSerializeAsync(outerComposite);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<OuterComposite>(model);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
Client.Option<decimal> body = default;
|
||||
var response = await _instance.FakeOuterNumberSerializeAsync(body);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<decimal>(model);
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
Guid requiredStringUuid = default;
|
||||
Client.Option<string> body = default;
|
||||
var response = await _instance.FakeOuterStringSerializeAsync(requiredStringUuid, body);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<string>(model);
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
public async Task GetArrayOfEnumsAsyncTest()
|
||||
{
|
||||
var response = await _instance.GetArrayOfEnumsAsync();
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<List<OuterEnum>>(model);
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
ModelClient modelClient = default;
|
||||
var response = await _instance.TestClientModelAsync(modelClient);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<ModelClient>(model);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
ModelClient modelClient = default;
|
||||
var response = await _instance.TestClassnameAsync(modelClient);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<ModelClient>(model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
List<string> status = default;
|
||||
var response = await _instance.FindPetsByStatusAsync(status);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<List<Pet>>(model);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
List<string> tags = default;
|
||||
var response = await _instance.FindPetsByTagsAsync(tags);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<List<Pet>>(model);
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
long petId = default;
|
||||
var response = await _instance.GetPetByIdAsync(petId);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<Pet>(model);
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
Client.Option<System.IO.Stream> file = default;
|
||||
Client.Option<string> additionalMetadata = default;
|
||||
var response = await _instance.UploadFileAsync(petId, file, additionalMetadata);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<ApiResponse>(model);
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
long petId = default;
|
||||
Client.Option<string> additionalMetadata = default;
|
||||
var response = await _instance.UploadFileWithRequiredFileAsync(requiredFile, petId, additionalMetadata);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<ApiResponse>(model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
public async Task GetInventoryAsyncTest()
|
||||
{
|
||||
var response = await _instance.GetInventoryAsync();
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<Dictionary<string, int>>(model);
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
long orderId = default;
|
||||
var response = await _instance.GetOrderByIdAsync(orderId);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<Order>(model);
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
Order order = default;
|
||||
var response = await _instance.PlaceOrderAsync(order);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<Order>(model);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
{
|
||||
string username = default;
|
||||
var response = await _instance.GetUserByNameAsync(username);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<User>(model);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace Org.OpenAPITools.Test.Api
|
||||
string username = default;
|
||||
string password = default;
|
||||
var response = await _instance.LoginUserAsync(username, password);
|
||||
var model = response.AsModel();
|
||||
var model = response.Ok();
|
||||
Assert.IsType<string>(model);
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,15 @@ namespace Org.OpenAPITools.Test.Model
|
||||
//Assert.IsType<Apple>(instance);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'ColorCode'
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void ColorCodeTest()
|
||||
{
|
||||
// TODO unit test for the property 'ColorCode'
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Test the property 'Cultivar'
|
||||
/// </summary>
|
||||
|
||||
@@ -17,7 +17,6 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json;
|
||||
using Org.OpenAPITools.Client;
|
||||
using Org.OpenAPITools.Api;
|
||||
using Org.OpenAPITools.Model;
|
||||
|
||||
namespace Org.OpenAPITools.Api
|
||||
@@ -42,8 +41,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<ModelClient>></returns>
|
||||
Task<ApiResponse<ModelClient>> Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="ICall123TestSpecialTagsApiResponse"/>></returns>
|
||||
Task<ICall123TestSpecialTagsApiResponse> Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// To test special tags
|
||||
@@ -53,29 +52,40 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>ModelClient>></returns>
|
||||
Task<ApiResponse<ModelClient>> Call123TestSpecialTagsOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="ICall123TestSpecialTagsApiResponse"/>></returns>
|
||||
Task<ICall123TestSpecialTagsApiResponse> Call123TestSpecialTagsOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ICall123TestSpecialTagsApiResponse"/>
|
||||
/// </summary>
|
||||
public interface ICall123TestSpecialTagsApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Org.OpenAPITools.Model.ModelClient>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// This class is registered as transient.
|
||||
/// </summary>
|
||||
public class AnotherFakeApiEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<ModelClient>> OnCall123TestSpecialTags;
|
||||
public event EventHandler<ApiResponseEventArgs> OnCall123TestSpecialTags;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs> OnErrorCall123TestSpecialTags;
|
||||
|
||||
internal void ExecuteOnCall123TestSpecialTags(ApiResponse<ModelClient> apiResponse)
|
||||
internal void ExecuteOnCall123TestSpecialTags(AnotherFakeApi.Call123TestSpecialTagsApiResponse apiResponse)
|
||||
{
|
||||
OnCall123TestSpecialTags?.Invoke(this, new ApiResponseEventArgs<ModelClient>(apiResponse));
|
||||
OnCall123TestSpecialTags?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorCall123TestSpecialTags(Exception exception)
|
||||
@@ -91,6 +101,11 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
private JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The logger factory
|
||||
/// </summary>
|
||||
public ILoggerFactory LoggerFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
@@ -135,7 +150,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// Initializes a new instance of the <see cref="AnotherFakeApi"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public AnotherFakeApi(ILogger<AnotherFakeApi> logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, AnotherFakeApiEvents anotherFakeApiEvents,
|
||||
public AnotherFakeApi(ILogger<AnotherFakeApi> logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, AnotherFakeApiEvents anotherFakeApiEvents,
|
||||
TokenProvider<ApiKeyToken> apiKeyProvider,
|
||||
TokenProvider<BearerToken> bearerTokenProvider,
|
||||
TokenProvider<BasicToken> basicTokenProvider,
|
||||
@@ -143,7 +158,8 @@ namespace Org.OpenAPITools.Api
|
||||
TokenProvider<OAuthToken> oauthTokenProvider)
|
||||
{
|
||||
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
|
||||
Logger = logger;
|
||||
LoggerFactory = loggerFactory;
|
||||
Logger = LoggerFactory.CreateLogger<AnotherFakeApi>();
|
||||
HttpClient = httpClient;
|
||||
Events = anotherFakeApiEvents;
|
||||
ApiKeyProvider = apiKeyProvider;
|
||||
@@ -171,7 +187,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="modelClient"></param>
|
||||
private void AfterCall123TestSpecialTagsDefaultImplementation(ApiResponse<ModelClient> apiResponseLocalVar, ModelClient modelClient)
|
||||
private void AfterCall123TestSpecialTagsDefaultImplementation(ICall123TestSpecialTagsApiResponse apiResponseLocalVar, ModelClient modelClient)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterCall123TestSpecialTags(ref suppressDefaultLog, apiResponseLocalVar, modelClient);
|
||||
@@ -185,7 +201,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="modelClient"></param>
|
||||
partial void AfterCall123TestSpecialTags(ref bool suppressDefaultLog, ApiResponse<ModelClient> apiResponseLocalVar, ModelClient modelClient);
|
||||
partial void AfterCall123TestSpecialTags(ref bool suppressDefaultLog, ICall123TestSpecialTagsApiResponse apiResponseLocalVar, ModelClient modelClient);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -217,8 +233,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="ModelClient"/></returns>
|
||||
public async Task<ApiResponse<ModelClient>> Call123TestSpecialTagsOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="ICall123TestSpecialTagsApiResponse"/>></returns>
|
||||
public async Task<ICall123TestSpecialTagsApiResponse> Call123TestSpecialTagsOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -236,8 +252,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="ModelClient"/></returns>
|
||||
public async Task<ApiResponse<ModelClient>> Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="ICall123TestSpecialTagsApiResponse"/>></returns>
|
||||
public async Task<ICall123TestSpecialTagsApiResponse> Call123TestSpecialTagsAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -285,7 +301,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
ApiResponse<ModelClient> apiResponseLocalVar = new ApiResponse<ModelClient>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/another-fake/dummy", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<Call123TestSpecialTagsApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<Call123TestSpecialTagsApiResponse>();
|
||||
|
||||
Call123TestSpecialTagsApiResponse apiResponseLocalVar = new Call123TestSpecialTagsApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/another-fake/dummy", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterCall123TestSpecialTagsDefaultImplementation(apiResponseLocalVar, modelClient);
|
||||
|
||||
@@ -302,5 +320,82 @@ namespace Org.OpenAPITools.Api
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Call123TestSpecialTagsApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class Call123TestSpecialTagsApiResponse : Org.OpenAPITools.Client.ApiResponse, ICall123TestSpecialTagsApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<Call123TestSpecialTagsApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Call123TestSpecialTagsApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public Call123TestSpecialTagsApiResponse(ILogger<Call123TestSpecialTagsApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Org.OpenAPITools.Model.ModelClient Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.ModelClient>(RawContent, _jsonSerializerOptions)
|
||||
: default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk(out Org.OpenAPITools.Model.ModelClient result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json;
|
||||
using Org.OpenAPITools.Client;
|
||||
using Org.OpenAPITools.Api;
|
||||
using Org.OpenAPITools.Model;
|
||||
|
||||
namespace Org.OpenAPITools.Api
|
||||
@@ -41,8 +40,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<FooGetDefaultResponse>></returns>
|
||||
Task<ApiResponse<FooGetDefaultResponse>> FooGetAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IFooGetApiResponse"/>></returns>
|
||||
Task<IFooGetApiResponse> FooGetAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -51,8 +50,8 @@ namespace Org.OpenAPITools.Api
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>FooGetDefaultResponse>></returns>
|
||||
Task<ApiResponse<FooGetDefaultResponse>> FooGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IFooGetApiResponse"/>></returns>
|
||||
Task<IFooGetApiResponse> FooGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -63,8 +62,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="country"></param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<object>></returns>
|
||||
Task<ApiResponse<object>> GetCountryAsync(string country, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IGetCountryApiResponse"/>></returns>
|
||||
Task<IGetCountryApiResponse> GetCountryAsync(string country, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -74,8 +73,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <param name="country"></param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>object>></returns>
|
||||
Task<ApiResponse<object>> GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IGetCountryApiResponse"/>></returns>
|
||||
Task<IGetCountryApiResponse> GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Hello
|
||||
@@ -85,8 +84,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<List<Guid>>></returns>
|
||||
Task<ApiResponse<List<Guid>>> HelloAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IHelloApiResponse"/>></returns>
|
||||
Task<IHelloApiResponse> HelloAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Hello
|
||||
@@ -95,8 +94,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// Hello
|
||||
/// </remarks>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>List<Guid>>></returns>
|
||||
Task<ApiResponse<List<Guid>>> HelloOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IHelloApiResponse"/>></returns>
|
||||
Task<IHelloApiResponse> HelloOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -106,8 +105,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<List<List<RolesReportsHash>>>></returns>
|
||||
Task<ApiResponse<List<List<RolesReportsHash>>>> RolesReportGetAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IRolesReportGetApiResponse"/>></returns>
|
||||
Task<IRolesReportGetApiResponse> RolesReportGetAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
@@ -116,8 +115,8 @@ namespace Org.OpenAPITools.Api
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>List<List<RolesReportsHash>>>></returns>
|
||||
Task<ApiResponse<List<List<RolesReportsHash>>>> RolesReportGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IRolesReportGetApiResponse"/>></returns>
|
||||
Task<IRolesReportGetApiResponse> RolesReportGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve an existing Notificationtest's Elements
|
||||
@@ -127,8 +126,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<NotificationtestGetElementsV1ResponseMPayload>></returns>
|
||||
Task<ApiResponse<NotificationtestGetElementsV1ResponseMPayload>> TestAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="ITestApiResponse"/>></returns>
|
||||
Task<ITestApiResponse> TestAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieve an existing Notificationtest's Elements
|
||||
@@ -137,29 +136,88 @@ namespace Org.OpenAPITools.Api
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>NotificationtestGetElementsV1ResponseMPayload>></returns>
|
||||
Task<ApiResponse<NotificationtestGetElementsV1ResponseMPayload>> TestOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="ITestApiResponse"/>></returns>
|
||||
Task<ITestApiResponse> TestOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IFooGetApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IFooGetApiResponse : Org.OpenAPITools.Client.IApiResponse, IDefault<Org.OpenAPITools.Model.FooGetDefaultResponse>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is the default response type
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsDefault { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IGetCountryApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IGetCountryApiResponse : Org.OpenAPITools.Client.IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IHelloApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IHelloApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<List<Guid>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IRolesReportGetApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IRolesReportGetApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<List<List>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ITestApiResponse"/>
|
||||
/// </summary>
|
||||
public interface ITestApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// This class is registered as transient.
|
||||
/// </summary>
|
||||
public class DefaultApiEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<FooGetDefaultResponse>> OnFooGet;
|
||||
public event EventHandler<ApiResponseEventArgs> OnFooGet;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs> OnErrorFooGet;
|
||||
|
||||
internal void ExecuteOnFooGet(ApiResponse<FooGetDefaultResponse> apiResponse)
|
||||
internal void ExecuteOnFooGet(DefaultApi.FooGetApiResponse apiResponse)
|
||||
{
|
||||
OnFooGet?.Invoke(this, new ApiResponseEventArgs<FooGetDefaultResponse>(apiResponse));
|
||||
OnFooGet?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorFooGet(Exception exception)
|
||||
@@ -170,16 +228,16 @@ namespace Org.OpenAPITools.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<object>> OnGetCountry;
|
||||
public event EventHandler<ApiResponseEventArgs> OnGetCountry;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs> OnErrorGetCountry;
|
||||
|
||||
internal void ExecuteOnGetCountry(ApiResponse<object> apiResponse)
|
||||
internal void ExecuteOnGetCountry(DefaultApi.GetCountryApiResponse apiResponse)
|
||||
{
|
||||
OnGetCountry?.Invoke(this, new ApiResponseEventArgs<object>(apiResponse));
|
||||
OnGetCountry?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorGetCountry(Exception exception)
|
||||
@@ -190,16 +248,16 @@ namespace Org.OpenAPITools.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<List<Guid>>> OnHello;
|
||||
public event EventHandler<ApiResponseEventArgs> OnHello;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs> OnErrorHello;
|
||||
|
||||
internal void ExecuteOnHello(ApiResponse<List<Guid>> apiResponse)
|
||||
internal void ExecuteOnHello(DefaultApi.HelloApiResponse apiResponse)
|
||||
{
|
||||
OnHello?.Invoke(this, new ApiResponseEventArgs<List<Guid>>(apiResponse));
|
||||
OnHello?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorHello(Exception exception)
|
||||
@@ -210,16 +268,16 @@ namespace Org.OpenAPITools.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<List<List<RolesReportsHash>>>> OnRolesReportGet;
|
||||
public event EventHandler<ApiResponseEventArgs> OnRolesReportGet;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs> OnErrorRolesReportGet;
|
||||
|
||||
internal void ExecuteOnRolesReportGet(ApiResponse<List<List<RolesReportsHash>>> apiResponse)
|
||||
internal void ExecuteOnRolesReportGet(DefaultApi.RolesReportGetApiResponse apiResponse)
|
||||
{
|
||||
OnRolesReportGet?.Invoke(this, new ApiResponseEventArgs<List<List<RolesReportsHash>>>(apiResponse));
|
||||
OnRolesReportGet?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorRolesReportGet(Exception exception)
|
||||
@@ -230,16 +288,16 @@ namespace Org.OpenAPITools.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<NotificationtestGetElementsV1ResponseMPayload>> OnTest;
|
||||
public event EventHandler<ApiResponseEventArgs> OnTest;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs> OnErrorTest;
|
||||
|
||||
internal void ExecuteOnTest(ApiResponse<NotificationtestGetElementsV1ResponseMPayload> apiResponse)
|
||||
internal void ExecuteOnTest(DefaultApi.TestApiResponse apiResponse)
|
||||
{
|
||||
OnTest?.Invoke(this, new ApiResponseEventArgs<NotificationtestGetElementsV1ResponseMPayload>(apiResponse));
|
||||
OnTest?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorTest(Exception exception)
|
||||
@@ -255,6 +313,11 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
private JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The logger factory
|
||||
/// </summary>
|
||||
public ILoggerFactory LoggerFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
@@ -299,7 +362,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// Initializes a new instance of the <see cref="DefaultApi"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public DefaultApi(ILogger<DefaultApi> logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents,
|
||||
public DefaultApi(ILogger<DefaultApi> logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, DefaultApiEvents defaultApiEvents,
|
||||
TokenProvider<ApiKeyToken> apiKeyProvider,
|
||||
TokenProvider<BearerToken> bearerTokenProvider,
|
||||
TokenProvider<BasicToken> basicTokenProvider,
|
||||
@@ -307,7 +370,8 @@ namespace Org.OpenAPITools.Api
|
||||
TokenProvider<OAuthToken> oauthTokenProvider)
|
||||
{
|
||||
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
|
||||
Logger = logger;
|
||||
LoggerFactory = loggerFactory;
|
||||
Logger = LoggerFactory.CreateLogger<DefaultApi>();
|
||||
HttpClient = httpClient;
|
||||
Events = defaultApiEvents;
|
||||
ApiKeyProvider = apiKeyProvider;
|
||||
@@ -321,7 +385,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// Processes the server response
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
private void AfterFooGetDefaultImplementation(ApiResponse<FooGetDefaultResponse> apiResponseLocalVar)
|
||||
private void AfterFooGetDefaultImplementation(IFooGetApiResponse apiResponseLocalVar)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterFooGet(ref suppressDefaultLog, apiResponseLocalVar);
|
||||
@@ -334,7 +398,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
partial void AfterFooGet(ref bool suppressDefaultLog, ApiResponse<FooGetDefaultResponse> apiResponseLocalVar);
|
||||
partial void AfterFooGet(ref bool suppressDefaultLog, IFooGetApiResponse apiResponseLocalVar);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -363,8 +427,8 @@ namespace Org.OpenAPITools.Api
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="FooGetDefaultResponse"/></returns>
|
||||
public async Task<ApiResponse<FooGetDefaultResponse>> FooGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IFooGetApiResponse"/>></returns>
|
||||
public async Task<IFooGetApiResponse> FooGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -381,8 +445,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="FooGetDefaultResponse"/></returns>
|
||||
public async Task<ApiResponse<FooGetDefaultResponse>> FooGetAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IFooGetApiResponse"/>></returns>
|
||||
public async Task<IFooGetApiResponse> FooGetAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -413,7 +477,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
ApiResponse<FooGetDefaultResponse> apiResponseLocalVar = new ApiResponse<FooGetDefaultResponse>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/foo", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<FooGetApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<FooGetApiResponse>();
|
||||
|
||||
FooGetApiResponse apiResponseLocalVar = new FooGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/foo", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterFooGetDefaultImplementation(apiResponseLocalVar);
|
||||
|
||||
@@ -431,6 +497,83 @@ namespace Org.OpenAPITools.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="FooGetApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class FooGetApiResponse : Org.OpenAPITools.Client.ApiResponse, IFooGetApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<FooGetApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="FooGetApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public FooGetApiResponse(ILogger<FooGetApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is the default response type
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsDefault => true;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 0 Default
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Org.OpenAPITools.Model.FooGetDefaultResponse Default()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsDefault
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.FooGetDefaultResponse>(RawContent, _jsonSerializerOptions)
|
||||
: default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 0 Default and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryDefault(out Org.OpenAPITools.Model.FooGetDefaultResponse result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Default();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)0);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
partial void FormatGetCountry(ref string country);
|
||||
|
||||
/// <summary>
|
||||
@@ -449,7 +592,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="country"></param>
|
||||
private void AfterGetCountryDefaultImplementation(ApiResponse<object> apiResponseLocalVar, string country)
|
||||
private void AfterGetCountryDefaultImplementation(IGetCountryApiResponse apiResponseLocalVar, string country)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterGetCountry(ref suppressDefaultLog, apiResponseLocalVar, country);
|
||||
@@ -463,7 +606,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="country"></param>
|
||||
partial void AfterGetCountry(ref bool suppressDefaultLog, ApiResponse<object> apiResponseLocalVar, string country);
|
||||
partial void AfterGetCountry(ref bool suppressDefaultLog, IGetCountryApiResponse apiResponseLocalVar, string country);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -495,8 +638,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="country"></param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="object"/></returns>
|
||||
public async Task<ApiResponse<object>> GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IGetCountryApiResponse"/>></returns>
|
||||
public async Task<IGetCountryApiResponse> GetCountryOrDefaultAsync(string country, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -514,8 +657,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="country"></param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="object"/></returns>
|
||||
public async Task<ApiResponse<object>> GetCountryAsync(string country, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IGetCountryApiResponse"/>></returns>
|
||||
public async Task<IGetCountryApiResponse> GetCountryAsync(string country, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -561,7 +704,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
ApiResponse<object> apiResponseLocalVar = new ApiResponse<object>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/country", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<GetCountryApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<GetCountryApiResponse>();
|
||||
|
||||
GetCountryApiResponse apiResponseLocalVar = new GetCountryApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/country", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterGetCountryDefaultImplementation(apiResponseLocalVar, country);
|
||||
|
||||
@@ -579,11 +724,56 @@ namespace Org.OpenAPITools.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GetCountryApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class GetCountryApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetCountryApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<GetCountryApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GetCountryApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public GetCountryApiResponse(ILogger<GetCountryApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes the server response
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
private void AfterHelloDefaultImplementation(ApiResponse<List<Guid>> apiResponseLocalVar)
|
||||
private void AfterHelloDefaultImplementation(IHelloApiResponse apiResponseLocalVar)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterHello(ref suppressDefaultLog, apiResponseLocalVar);
|
||||
@@ -596,7 +786,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
partial void AfterHello(ref bool suppressDefaultLog, ApiResponse<List<Guid>> apiResponseLocalVar);
|
||||
partial void AfterHello(ref bool suppressDefaultLog, IHelloApiResponse apiResponseLocalVar);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -625,8 +815,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// Hello Hello
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="List{TValue}"/></returns>
|
||||
public async Task<ApiResponse<List<Guid>>> HelloOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IHelloApiResponse"/>></returns>
|
||||
public async Task<IHelloApiResponse> HelloOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -643,8 +833,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="List{TValue}"/></returns>
|
||||
public async Task<ApiResponse<List<Guid>>> HelloAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IHelloApiResponse"/>></returns>
|
||||
public async Task<IHelloApiResponse> HelloAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -675,7 +865,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
ApiResponse<List<Guid>> apiResponseLocalVar = new ApiResponse<List<Guid>>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/hello", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<HelloApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<HelloApiResponse>();
|
||||
|
||||
HelloApiResponse apiResponseLocalVar = new HelloApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/hello", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterHelloDefaultImplementation(apiResponseLocalVar);
|
||||
|
||||
@@ -693,11 +885,88 @@ namespace Org.OpenAPITools.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="HelloApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class HelloApiResponse : Org.OpenAPITools.Client.ApiResponse, IHelloApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<HelloApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="HelloApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public HelloApiResponse(ILogger<HelloApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<Guid> Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<List<Guid>>(RawContent, _jsonSerializerOptions)
|
||||
: default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk(out List<Guid> result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes the server response
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
private void AfterRolesReportGetDefaultImplementation(ApiResponse<List<List<RolesReportsHash>>> apiResponseLocalVar)
|
||||
private void AfterRolesReportGetDefaultImplementation(IRolesReportGetApiResponse apiResponseLocalVar)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterRolesReportGet(ref suppressDefaultLog, apiResponseLocalVar);
|
||||
@@ -710,7 +979,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
partial void AfterRolesReportGet(ref bool suppressDefaultLog, ApiResponse<List<List<RolesReportsHash>>> apiResponseLocalVar);
|
||||
partial void AfterRolesReportGet(ref bool suppressDefaultLog, IRolesReportGetApiResponse apiResponseLocalVar);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -739,8 +1008,8 @@ namespace Org.OpenAPITools.Api
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="List{TValue}"/></returns>
|
||||
public async Task<ApiResponse<List<List<RolesReportsHash>>>> RolesReportGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IRolesReportGetApiResponse"/>></returns>
|
||||
public async Task<IRolesReportGetApiResponse> RolesReportGetOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -757,8 +1026,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="List{TValue}"/></returns>
|
||||
public async Task<ApiResponse<List<List<RolesReportsHash>>>> RolesReportGetAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IRolesReportGetApiResponse"/>></returns>
|
||||
public async Task<IRolesReportGetApiResponse> RolesReportGetAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -789,7 +1058,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
ApiResponse<List<List<RolesReportsHash>>> apiResponseLocalVar = new ApiResponse<List<List<RolesReportsHash>>>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/roles/report", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<RolesReportGetApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<RolesReportGetApiResponse>();
|
||||
|
||||
RolesReportGetApiResponse apiResponseLocalVar = new RolesReportGetApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/roles/report", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterRolesReportGetDefaultImplementation(apiResponseLocalVar);
|
||||
|
||||
@@ -807,11 +1078,88 @@ namespace Org.OpenAPITools.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="RolesReportGetApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class RolesReportGetApiResponse : Org.OpenAPITools.Client.ApiResponse, IRolesReportGetApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<RolesReportGetApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="RolesReportGetApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public RolesReportGetApiResponse(ILogger<RolesReportGetApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<List> Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<List<List>>(RawContent, _jsonSerializerOptions)
|
||||
: default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk(out List<List> result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes the server response
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
private void AfterTestDefaultImplementation(ApiResponse<NotificationtestGetElementsV1ResponseMPayload> apiResponseLocalVar)
|
||||
private void AfterTestDefaultImplementation(ITestApiResponse apiResponseLocalVar)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterTest(ref suppressDefaultLog, apiResponseLocalVar);
|
||||
@@ -824,7 +1172,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
partial void AfterTest(ref bool suppressDefaultLog, ApiResponse<NotificationtestGetElementsV1ResponseMPayload> apiResponseLocalVar);
|
||||
partial void AfterTest(ref bool suppressDefaultLog, ITestApiResponse apiResponseLocalVar);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -853,8 +1201,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// Retrieve an existing Notificationtest's Elements
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="NotificationtestGetElementsV1ResponseMPayload"/></returns>
|
||||
public async Task<ApiResponse<NotificationtestGetElementsV1ResponseMPayload>> TestOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="ITestApiResponse"/>></returns>
|
||||
public async Task<ITestApiResponse> TestOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -871,8 +1219,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="NotificationtestGetElementsV1ResponseMPayload"/></returns>
|
||||
public async Task<ApiResponse<NotificationtestGetElementsV1ResponseMPayload>> TestAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="ITestApiResponse"/>></returns>
|
||||
public async Task<ITestApiResponse> TestAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -903,7 +1251,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
ApiResponse<NotificationtestGetElementsV1ResponseMPayload> apiResponseLocalVar = new ApiResponse<NotificationtestGetElementsV1ResponseMPayload>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/test", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<TestApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<TestApiResponse>();
|
||||
|
||||
TestApiResponse apiResponseLocalVar = new TestApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/test", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterTestDefaultImplementation(apiResponseLocalVar);
|
||||
|
||||
@@ -920,5 +1270,82 @@ namespace Org.OpenAPITools.Api
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="TestApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class TestApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<TestApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="TestApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public TestApiResponse(ILogger<TestApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload>(RawContent, _jsonSerializerOptions)
|
||||
: default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk(out Org.OpenAPITools.Model.NotificationtestGetElementsV1ResponseMPayload result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,6 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json;
|
||||
using Org.OpenAPITools.Client;
|
||||
using Org.OpenAPITools.Api;
|
||||
using Org.OpenAPITools.Model;
|
||||
|
||||
namespace Org.OpenAPITools.Api
|
||||
@@ -42,8 +41,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<ModelClient>></returns>
|
||||
Task<ApiResponse<ModelClient>> TestClassnameAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="ITestClassnameApiResponse"/>></returns>
|
||||
Task<ITestClassnameApiResponse> TestClassnameAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// To test class name in snake case
|
||||
@@ -53,29 +52,40 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>ModelClient>></returns>
|
||||
Task<ApiResponse<ModelClient>> TestClassnameOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="ITestClassnameApiResponse"/>></returns>
|
||||
Task<ITestClassnameApiResponse> TestClassnameOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ITestClassnameApiResponse"/>
|
||||
/// </summary>
|
||||
public interface ITestClassnameApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Org.OpenAPITools.Model.ModelClient>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// This class is registered as transient.
|
||||
/// </summary>
|
||||
public class FakeClassnameTags123ApiEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<ModelClient>> OnTestClassname;
|
||||
public event EventHandler<ApiResponseEventArgs> OnTestClassname;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs> OnErrorTestClassname;
|
||||
|
||||
internal void ExecuteOnTestClassname(ApiResponse<ModelClient> apiResponse)
|
||||
internal void ExecuteOnTestClassname(FakeClassnameTags123Api.TestClassnameApiResponse apiResponse)
|
||||
{
|
||||
OnTestClassname?.Invoke(this, new ApiResponseEventArgs<ModelClient>(apiResponse));
|
||||
OnTestClassname?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorTestClassname(Exception exception)
|
||||
@@ -91,6 +101,11 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
private JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The logger factory
|
||||
/// </summary>
|
||||
public ILoggerFactory LoggerFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
@@ -135,7 +150,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// Initializes a new instance of the <see cref="FakeClassnameTags123Api"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public FakeClassnameTags123Api(ILogger<FakeClassnameTags123Api> logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, FakeClassnameTags123ApiEvents fakeClassnameTags123ApiEvents,
|
||||
public FakeClassnameTags123Api(ILogger<FakeClassnameTags123Api> logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, FakeClassnameTags123ApiEvents fakeClassnameTags123ApiEvents,
|
||||
TokenProvider<ApiKeyToken> apiKeyProvider,
|
||||
TokenProvider<BearerToken> bearerTokenProvider,
|
||||
TokenProvider<BasicToken> basicTokenProvider,
|
||||
@@ -143,7 +158,8 @@ namespace Org.OpenAPITools.Api
|
||||
TokenProvider<OAuthToken> oauthTokenProvider)
|
||||
{
|
||||
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
|
||||
Logger = logger;
|
||||
LoggerFactory = loggerFactory;
|
||||
Logger = LoggerFactory.CreateLogger<FakeClassnameTags123Api>();
|
||||
HttpClient = httpClient;
|
||||
Events = fakeClassnameTags123ApiEvents;
|
||||
ApiKeyProvider = apiKeyProvider;
|
||||
@@ -171,7 +187,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="modelClient"></param>
|
||||
private void AfterTestClassnameDefaultImplementation(ApiResponse<ModelClient> apiResponseLocalVar, ModelClient modelClient)
|
||||
private void AfterTestClassnameDefaultImplementation(ITestClassnameApiResponse apiResponseLocalVar, ModelClient modelClient)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterTestClassname(ref suppressDefaultLog, apiResponseLocalVar, modelClient);
|
||||
@@ -185,7 +201,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="modelClient"></param>
|
||||
partial void AfterTestClassname(ref bool suppressDefaultLog, ApiResponse<ModelClient> apiResponseLocalVar, ModelClient modelClient);
|
||||
partial void AfterTestClassname(ref bool suppressDefaultLog, ITestClassnameApiResponse apiResponseLocalVar, ModelClient modelClient);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -217,8 +233,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="ModelClient"/></returns>
|
||||
public async Task<ApiResponse<ModelClient>> TestClassnameOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="ITestClassnameApiResponse"/>></returns>
|
||||
public async Task<ITestClassnameApiResponse> TestClassnameOrDefaultAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -236,8 +252,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="modelClient">client model</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="ModelClient"/></returns>
|
||||
public async Task<ApiResponse<ModelClient>> TestClassnameAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="ITestClassnameApiResponse"/>></returns>
|
||||
public async Task<ITestClassnameApiResponse> TestClassnameAsync(ModelClient modelClient, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -296,7 +312,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
ApiResponse<ModelClient> apiResponseLocalVar = new ApiResponse<ModelClient>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake_classname_test", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<TestClassnameApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<TestClassnameApiResponse>();
|
||||
|
||||
TestClassnameApiResponse apiResponseLocalVar = new TestClassnameApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/fake_classname_test", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterTestClassnameDefaultImplementation(apiResponseLocalVar, modelClient);
|
||||
|
||||
@@ -317,5 +335,82 @@ namespace Org.OpenAPITools.Api
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="TestClassnameApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class TestClassnameApiResponse : Org.OpenAPITools.Client.ApiResponse, ITestClassnameApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<TestClassnameApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="TestClassnameApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public TestClassnameApiResponse(ILogger<TestClassnameApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Org.OpenAPITools.Model.ModelClient Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.ModelClient>(RawContent, _jsonSerializerOptions)
|
||||
: default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk(out Org.OpenAPITools.Model.ModelClient result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,6 @@ using System.Net.Http;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text.Json;
|
||||
using Org.OpenAPITools.Client;
|
||||
using Org.OpenAPITools.Api;
|
||||
using Org.OpenAPITools.Model;
|
||||
|
||||
namespace Org.OpenAPITools.Api
|
||||
@@ -42,8 +41,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<object>></returns>
|
||||
Task<ApiResponse<object>> DeleteOrderAsync(string orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IDeleteOrderApiResponse"/>></returns>
|
||||
Task<IDeleteOrderApiResponse> DeleteOrderAsync(string orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Delete purchase order by ID
|
||||
@@ -53,8 +52,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>object>></returns>
|
||||
Task<ApiResponse<object>> DeleteOrderOrDefaultAsync(string orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IDeleteOrderApiResponse"/>></returns>
|
||||
Task<IDeleteOrderApiResponse> DeleteOrderOrDefaultAsync(string orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Returns pet inventories by status
|
||||
@@ -64,8 +63,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<Dictionary<string, int>>></returns>
|
||||
Task<ApiResponse<Dictionary<string, int>>> GetInventoryAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IGetInventoryApiResponse"/>></returns>
|
||||
Task<IGetInventoryApiResponse> GetInventoryAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Returns pet inventories by status
|
||||
@@ -74,8 +73,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// Returns a map of status codes to quantities
|
||||
/// </remarks>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>Dictionary<string, int>>></returns>
|
||||
Task<ApiResponse<Dictionary<string, int>>> GetInventoryOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IGetInventoryApiResponse"/>></returns>
|
||||
Task<IGetInventoryApiResponse> GetInventoryOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Find purchase order by ID
|
||||
@@ -86,8 +85,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<Order>></returns>
|
||||
Task<ApiResponse<Order>> GetOrderByIdAsync(long orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IGetOrderByIdApiResponse"/>></returns>
|
||||
Task<IGetOrderByIdApiResponse> GetOrderByIdAsync(long orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Find purchase order by ID
|
||||
@@ -97,8 +96,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>Order>></returns>
|
||||
Task<ApiResponse<Order>> GetOrderByIdOrDefaultAsync(long orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IGetOrderByIdApiResponse"/>></returns>
|
||||
Task<IGetOrderByIdApiResponse> GetOrderByIdOrDefaultAsync(long orderId, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Place an order for a pet
|
||||
@@ -109,8 +108,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="order">order placed for purchasing the pet</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse<Order>></returns>
|
||||
Task<ApiResponse<Order>> PlaceOrderAsync(Order order, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IPlaceOrderApiResponse"/>></returns>
|
||||
Task<IPlaceOrderApiResponse> PlaceOrderAsync(Order order, System.Threading.CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Place an order for a pet
|
||||
@@ -120,29 +119,100 @@ namespace Org.OpenAPITools.Api
|
||||
/// </remarks>
|
||||
/// <param name="order">order placed for purchasing the pet</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns>Task<ApiResponse>Order>></returns>
|
||||
Task<ApiResponse<Order>> PlaceOrderOrDefaultAsync(Order order, System.Threading.CancellationToken cancellationToken = default);
|
||||
/// <returns><see cref="Task"/><<see cref="IPlaceOrderApiResponse"/>></returns>
|
||||
Task<IPlaceOrderApiResponse> PlaceOrderOrDefaultAsync(Order order, System.Threading.CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IDeleteOrderApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IDeleteOrderApiResponse : Org.OpenAPITools.Client.IApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 400 BadRequest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsBadRequest { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 404 NotFound
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsNotFound { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IGetInventoryApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IGetInventoryApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Dictionary<string, int>>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IGetOrderByIdApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IGetOrderByIdApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Org.OpenAPITools.Model.Order>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 400 BadRequest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsBadRequest { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 404 NotFound
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsNotFound { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IPlaceOrderApiResponse"/>
|
||||
/// </summary>
|
||||
public interface IPlaceOrderApiResponse : Org.OpenAPITools.Client.IApiResponse, IOk<Org.OpenAPITools.Model.Order>
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsOk { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 400 BadRequest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool IsBadRequest { get; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a collection of functions to interact with the API endpoints
|
||||
/// This class is registered as transient.
|
||||
/// </summary>
|
||||
public class StoreApiEvents
|
||||
{
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<object>> OnDeleteOrder;
|
||||
public event EventHandler<ApiResponseEventArgs> OnDeleteOrder;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs> OnErrorDeleteOrder;
|
||||
|
||||
internal void ExecuteOnDeleteOrder(ApiResponse<object> apiResponse)
|
||||
internal void ExecuteOnDeleteOrder(StoreApi.DeleteOrderApiResponse apiResponse)
|
||||
{
|
||||
OnDeleteOrder?.Invoke(this, new ApiResponseEventArgs<object>(apiResponse));
|
||||
OnDeleteOrder?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorDeleteOrder(Exception exception)
|
||||
@@ -153,16 +223,16 @@ namespace Org.OpenAPITools.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<Dictionary<string, int>>> OnGetInventory;
|
||||
public event EventHandler<ApiResponseEventArgs> OnGetInventory;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs> OnErrorGetInventory;
|
||||
|
||||
internal void ExecuteOnGetInventory(ApiResponse<Dictionary<string, int>> apiResponse)
|
||||
internal void ExecuteOnGetInventory(StoreApi.GetInventoryApiResponse apiResponse)
|
||||
{
|
||||
OnGetInventory?.Invoke(this, new ApiResponseEventArgs<Dictionary<string, int>>(apiResponse));
|
||||
OnGetInventory?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorGetInventory(Exception exception)
|
||||
@@ -173,16 +243,16 @@ namespace Org.OpenAPITools.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<Order>> OnGetOrderById;
|
||||
public event EventHandler<ApiResponseEventArgs> OnGetOrderById;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs> OnErrorGetOrderById;
|
||||
|
||||
internal void ExecuteOnGetOrderById(ApiResponse<Order> apiResponse)
|
||||
internal void ExecuteOnGetOrderById(StoreApi.GetOrderByIdApiResponse apiResponse)
|
||||
{
|
||||
OnGetOrderById?.Invoke(this, new ApiResponseEventArgs<Order>(apiResponse));
|
||||
OnGetOrderById?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorGetOrderById(Exception exception)
|
||||
@@ -193,16 +263,16 @@ namespace Org.OpenAPITools.Api
|
||||
/// <summary>
|
||||
/// The event raised after the server response
|
||||
/// </summary>
|
||||
public event EventHandler<ApiResponseEventArgs<Order>> OnPlaceOrder;
|
||||
public event EventHandler<ApiResponseEventArgs> OnPlaceOrder;
|
||||
|
||||
/// <summary>
|
||||
/// The event raised after an error querying the server
|
||||
/// </summary>
|
||||
public event EventHandler<ExceptionEventArgs> OnErrorPlaceOrder;
|
||||
|
||||
internal void ExecuteOnPlaceOrder(ApiResponse<Order> apiResponse)
|
||||
internal void ExecuteOnPlaceOrder(StoreApi.PlaceOrderApiResponse apiResponse)
|
||||
{
|
||||
OnPlaceOrder?.Invoke(this, new ApiResponseEventArgs<Order>(apiResponse));
|
||||
OnPlaceOrder?.Invoke(this, new ApiResponseEventArgs(apiResponse));
|
||||
}
|
||||
|
||||
internal void ExecuteOnErrorPlaceOrder(Exception exception)
|
||||
@@ -218,6 +288,11 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
private JsonSerializerOptions _jsonSerializerOptions;
|
||||
|
||||
/// <summary>
|
||||
/// The logger factory
|
||||
/// </summary>
|
||||
public ILoggerFactory LoggerFactory { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
@@ -262,7 +337,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// Initializes a new instance of the <see cref="StoreApi"/> class.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public StoreApi(ILogger<StoreApi> logger, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, StoreApiEvents storeApiEvents,
|
||||
public StoreApi(ILogger<StoreApi> logger, ILoggerFactory loggerFactory, HttpClient httpClient, JsonSerializerOptionsProvider jsonSerializerOptionsProvider, StoreApiEvents storeApiEvents,
|
||||
TokenProvider<ApiKeyToken> apiKeyProvider,
|
||||
TokenProvider<BearerToken> bearerTokenProvider,
|
||||
TokenProvider<BasicToken> basicTokenProvider,
|
||||
@@ -270,7 +345,8 @@ namespace Org.OpenAPITools.Api
|
||||
TokenProvider<OAuthToken> oauthTokenProvider)
|
||||
{
|
||||
_jsonSerializerOptions = jsonSerializerOptionsProvider.Options;
|
||||
Logger = logger;
|
||||
LoggerFactory = loggerFactory;
|
||||
Logger = LoggerFactory.CreateLogger<StoreApi>();
|
||||
HttpClient = httpClient;
|
||||
Events = storeApiEvents;
|
||||
ApiKeyProvider = apiKeyProvider;
|
||||
@@ -298,7 +374,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="orderId"></param>
|
||||
private void AfterDeleteOrderDefaultImplementation(ApiResponse<object> apiResponseLocalVar, string orderId)
|
||||
private void AfterDeleteOrderDefaultImplementation(IDeleteOrderApiResponse apiResponseLocalVar, string orderId)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterDeleteOrder(ref suppressDefaultLog, apiResponseLocalVar, orderId);
|
||||
@@ -312,7 +388,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="orderId"></param>
|
||||
partial void AfterDeleteOrder(ref bool suppressDefaultLog, ApiResponse<object> apiResponseLocalVar, string orderId);
|
||||
partial void AfterDeleteOrder(ref bool suppressDefaultLog, IDeleteOrderApiResponse apiResponseLocalVar, string orderId);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -344,8 +420,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="object"/></returns>
|
||||
public async Task<ApiResponse<object>> DeleteOrderOrDefaultAsync(string orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IDeleteOrderApiResponse"/>></returns>
|
||||
public async Task<IDeleteOrderApiResponse> DeleteOrderOrDefaultAsync(string orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -363,8 +439,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="object"/></returns>
|
||||
public async Task<ApiResponse<object>> DeleteOrderAsync(string orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IDeleteOrderApiResponse"/>></returns>
|
||||
public async Task<IDeleteOrderApiResponse> DeleteOrderAsync(string orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -391,7 +467,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
ApiResponse<object> apiResponseLocalVar = new ApiResponse<object>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<DeleteOrderApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<DeleteOrderApiResponse>();
|
||||
|
||||
DeleteOrderApiResponse apiResponseLocalVar = new DeleteOrderApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterDeleteOrderDefaultImplementation(apiResponseLocalVar, orderId);
|
||||
|
||||
@@ -409,11 +487,62 @@ namespace Org.OpenAPITools.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DeleteOrderApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class DeleteOrderApiResponse : Org.OpenAPITools.Client.ApiResponse, IDeleteOrderApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<DeleteOrderApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DeleteOrderApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public DeleteOrderApiResponse(ILogger<DeleteOrderApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 400 BadRequest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsBadRequest => 400 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 404 NotFound
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsNotFound => 404 == (int)StatusCode;
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processes the server response
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
private void AfterGetInventoryDefaultImplementation(ApiResponse<Dictionary<string, int>> apiResponseLocalVar)
|
||||
private void AfterGetInventoryDefaultImplementation(IGetInventoryApiResponse apiResponseLocalVar)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterGetInventory(ref suppressDefaultLog, apiResponseLocalVar);
|
||||
@@ -426,7 +555,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
partial void AfterGetInventory(ref bool suppressDefaultLog, ApiResponse<Dictionary<string, int>> apiResponseLocalVar);
|
||||
partial void AfterGetInventory(ref bool suppressDefaultLog, IGetInventoryApiResponse apiResponseLocalVar);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -455,8 +584,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// Returns pet inventories by status Returns a map of status codes to quantities
|
||||
/// </summary>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Dictionary{TKey, TValue}"/></returns>
|
||||
public async Task<ApiResponse<Dictionary<string, int>>> GetInventoryOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IGetInventoryApiResponse"/>></returns>
|
||||
public async Task<IGetInventoryApiResponse> GetInventoryOrDefaultAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -473,8 +602,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Dictionary{TKey, TValue}"/></returns>
|
||||
public async Task<ApiResponse<Dictionary<string, int>>> GetInventoryAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IGetInventoryApiResponse"/>></returns>
|
||||
public async Task<IGetInventoryApiResponse> GetInventoryAsync(System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -513,7 +642,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
ApiResponse<Dictionary<string, int>> apiResponseLocalVar = new ApiResponse<Dictionary<string, int>>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/inventory", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<GetInventoryApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<GetInventoryApiResponse>();
|
||||
|
||||
GetInventoryApiResponse apiResponseLocalVar = new GetInventoryApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/inventory", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterGetInventoryDefaultImplementation(apiResponseLocalVar);
|
||||
|
||||
@@ -535,6 +666,83 @@ namespace Org.OpenAPITools.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GetInventoryApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class GetInventoryApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetInventoryApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<GetInventoryApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GetInventoryApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public GetInventoryApiResponse(ILogger<GetInventoryApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Dictionary<string, int> Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Dictionary<string, int>>(RawContent, _jsonSerializerOptions)
|
||||
: default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk(out Dictionary<string, int> result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
partial void FormatGetOrderById(ref long orderId);
|
||||
|
||||
/// <summary>
|
||||
@@ -542,7 +750,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="orderId"></param>
|
||||
private void AfterGetOrderByIdDefaultImplementation(ApiResponse<Order> apiResponseLocalVar, long orderId)
|
||||
private void AfterGetOrderByIdDefaultImplementation(IGetOrderByIdApiResponse apiResponseLocalVar, long orderId)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterGetOrderById(ref suppressDefaultLog, apiResponseLocalVar, orderId);
|
||||
@@ -556,7 +764,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="orderId"></param>
|
||||
partial void AfterGetOrderById(ref bool suppressDefaultLog, ApiResponse<Order> apiResponseLocalVar, long orderId);
|
||||
partial void AfterGetOrderById(ref bool suppressDefaultLog, IGetOrderByIdApiResponse apiResponseLocalVar, long orderId);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -588,8 +796,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Order"/></returns>
|
||||
public async Task<ApiResponse<Order>> GetOrderByIdOrDefaultAsync(long orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IGetOrderByIdApiResponse"/>></returns>
|
||||
public async Task<IGetOrderByIdApiResponse> GetOrderByIdOrDefaultAsync(long orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -607,8 +815,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Order"/></returns>
|
||||
public async Task<ApiResponse<Order>> GetOrderByIdAsync(long orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IGetOrderByIdApiResponse"/>></returns>
|
||||
public async Task<IGetOrderByIdApiResponse> GetOrderByIdAsync(long orderId, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -643,7 +851,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
ApiResponse<Order> apiResponseLocalVar = new ApiResponse<Order>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<GetOrderByIdApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<GetOrderByIdApiResponse>();
|
||||
|
||||
GetOrderByIdApiResponse apiResponseLocalVar = new GetOrderByIdApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order/{order_id}", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterGetOrderByIdDefaultImplementation(apiResponseLocalVar, orderId);
|
||||
|
||||
@@ -661,6 +871,95 @@ namespace Org.OpenAPITools.Api
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GetOrderByIdApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class GetOrderByIdApiResponse : Org.OpenAPITools.Client.ApiResponse, IGetOrderByIdApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<GetOrderByIdApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="GetOrderByIdApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public GetOrderByIdApiResponse(ILogger<GetOrderByIdApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Org.OpenAPITools.Model.Order Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.Order>(RawContent, _jsonSerializerOptions)
|
||||
: default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk(out Org.OpenAPITools.Model.Order result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 400 BadRequest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsBadRequest => 400 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 404 NotFound
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsNotFound => 404 == (int)StatusCode;
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
|
||||
partial void FormatPlaceOrder(Order order);
|
||||
|
||||
/// <summary>
|
||||
@@ -679,7 +978,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="order"></param>
|
||||
private void AfterPlaceOrderDefaultImplementation(ApiResponse<Order> apiResponseLocalVar, Order order)
|
||||
private void AfterPlaceOrderDefaultImplementation(IPlaceOrderApiResponse apiResponseLocalVar, Order order)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
AfterPlaceOrder(ref suppressDefaultLog, apiResponseLocalVar, order);
|
||||
@@ -693,7 +992,7 @@ namespace Org.OpenAPITools.Api
|
||||
/// <param name="suppressDefaultLog"></param>
|
||||
/// <param name="apiResponseLocalVar"></param>
|
||||
/// <param name="order"></param>
|
||||
partial void AfterPlaceOrder(ref bool suppressDefaultLog, ApiResponse<Order> apiResponseLocalVar, Order order);
|
||||
partial void AfterPlaceOrder(ref bool suppressDefaultLog, IPlaceOrderApiResponse apiResponseLocalVar, Order order);
|
||||
|
||||
/// <summary>
|
||||
/// Logs exceptions that occur while retrieving the server response
|
||||
@@ -725,8 +1024,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// </summary>
|
||||
/// <param name="order">order placed for purchasing the pet</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Order"/></returns>
|
||||
public async Task<ApiResponse<Order>> PlaceOrderOrDefaultAsync(Order order, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IPlaceOrderApiResponse"/>></returns>
|
||||
public async Task<IPlaceOrderApiResponse> PlaceOrderOrDefaultAsync(Order order, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -744,8 +1043,8 @@ namespace Org.OpenAPITools.Api
|
||||
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
|
||||
/// <param name="order">order placed for purchasing the pet</param>
|
||||
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
|
||||
/// <returns><see cref="Task"/><<see cref="ApiResponse{T}"/>> where T : <see cref="Order"/></returns>
|
||||
public async Task<ApiResponse<Order>> PlaceOrderAsync(Order order, System.Threading.CancellationToken cancellationToken = default)
|
||||
/// <returns><see cref="Task"/><<see cref="IPlaceOrderApiResponse"/>></returns>
|
||||
public async Task<IPlaceOrderApiResponse> PlaceOrderAsync(Order order, System.Threading.CancellationToken cancellationToken = default)
|
||||
{
|
||||
UriBuilder uriBuilderLocalVar = new UriBuilder();
|
||||
|
||||
@@ -794,7 +1093,9 @@ namespace Org.OpenAPITools.Api
|
||||
{
|
||||
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync().ConfigureAwait(false);
|
||||
|
||||
ApiResponse<Order> apiResponseLocalVar = new ApiResponse<Order>(httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
ILogger<PlaceOrderApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<PlaceOrderApiResponse>();
|
||||
|
||||
PlaceOrderApiResponse apiResponseLocalVar = new PlaceOrderApiResponse(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/store/order", requestedAtLocalVar, _jsonSerializerOptions);
|
||||
|
||||
AfterPlaceOrderDefaultImplementation(apiResponseLocalVar, order);
|
||||
|
||||
@@ -811,5 +1112,88 @@ namespace Org.OpenAPITools.Api
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="PlaceOrderApiResponse"/>
|
||||
/// </summary>
|
||||
public partial class PlaceOrderApiResponse : Org.OpenAPITools.Client.ApiResponse, IPlaceOrderApiResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// The logger
|
||||
/// </summary>
|
||||
public ILogger<PlaceOrderApiResponse> Logger { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="PlaceOrderApiResponse"/>
|
||||
/// </summary>
|
||||
/// <param name="logger"></param>
|
||||
/// <param name="httpRequestMessage"></param>
|
||||
/// <param name="httpResponseMessage"></param>
|
||||
/// <param name="rawContent"></param>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="requestedAt"></param>
|
||||
/// <param name="jsonSerializerOptions"></param>
|
||||
public PlaceOrderApiResponse(ILogger<PlaceOrderApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
|
||||
{
|
||||
Logger = logger;
|
||||
OnCreated(httpRequestMessage, httpResponseMessage);
|
||||
}
|
||||
|
||||
partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsOk => 200 == (int)StatusCode;
|
||||
|
||||
/// <summary>
|
||||
/// Deserializes the response if the response is 200 Ok
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public Org.OpenAPITools.Model.Order Ok()
|
||||
{
|
||||
// This logic may be modified with the AsModel.mustache template
|
||||
return IsOk
|
||||
? System.Text.Json.JsonSerializer.Deserialize<Org.OpenAPITools.Model.Order>(RawContent, _jsonSerializerOptions)
|
||||
: default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 200 Ok and the deserialized response is not null
|
||||
/// </summary>
|
||||
/// <param name="result"></param>
|
||||
/// <returns></returns>
|
||||
public bool TryOk(out Org.OpenAPITools.Model.Order result)
|
||||
{
|
||||
result = null;
|
||||
|
||||
try
|
||||
{
|
||||
result = Ok();
|
||||
} catch (Exception e)
|
||||
{
|
||||
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
|
||||
}
|
||||
|
||||
return result != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the response is 400 BadRequest
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool IsBadRequest => 400 == (int)StatusCode;
|
||||
|
||||
private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
|
||||
{
|
||||
bool suppressDefaultLog = false;
|
||||
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
|
||||
if (!suppressDefaultLog)
|
||||
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
|
||||
}
|
||||
|
||||
partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user