Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions DocRaptor.sln
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
VisualStudioVersion = 12.0.0.0
MinimumVisualStudioVersion = 10.0.0.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocRaptor", "src\DocRaptor\DocRaptor.csproj", "{CFD94733-F020-45EE-B121-AA0CA516F4FD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocRaptor.Test", "src\DocRaptor.Test\DocRaptor.Test.csproj", "{19F1DEBC-DE5E-4517-8062-F000CD499087}"
# Visual Studio Version 17
VisualStudioVersion = 17.3.32922.545
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DocRaptor", "src\DocRaptor\DocRaptor.csproj", "{0A8810C0-4EB7-4154-9987-2E4EAA55C9A7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CFD94733-F020-45EE-B121-AA0CA516F4FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CFD94733-F020-45EE-B121-AA0CA516F4FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CFD94733-F020-45EE-B121-AA0CA516F4FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CFD94733-F020-45EE-B121-AA0CA516F4FD}.Release|Any CPU.Build.0 = Release|Any CPU
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.ActiveCfg = Release|Any CPU
{19F1DEBC-DE5E-4517-8062-F000CD499087}.Release|Any CPU.Build.0 = Release|Any CPU
{0A8810C0-4EB7-4154-9987-2E4EAA55C9A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0A8810C0-4EB7-4154-9987-2E4EAA55C9A7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0A8810C0-4EB7-4154-9987-2E4EAA55C9A7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0A8810C0-4EB7-4154-9987-2E4EAA55C9A7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {65B918BC-E1D7-41E9-840E-3C41F712F4F1}
EndGlobalSection
EndGlobal
362 changes: 186 additions & 176 deletions src/DocRaptor/Api/DocApi.cs

Large diffs are not rendered by default.

51 changes: 22 additions & 29 deletions src/DocRaptor/Client/ApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,9 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.Text.RegularExpressions;
using System.IO;
using System.Threading;
using System.Web;
using System.Linq;
using System.Net;
using System.Text;
using Newtonsoft.Json;
using RestSharp;
Expand All @@ -29,7 +25,7 @@ namespace DocRaptor.Client
/// </summary>
public partial class ApiClient
{
public JsonSerializerSettings serializerSettings = new JsonSerializerSettings
private JsonSerializerSettings serializerSettings = new JsonSerializerSettings
{
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor
};
Expand All @@ -38,43 +34,51 @@ public partial class ApiClient
/// Allows for extending request processing for <see cref="ApiClient"/> generated code.
/// </summary>
/// <param name="request">The RestSharp request object</param>
partial void InterceptRequest(IRestRequest request);
partial void InterceptRequest(RestRequest request);

/// <summary>
/// Allows for extending response processing for <see cref="ApiClient"/> generated code.
/// </summary>
/// <param name="request">The RestSharp request object</param>
/// <param name="response">The RestSharp response object</param>
partial void InterceptResponse(IRestRequest request, IRestResponse response);
partial void InterceptResponse(RestRequest request, RestResponse response);

/// <summary>
/// Initializes a new instance of the <see cref="ApiClient" /> class
/// with default configuration.
/// </summary>
public ApiClient()
public ApiClient() : this(DocRaptor.Client.Configuration.Default)
{
Configuration = DocRaptor.Client.Configuration.Default;
RestClient = new RestClient("https://api.docraptor.com");
}

/// <summary>
/// Initializes a new instance of the <see cref="ApiClient" /> class
/// with default base path (https://api.docraptor.com).
/// with default base path (https://docraptor.com).
/// </summary>
/// <param name="config">An instance of Configuration.</param>
public ApiClient(Configuration config)
{
Configuration = config ?? DocRaptor.Client.Configuration.Default;

RestClient = new RestClient(Configuration.BasePath);
if (string.IsNullOrEmpty(Configuration.BasePath))
{
DocRaptor.Client.Configuration.Default.BasePath = "https://docraptor.com";
}

RestClient = new RestClient(new RestClientOptions
{
BaseUrl = new Uri(Configuration.BasePath),
Timeout = TimeSpan.FromMilliseconds(Configuration.Timeout),
UserAgent = Configuration.UserAgent
});
}

/// <summary>
/// Initializes a new instance of the <see cref="ApiClient" /> class
/// with default configuration.
/// </summary>
/// <param name="basePath">The base path.</param>
public ApiClient(String basePath = "https://api.docraptor.com")
public ApiClient(String basePath = "https://docraptor.com")
{
if (String.IsNullOrEmpty(basePath))
throw new ArgumentException("basePath cannot be empty");
Expand Down Expand Up @@ -135,7 +139,7 @@ private RestRequest PrepareRequest(
// add file parameter, if any
foreach(var param in fileParams)
{
request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
request.AddFile(param.Value.Name, param.Value.GetFile, param.Value.FileName, param.Value.ContentType);
}

if (postBody != null) // http body (model or byte[]) parameter
Expand Down Expand Up @@ -169,12 +173,6 @@ public Object CallApi(
path, method, queryParams, postBody, headerParams, formParams, fileParams,
pathParams, contentType);

// set timeout

RestClient.Timeout = Configuration.Timeout;
// set user agent
RestClient.UserAgent = Configuration.UserAgent;

InterceptRequest(request);
var response = RestClient.Execute(request);
InterceptResponse(request, response);
Expand All @@ -193,20 +191,18 @@ public Object CallApi(
/// <param name="fileParams">File parameters.</param>
/// <param name="pathParams">Path parameters.</param>
/// <param name="contentType">Content type.</param>
/// <param name="cancellationToken">Cancellation Token.</param>
/// <returns>The Task instance.</returns>
public async System.Threading.Tasks.Task<Object> CallApiAsync(
String path, RestSharp.Method method, List<KeyValuePair<String, String>> queryParams, Object postBody,
Dictionary<String, String> headerParams, Dictionary<String, String> formParams,
Dictionary<String, FileParameter> fileParams, Dictionary<String, String> pathParams,
String contentType, CancellationToken cancellationToken)
String contentType)
{
var request = PrepareRequest(
path, method, queryParams, postBody, headerParams, formParams, fileParams,
pathParams, contentType);
RestClient.UserAgent = Configuration.UserAgent;
InterceptRequest(request);
var response = await RestClient.ExecuteTaskAsync(request, cancellationToken);
var response = await RestClient.ExecuteAsync(request);
InterceptResponse(request, response);
return (Object)response;
}
Expand Down Expand Up @@ -256,8 +252,6 @@ public string ParameterToString(object obj)
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
// For example: 2009-06-15T13:45:30.0000000
return ((DateTimeOffset)obj).ToString (Configuration.DateTimeFormat);
else if (obj is bool)
return (bool)obj ? "true" : "false";
else if (obj is IList)
{
var flattenedString = new StringBuilder();
Expand All @@ -279,9 +273,9 @@ public string ParameterToString(object obj)
/// <param name="response">The HTTP response.</param>
/// <param name="type">Object type.</param>
/// <returns>Object representation of the JSON string.</returns>
public object Deserialize(IRestResponse response, Type type)
public object Deserialize(RestResponse response, Type type)
{
IList<Parameter> headers = response.Headers;
var headers = response.Headers;
if (type == typeof(byte[])) // return byte array
{
return response.RawBytes;
Expand Down Expand Up @@ -502,7 +496,6 @@ public static string SanitizeFilename(string filename)
/// Convert params to key/value pairs.
/// Use collectionFormat to properly format lists and collections.
/// </summary>
/// <param name="collectionFormat">Collection format.</param>
/// <param name="name">Key name.</param>
/// <param name="value">Value object.</param>
/// <returns>A list of KeyValuePairs</returns>
Expand Down
6 changes: 3 additions & 3 deletions src/DocRaptor/Client/ApiResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
* Generated by: https://github.com/openapitools/openapi-generator.git
*/

using System;
using System.Collections.Generic;
using RestSharp;

namespace DocRaptor.Client
{
Expand All @@ -28,7 +28,7 @@ public class ApiResponse<T>
/// Gets or sets the HTTP headers
/// </summary>
/// <value>HTTP headers</value>
public IDictionary<string, string> Headers { get; private set; }
public IReadOnlyCollection<HeaderParameter> Headers { get; private set; }

/// <summary>
/// Gets or sets the data (parsed HTTP body)
Expand All @@ -42,7 +42,7 @@ public class ApiResponse<T>
/// <param name="statusCode">HTTP status code.</param>
/// <param name="headers">HTTP headers.</param>
/// <param name="data">Data (parsed HTTP body)</param>
public ApiResponse(int statusCode, IDictionary<string, string> headers, T data)
public ApiResponse(int statusCode, IReadOnlyCollection<HeaderParameter> headers, T data)
{
this.StatusCode= statusCode;
this.Headers = headers;
Expand Down
26 changes: 10 additions & 16 deletions src/DocRaptor/Client/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,9 @@
*/

using System;
using System.Reflection;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace DocRaptor.Client
{
Expand All @@ -29,7 +26,7 @@ public class Configuration : IReadableConfiguration
/// Version of the package.
/// </summary>
/// <value>Version of the package.</value>
public const string Version = "4.0.0";
public const string Version = "2.0.0";

/// <summary>
/// Identifier for ISO 8601 DateTime Format
Expand Down Expand Up @@ -114,8 +111,8 @@ static Configuration()
/// </summary>
public Configuration()
{
UserAgent = "OpenAPI-Generator/4.0.0/csharp";
BasePath = "https://api.docraptor.com";
UserAgent = "Swagger-Codegen/2.0.0/csharp";
BasePath = "https://docraptor.com";
DefaultHeader = new ConcurrentDictionary<string, string>();
ApiKey = new ConcurrentDictionary<string, string>();
ApiKeyPrefix = new ConcurrentDictionary<string, string>();
Expand All @@ -131,7 +128,7 @@ public Configuration(
IDictionary<string, string> defaultHeader,
IDictionary<string, string> apiKey,
IDictionary<string, string> apiKeyPrefix,
string basePath = "https://api.docraptor.com") : this()
string basePath = "https://docraptor.com") : this()
{
if (string.IsNullOrWhiteSpace(basePath))
throw new ArgumentException("The provided basePath is invalid.", "basePath");
Expand Down Expand Up @@ -187,7 +184,7 @@ public Configuration(
string tempFolderPath = null,
string dateTimeFormat = null,
int timeout = 100000,
string userAgent = "OpenAPI-Generator/4.0.0/csharp"
string userAgent = "Swagger-Codegen/2.0.0/csharp"
// ReSharper restore UnusedParameter.Local
)
{
Expand Down Expand Up @@ -231,10 +228,6 @@ public virtual string BasePath {
get { return _basePath; }
set {
_basePath = value;
// pass-through to ApiClient if it's set.
if(_apiClient != null) {
_apiClient.RestClient.BaseUrl = new Uri(_basePath);
}
}
}

Expand All @@ -246,11 +239,11 @@ public virtual string BasePath {
/// <summary>
/// Gets or sets the HTTP timeout (milliseconds) of ApiClient. Default to 100000 milliseconds.
/// </summary>
private int _timeout = 30000;
public virtual int Timeout
{

get { return ApiClient.RestClient.Timeout; }
set { ApiClient.RestClient.Timeout = value; }
get { return _timeout; }
set { _timeout = value; }
}

/// <summary>
Expand Down Expand Up @@ -305,6 +298,7 @@ public virtual string TempFolderPath
{
if (string.IsNullOrEmpty(value))
{
// Possible breaking change since swagger-codegen 2.2.1, enforce a valid temporary path on set.
_tempFolderPath = Path.GetTempPath();
return;
}
Expand Down Expand Up @@ -421,7 +415,7 @@ public static String ToDebugReport()
report += " OS: " + System.Environment.OSVersion + "\n";
report += " .NET Framework Version: " + System.Environment.Version + "\n";
report += " Version of the API: 2.0.0\n";
report += " SDK Package Version: 4.0.0\n";
report += " SDK Package Version: 2.0.0\n";

return report;
}
Expand Down
2 changes: 1 addition & 1 deletion src/DocRaptor/Client/ExceptionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ namespace DocRaptor.Client
/// <param name="methodName">Method name</param>
/// <param name="response">Response</param>
/// <returns>Exceptions</returns>
public delegate Exception ExceptionFactory(string methodName, IRestResponse response);
public delegate Exception ExceptionFactory(string methodName, RestResponse response);
}
12 changes: 2 additions & 10 deletions src/DocRaptor/Client/GlobalConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@
*/


using System;
using System.Reflection;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

namespace DocRaptor.Client
{
/// <summary>
Expand All @@ -25,10 +17,10 @@ namespace DocRaptor.Client
/// </summary>
/// <remarks>
/// A customized implementation via partial class may reside in another file and may
/// be excluded from automatic generation via a .openapi-generator-ignore file.
/// be excluded from automatic generation via a .swagger-codegen-ignore file.
/// </remarks>
public partial class GlobalConfiguration : Configuration
{

}
}
}
4 changes: 0 additions & 4 deletions src/DocRaptor/Client/IApiAccessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@


using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using RestSharp;

namespace DocRaptor.Client
{
Expand Down
2 changes: 1 addition & 1 deletion src/DocRaptor/Client/IReadableConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public interface IReadableConfiguration
/// <summary>
/// Gets the date time format.
/// </summary>
/// <value>Date time format.</value>
/// <value>Date time foramt.</value>
string DateTimeFormat { get; }

/// <summary>
Expand Down
Loading