[csharp] Update JsonSubTypes to 1.1.3 and use nuget dependency (#6969)

* the result I want to obtain

* add csharp-petstore-net-40.bat for windows

* just ran bin\windows\csharp-petstore-all.bat

* Removed those directories:
- samples\client\petstore\csharp
- samples\client\petstore\csharp-dotnet2

then ran :
bin\windows\csharp-petstore-all.bat

* - update JsonSubTypes to 1.1.3 by using nuget dependency (the package is compatible with net40)
- allign all version of Newtonsoft.Json to 10.0.3

* the result of bin\windows\csharp-petstore-all.bat

* ran bin\security\windows\csharp-petstore.bat
This commit is contained in:
manuc66
2017-11-21 04:26:58 +01:00
committed by William Cheng
parent 0c3688227a
commit b06ccec11e
234 changed files with 2545 additions and 5874 deletions

View File

@@ -12,3 +12,5 @@ call .\bin\windows\csharp-dotnet2-petstore.bat
call .\bin\windows\csharp-petstore-netcore-project.bat
call .\bin\windows\csharp-property-changed-petstore.bat
call .\bin\windows\csharp-petstore-net-40.bat

View File

@@ -0,0 +1,10 @@
set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar
If Not Exist %executable% (
mvn clean package
)
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
set ags=generate -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l csharp -o samples/client/petstore/csharp/SwaggerClientNet40 --additional-properties packageGuid={321C8C3F-0156-40C1-AE42-D59761FB9B6C} -c ./bin/csharp-petstore-net-40.json
java %JAVA_OPTS% -jar %executable% %ags%

View File

@@ -359,8 +359,6 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
clientPackageDir, "ExceptionFactory.cs"));
supportingFiles.add(new SupportingFile("SwaggerDateConverter.mustache",
clientPackageDir, "SwaggerDateConverter.cs"));
supportingFiles.add(new SupportingFile("JsonSubTypes.mustache",
clientPackageDir, "JsonSubTypes.cs"));
if (NET40.equals(this.targetFramework)) {
// .net 4.0 doesn't include ReadOnlyDictionary…

View File

@@ -22,7 +22,8 @@
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
"Microsoft.EntityFrameworkCore": "1.0.0",
"Swashbuckle.AspNetCore": "1.0.0-rc3",
"Newtonsoft.Json": "9.0.1"
"Newtonsoft.Json": "10.0.3",
"JsonSubTypes": "1.1.3"
},
"tools": {

View File

@@ -1,272 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace JsonSubTypes
{
// Copied from project https://github.com/manuc66/JsonSubTypes
// https://raw.githubusercontent.com/manuc66/JsonSubTypes/07403192ea3f4959f6d42f5966ac56ceb0d6095b/JsonSubTypes/JsonSubtypes.cs
public class JsonSubtypes : JsonConverter
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true)]
public class KnownSubTypeAttribute : Attribute
{
public Type SubType { get; private set; }
public object AssociatedValue { get; private set; }
public KnownSubTypeAttribute(Type subType, object associatedValue)
{
SubType = subType;
AssociatedValue = associatedValue;
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true)]
public class KnownSubTypeWithPropertyAttribute : Attribute
{
public Type SubType { get; private set; }
public string PropertyName { get; private set; }
public KnownSubTypeWithPropertyAttribute(Type subType, string propertyName)
{
SubType = subType;
PropertyName = propertyName;
}
}
private readonly string _typeMappingPropertyName;
private bool _isInsideRead;
private JsonReader _reader;
public override bool CanRead
{
get
{
if (!_isInsideRead)
return true;
return !string.IsNullOrEmpty(_reader.Path);
}
}
public sealed override bool CanWrite
{
get { return false; }
}
public JsonSubtypes()
{
}
public JsonSubtypes(string typeMappingPropertyName)
{
_typeMappingPropertyName = typeMappingPropertyName;
}
public override bool CanConvert(Type objectType)
{
return _typeMappingPropertyName != null;
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
throw new NotImplementedException();
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Comment)
reader.Read();
switch (reader.TokenType)
{
case JsonToken.Null:
return null;
case JsonToken.StartArray:
return ReadArray(reader, objectType, serializer);
case JsonToken.StartObject:
return ReadObject(reader, objectType, serializer);
default:
throw new Exception("Array: Unrecognized token: " + reader.TokenType);
}
}
private IList ReadArray(JsonReader reader, Type targetType, JsonSerializer serializer)
{
var elementType = GetElementType(targetType);
var list = CreateCompatibleList(targetType, elementType);
while (reader.TokenType != JsonToken.EndArray && reader.Read())
{
switch (reader.TokenType)
{
case JsonToken.Null:
list.Add(reader.Value);
break;
case JsonToken.Comment:
break;
case JsonToken.StartObject:
list.Add(ReadObject(reader, elementType, serializer));
break;
case JsonToken.EndArray:
break;
default:
throw new Exception("Array: Unrecognized token: " + reader.TokenType);
}
}
if (targetType.IsArray)
{
var array = Array.CreateInstance(targetType.GetElementType(), list.Count);
list.CopyTo(array, 0);
list = array;
}
return list;
}
private static IList CreateCompatibleList(Type targetContainerType, Type elementType)
{
IList list;
if (targetContainerType.IsArray || targetContainerType{{^isNet40}}.GetTypeInfo(){{/isNet40}}.IsAbstract)
{
list = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(elementType));
}
else
{
list = (IList)Activator.CreateInstance(targetContainerType);
}
return list;
}
private static Type GetElementType(Type arrayOrGenericContainer)
{
Type elementType;
if (arrayOrGenericContainer.IsArray)
{
elementType = arrayOrGenericContainer.GetElementType();
}
else
{
elementType = arrayOrGenericContainer{{#isNet40}}.GetGenericArguments().FirstOrDefault(){{/isNet40}}{{^isNet40}}.GenericTypeArguments[0]{{/isNet40}};
}
return elementType;
}
private object ReadObject(JsonReader reader, Type objectType, JsonSerializer serializer)
{
var jObject = JObject.Load(reader);
var targetType = GetType(jObject, objectType) ?? objectType;
return _ReadJson(CreateAnotherReader(jObject, reader), targetType, null, serializer);
}
private static JsonReader CreateAnotherReader(JObject jObject, JsonReader reader)
{
var jObjectReader = jObject.CreateReader();
jObjectReader.Culture = reader.Culture;
jObjectReader.CloseInput = reader.CloseInput;
jObjectReader.SupportMultipleContent = reader.SupportMultipleContent;
jObjectReader.DateTimeZoneHandling = reader.DateTimeZoneHandling;
jObjectReader.FloatParseHandling = reader.FloatParseHandling;
jObjectReader.DateFormatString = reader.DateFormatString;
jObjectReader.DateParseHandling = reader.DateParseHandling;
return jObjectReader;
}
public Type GetType(JObject jObject, Type parentType)
{
if (_typeMappingPropertyName == null)
{
return GetTypeByPropertyPresence(jObject, parentType);
}
return GetTypeFromDiscriminatorValue(jObject, parentType);
}
private static Type GetTypeByPropertyPresence(JObject jObject, Type parentType)
{
foreach (var type in parentType{{#isNet40}}.GetCustomAttributes(false).OfType{{/isNet40}}{{^isNet40}}.GetTypeInfo().GetCustomAttributes{{/isNet40}}<KnownSubTypeWithPropertyAttribute>())
{
JToken ignore;
if (jObject.TryGetValue(type.PropertyName, out ignore))
{
return type.SubType;
}
}
return null;
}
private Type GetTypeFromDiscriminatorValue(JObject jObject, Type parentType)
{
JToken jToken;
if (!jObject.TryGetValue(_typeMappingPropertyName, out jToken)) return null;
var discriminatorValue = jToken.ToObject<object>();
if (discriminatorValue == null) return null;
var typeMapping = GetSubTypeMapping(parentType);
if (typeMapping.Any())
{
return GetTypeFromMapping(typeMapping, discriminatorValue);
}
return GetTypeByName(discriminatorValue as string, parentType);
}
private static Type GetTypeByName(string typeName, Type parentType)
{
if (typeName == null)
return null;
var insideAssembly = parentType{{^isNet40}}.GetTypeInfo(){{/isNet40}}.Assembly;
var typeByName = insideAssembly.GetType(typeName);
if (typeByName == null)
{
var searchLocation = parentType.FullName.Substring(0, parentType.FullName.Length - parentType.Name.Length);
typeByName = insideAssembly.GetType(searchLocation + typeName, false, true);
}
return typeByName;
}
private static Type GetTypeFromMapping(I{{^isNet40}}ReadOnly{{/isNet40}}Dictionary<object, Type> typeMapping, object discriminatorValue)
{
var targetlookupValueType = typeMapping.First().Key.GetType();
var lookupValue = ConvertJsonValueToType(discriminatorValue, targetlookupValueType);
Type targetType;
return typeMapping.TryGetValue(lookupValue, out targetType) ? targetType : null;
}
private static Dictionary<object, Type> GetSubTypeMapping(Type type)
{
return type{{#isNet40}}.GetCustomAttributes(false).OfType{{/isNet40}}{{^isNet40}}.GetTypeInfo().GetCustomAttributes{{/isNet40}}<KnownSubTypeAttribute>().ToDictionary(x => x.AssociatedValue, x => x.SubType);
}
private static object ConvertJsonValueToType(object objectType, Type targetlookupValueType)
{
if (targetlookupValueType{{^isNet40}}.GetTypeInfo(){{/isNet40}}.IsEnum)
return Enum.ToObject(targetlookupValueType, objectType);
return Convert.ChangeType(objectType, targetlookupValueType);
}
protected object _ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
_reader = reader;
_isInsideRead = true;
try
{
return serializer.Deserialize(reader, objectType);
}
finally
{
_isInsideRead = false;
}
}
}
}

View File

@@ -72,6 +72,12 @@
<HintPath Condition="Exists('..\..\packages')">..\..\packages\Newtonsoft.Json.10.0.3\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll</HintPath>
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\Newtonsoft.Json.10.0.3\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="JsonSubTypes">
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\JsonSubTypes.1.1.3\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\packages')">..\packages\JsonSubTypes.1.1.3\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\..\packages')">..\..\packages\JsonSubTypes.1.1.3\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\JsonSubTypes.1.1.3\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll</HintPath>
</Reference>
<Reference Include="RestSharp">
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.105.1.0\lib\{{#isNet40}}net4{{/isNet40}}{{^isNet40}}{{targetFrameworkNuget}}{{/isNet40}}\RestSharp.dll</HintPath>
<HintPath Condition="Exists('..\packages')">..\packages\RestSharp.105.1.0\lib\{{#isNet40}}net4{{/isNet40}}{{^isNet40}}{{targetFrameworkNuget}}{{/isNet40}}\RestSharp.dll</HintPath>

View File

@@ -39,7 +39,7 @@ This C# SDK is automatically generated by the [Swagger Codegen](https://github.c
{{#netStandard}}
- FubarCoder.RestSharp.Portable.Core >=4.0.7
- FubarCoder.RestSharp.Portable.HttpClient >=4.0.7
- Newtonsoft.Json >=9.0.1
- Newtonsoft.Json >=10.0.3
{{/netStandard}}
{{^netStandard}}
- [RestSharp](https://www.nuget.org/packages/RestSharp) - 105.1.0 or later

View File

@@ -64,6 +64,12 @@
<HintPath Condition="Exists('..\..\packages')">..\..\packages\Newtonsoft.Json.10.0.3\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll</HintPath>
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\Newtonsoft.Json.10.0.3\lib\{{targetFrameworkNuget}}\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="JsonSubTypes">
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\JsonSubTypes.1.1.3\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\packages')">..\packages\JsonSubTypes.1.1.3\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\..\packages')">..\..\packages\JsonSubTypes.1.1.3\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('{{binRelativePath}}')">{{binRelativePath}}\JsonSubTypes.1.1.3\lib\{{targetFrameworkNuget}}\JsonSubTypes.dll</HintPath>
</Reference>
<Reference Include="RestSharp">
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.105.1.0\lib\{{#isNet40}}net4{{/isNet40}}{{^isNet40}}{{targetFrameworkNuget}}{{/isNet40}}\RestSharp.dll</HintPath>
<HintPath Condition="Exists('..\packages')">..\packages\RestSharp.105.1.0\lib\{{#isNet40}}net4{{/isNet40}}{{^isNet40}}{{targetFrameworkNuget}}{{/isNet40}}\RestSharp.dll</HintPath>

View File

@@ -25,7 +25,8 @@
{{^netStandard}}
<PackageReference Include="RestSharp" Version="105.1.0" />
{{/netStandard}}
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="JsonSubTypes" Version="1.1.3" />
</ItemGroup>
{{^netStandard}}

View File

@@ -24,7 +24,8 @@
{{^netStandard}}
<PackageReference Include="RestSharp" Version="105.1.0" />
{{/netStandard}}
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
<PackageReference Include="JsonSubTypes" Version="1.1.3" />
</ItemGroup>
{{^netStandard}}

View File

@@ -2,6 +2,7 @@
<packages>
<package id="RestSharp" version="105.1.0" targetFramework="{{#isNet40}}net4{{/isNet40}}{{^isNet40}}{{targetFrameworkNuget}}{{/isNet40}}" developmentDependency="true" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="{{targetFrameworkNuget}}" developmentDependency="true" />
<package id="JsonSubTypes" version="1.1.3" targetFramework="{{targetFrameworkNuget}}" developmentDependency="true" />
{{#generatePropertyChanged}}
<package id="Fody" version="1.29.4" targetFramework="{{targetFrameworkNuget}}" developmentDependency="true" />
<package id="PropertyChanged.Fody" version="1.51.3" targetFramework="{{targetFrameworkNuget}}" developmentDependency="true" />

View File

@@ -3,4 +3,5 @@
<package id="NUnit" version="2.6.4" targetFramework="{{targetFrameworkNuget}}" />
<package id="RestSharp" version="105.1.0" targetFramework="{{#isNet40}}net4{{/isNet40}}{{^isNet40}}{{targetFrameworkNuget}}{{/isNet40}}" developmentDependency="true" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="{{targetFrameworkNuget}}" developmentDependency="true" />
<package id="JsonSubTypes" version="1.1.3" targetFramework="{{targetFrameworkNuget}}" developmentDependency="true" />
</packages>

View File

@@ -3,7 +3,8 @@
"dependencies": {
"FubarCoder.RestSharp.Portable.Core": "4.0.7",
"FubarCoder.RestSharp.Portable.HttpClient": "4.0.7",
"Newtonsoft.Json": "9.0.1"
"Newtonsoft.Json": "10.0.3",
"JsonSubTypes": "1.1.3"
},
"frameworks": {
"{{targetFrameworkNuget}}": {}

View File

@@ -6,6 +6,7 @@
*.suo
*.user
*.sln.docstates
./nuget
# Build results

View File

@@ -1,13 +0,0 @@
<Properties StartupItem="src/IO.Swagger/IO.Swagger.csproj">
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.Workbench ActiveDocument="src/IO.Swagger/Client/Configuration.cs">
<Files>
<File FileName="src/IO.Swagger/Client/ApiClient.cs" Line="1" Column="1" />
<File FileName="src/IO.Swagger/Client/Configuration.cs" Line="22" Column="1" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
</Properties>

View File

@@ -1,201 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

View File

@@ -4,14 +4,43 @@
#
frameworkVersion=net45
netfx=${frameworkVersion#net}
# sdk must match installed framworks under PREFIX/lib/mono/[value]
sdk=4.5.2-api
# langversion refers to C# language features. see man mcs for details.
langversion=${sdk}
nuget_cmd=nuget
# Match against our known SDK possibilities
case "${sdk}" in
4)
langversion=4
;;
4.5*)
langversion=5
;;
4.6*)
langversion=6
;;
4.7*)
langversion=7 # ignoring 7.1 for now.
;;
*)
langversion=6
;;
esac
echo "[INFO] Target framework: ${frameworkVersion}"
echo "[INFO] Download nuget and packages"
wget -nc https://dist.nuget.org/win-x86-commandline/latest/nuget.exe;
if [ ! type nuget &>/dev/null ]; then
echo "[INFO] Download nuget and packages"
wget -nc https://dist.nuget.org/win-x86-commandline/latest/nuget.exe;
nuget_cmd="mono nuget"
fi
mozroots --import --sync
mono nuget.exe install src/IO.Swagger/packages.config -o packages;
${nuget_cmd} install src/IO.Swagger/packages.config -o packages;
echo "[INFO] Copy DLLs to the 'bin' folder"
mkdir -p bin;
@@ -19,7 +48,7 @@ cp packages/Newtonsoft.Json.10.0.3/lib/net45/Newtonsoft.Json.dll bin/Newtonsoft.
cp packages/RestSharp.105.1.0/lib/net45/RestSharp.dll bin/RestSharp.dll;
echo "[INFO] Run 'mcs' to build bin/IO.Swagger.dll"
mcs -sdk:${netfx} -r:bin/Newtonsoft.Json.dll,\
mcs -langversion:${langversion} -sdk:${sdk} -r:bin/Newtonsoft.Json.dll,\
bin/RestSharp.dll,\
System.ComponentModel.DataAnnotations.dll,\
System.Runtime.Serialization.dll \

View File

@@ -36,7 +36,7 @@ git_remote=`git remote`
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git

View File

@@ -1,23 +1,11 @@
/*
* Swagger Petstore ' \" =end
* Swagger Petstore *_/ ' \" =end - - \\r\\n \\n \\r
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ ' \" =end
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end - -
*
* OpenAPI spec version: 1.0.0 ' \" =end
* Contact: apiteam@swagger.io ' \" =end
* OpenAPI spec version: 1.0.0 *_/ ' \" =end - - \\r\\n \\n \\r
* Contact: apiteam@swagger.io *_/ ' \" =end - - \\r\\n \\n \\r
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
@@ -70,20 +58,20 @@ namespace IO.Swagger.Test
[Test]
public void InstanceTest()
{
// test 'IsInstanceOfType' FakeApi
Assert.IsInstanceOfType(typeof(FakeApi), instance, "instance is a FakeApi");
// TODO uncomment below to test 'IsInstanceOfType' FakeApi
//Assert.IsInstanceOfType(typeof(FakeApi), instance, "instance is a FakeApi");
}
/// <summary>
/// Test TestCodeInjectEnd
/// Test TestCodeInjectEndRnNR
/// </summary>
[Test]
public void TestCodeInjectEndTest()
public void TestCodeInjectEndRnNRTest()
{
// TODO uncomment below to test the method and replace null with proper value
//string testCodeInjectEnd = null;
//instance.TestCodeInjectEnd(testCodeInjectEnd);
//string testCodeInjectEndRnNR = null;
//instance.TestCodeInjectEndRnNR(testCodeInjectEndRnNR);
}

View File

@@ -52,6 +52,12 @@ Contact: apiteam@swagger.io *_/ ' \" =end - - \\r\\n \\n \\r
<HintPath Condition="Exists('..\..\packages')">..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="JsonSubTypes">
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\JsonSubTypes.1.1.3\lib\net45\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\packages')">..\packages\JsonSubTypes.1.1.3\lib\net45\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\..\packages')">..\..\packages\JsonSubTypes.1.1.3\lib\net45\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\JsonSubTypes.1.1.3\lib\net45\JsonSubTypes.dll</HintPath>
</Reference>
<Reference Include="RestSharp">
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
<HintPath Condition="Exists('..\packages')">..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>

View File

@@ -1,23 +1,11 @@
/*
* Swagger Petstore ' \" =end
* Swagger Petstore *_/ ' \" =end - - \\r\\n \\n \\r
*
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ ' \" =end
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end - -
*
* OpenAPI spec version: 1.0.0 ' \" =end
* Contact: apiteam@swagger.io ' \" =end
* OpenAPI spec version: 1.0.0 *_/ ' \" =end - - \\r\\n \\n \\r
* Contact: apiteam@swagger.io *_/ ' \" =end - - \\r\\n \\n \\r
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
@@ -31,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -76,6 +65,7 @@ namespace IO.Swagger.Test
//Assert.IsInstanceOfType<ModelReturn> (instance, "variable 'instance' is a ModelReturn");
}
/// <summary>
/// Test the property '_Return'
/// </summary>

View File

@@ -3,4 +3,5 @@
<package id="NUnit" version="2.6.4" targetFramework="net45" />
<package id="RestSharp" version="105.1.0" targetFramework="net45" developmentDependency="true" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net45" developmentDependency="true" />
<package id="JsonSubTypes" version="1.1.3" targetFramework="net45" developmentDependency="true" />
</packages>

View File

@@ -1,272 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace JsonSubTypes
{
// Copied from project https://github.com/manuc66/JsonSubTypes
// https://raw.githubusercontent.com/manuc66/JsonSubTypes/07403192ea3f4959f6d42f5966ac56ceb0d6095b/JsonSubTypes/JsonSubtypes.cs
public class JsonSubtypes : JsonConverter
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true)]
public class KnownSubTypeAttribute : Attribute
{
public Type SubType { get; private set; }
public object AssociatedValue { get; private set; }
public KnownSubTypeAttribute(Type subType, object associatedValue)
{
SubType = subType;
AssociatedValue = associatedValue;
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true)]
public class KnownSubTypeWithPropertyAttribute : Attribute
{
public Type SubType { get; private set; }
public string PropertyName { get; private set; }
public KnownSubTypeWithPropertyAttribute(Type subType, string propertyName)
{
SubType = subType;
PropertyName = propertyName;
}
}
private readonly string _typeMappingPropertyName;
private bool _isInsideRead;
private JsonReader _reader;
public override bool CanRead
{
get
{
if (!_isInsideRead)
return true;
return !string.IsNullOrEmpty(_reader.Path);
}
}
public sealed override bool CanWrite
{
get { return false; }
}
public JsonSubtypes()
{
}
public JsonSubtypes(string typeMappingPropertyName)
{
_typeMappingPropertyName = typeMappingPropertyName;
}
public override bool CanConvert(Type objectType)
{
return _typeMappingPropertyName != null;
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
throw new NotImplementedException();
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Comment)
reader.Read();
switch (reader.TokenType)
{
case JsonToken.Null:
return null;
case JsonToken.StartArray:
return ReadArray(reader, objectType, serializer);
case JsonToken.StartObject:
return ReadObject(reader, objectType, serializer);
default:
throw new Exception("Array: Unrecognized token: " + reader.TokenType);
}
}
private IList ReadArray(JsonReader reader, Type targetType, JsonSerializer serializer)
{
var elementType = GetElementType(targetType);
var list = CreateCompatibleList(targetType, elementType);
while (reader.TokenType != JsonToken.EndArray && reader.Read())
{
switch (reader.TokenType)
{
case JsonToken.Null:
list.Add(reader.Value);
break;
case JsonToken.Comment:
break;
case JsonToken.StartObject:
list.Add(ReadObject(reader, elementType, serializer));
break;
case JsonToken.EndArray:
break;
default:
throw new Exception("Array: Unrecognized token: " + reader.TokenType);
}
}
if (targetType.IsArray)
{
var array = Array.CreateInstance(targetType.GetElementType(), list.Count);
list.CopyTo(array, 0);
list = array;
}
return list;
}
private static IList CreateCompatibleList(Type targetContainerType, Type elementType)
{
IList list;
if (targetContainerType.IsArray || targetContainerType.GetTypeInfo().IsAbstract)
{
list = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(elementType));
}
else
{
list = (IList)Activator.CreateInstance(targetContainerType);
}
return list;
}
private static Type GetElementType(Type arrayOrGenericContainer)
{
Type elementType;
if (arrayOrGenericContainer.IsArray)
{
elementType = arrayOrGenericContainer.GetElementType();
}
else
{
elementType = arrayOrGenericContainer.GenericTypeArguments[0];
}
return elementType;
}
private object ReadObject(JsonReader reader, Type objectType, JsonSerializer serializer)
{
var jObject = JObject.Load(reader);
var targetType = GetType(jObject, objectType) ?? objectType;
return _ReadJson(CreateAnotherReader(jObject, reader), targetType, null, serializer);
}
private static JsonReader CreateAnotherReader(JObject jObject, JsonReader reader)
{
var jObjectReader = jObject.CreateReader();
jObjectReader.Culture = reader.Culture;
jObjectReader.CloseInput = reader.CloseInput;
jObjectReader.SupportMultipleContent = reader.SupportMultipleContent;
jObjectReader.DateTimeZoneHandling = reader.DateTimeZoneHandling;
jObjectReader.FloatParseHandling = reader.FloatParseHandling;
jObjectReader.DateFormatString = reader.DateFormatString;
jObjectReader.DateParseHandling = reader.DateParseHandling;
return jObjectReader;
}
public Type GetType(JObject jObject, Type parentType)
{
if (_typeMappingPropertyName == null)
{
return GetTypeByPropertyPresence(jObject, parentType);
}
return GetTypeFromDiscriminatorValue(jObject, parentType);
}
private static Type GetTypeByPropertyPresence(JObject jObject, Type parentType)
{
foreach (var type in parentType.GetTypeInfo().GetCustomAttributes<KnownSubTypeWithPropertyAttribute>())
{
JToken ignore;
if (jObject.TryGetValue(type.PropertyName, out ignore))
{
return type.SubType;
}
}
return null;
}
private Type GetTypeFromDiscriminatorValue(JObject jObject, Type parentType)
{
JToken jToken;
if (!jObject.TryGetValue(_typeMappingPropertyName, out jToken)) return null;
var discriminatorValue = jToken.ToObject<object>();
if (discriminatorValue == null) return null;
var typeMapping = GetSubTypeMapping(parentType);
if (typeMapping.Any())
{
return GetTypeFromMapping(typeMapping, discriminatorValue);
}
return GetTypeByName(discriminatorValue as string, parentType);
}
private static Type GetTypeByName(string typeName, Type parentType)
{
if (typeName == null)
return null;
var insideAssembly = parentType.GetTypeInfo().Assembly;
var typeByName = insideAssembly.GetType(typeName);
if (typeByName == null)
{
var searchLocation = parentType.FullName.Substring(0, parentType.FullName.Length - parentType.Name.Length);
typeByName = insideAssembly.GetType(searchLocation + typeName, false, true);
}
return typeByName;
}
private static Type GetTypeFromMapping(IReadOnlyDictionary<object, Type> typeMapping, object discriminatorValue)
{
var targetlookupValueType = typeMapping.First().Key.GetType();
var lookupValue = ConvertJsonValueToType(discriminatorValue, targetlookupValueType);
Type targetType;
return typeMapping.TryGetValue(lookupValue, out targetType) ? targetType : null;
}
private static Dictionary<object, Type> GetSubTypeMapping(Type type)
{
return type.GetTypeInfo().GetCustomAttributes<KnownSubTypeAttribute>().ToDictionary(x => x.AssociatedValue, x => x.SubType);
}
private static object ConvertJsonValueToType(object objectType, Type targetlookupValueType)
{
if (targetlookupValueType.GetTypeInfo().IsEnum)
return Enum.ToObject(targetlookupValueType, objectType);
return Convert.ChangeType(objectType, targetlookupValueType);
}
protected object _ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
_reader = reader;
_isInsideRead = true;
try
{
return serializer.Deserialize(reader, objectType);
}
finally
{
_isInsideRead = false;
}
}
}
}

View File

@@ -53,6 +53,12 @@ Contact: apiteam@swagger.io *_/ ' \" =end - - \\r\\n \\n \\r
<HintPath Condition="Exists('..\..\packages')">..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="JsonSubTypes">
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\JsonSubTypes.1.1.3\lib\net45\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\packages')">..\packages\JsonSubTypes.1.1.3\lib\net45\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\..\packages')">..\..\packages\JsonSubTypes.1.1.3\lib\net45\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\JsonSubTypes.1.1.3\lib\net45\JsonSubTypes.dll</HintPath>
</Reference>
<Reference Include="RestSharp">
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
<HintPath Condition="Exists('..\packages')">..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>

View File

@@ -2,4 +2,5 @@
<packages>
<package id="RestSharp" version="105.1.0" targetFramework="net45" developmentDependency="true" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net45" developmentDependency="true" />
<package id="JsonSubTypes" version="1.1.3" targetFramework="net45" developmentDependency="true" />
</packages>

View File

@@ -1,8 +0,0 @@
# IO.Swagger.Model.OuterBoolean
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -1,11 +0,0 @@
# IO.Swagger.Model.OuterComposite
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**MyNumber** | [**OuterNumber**](OuterNumber.md) | | [optional]
**MyString** | [**OuterString**](OuterString.md) | | [optional]
**MyBoolean** | [**OuterBoolean**](OuterBoolean.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)

View File

@@ -1,8 +0,0 @@
# IO.Swagger.Model.OuterNumber
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -1,8 +0,0 @@
# IO.Swagger.Model.OuterString
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

View File

@@ -21,4 +21,3 @@
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
src/IO.Swagger.Test/IO.Swagger.Test.csproj

View File

@@ -6,7 +6,7 @@ Name | Type | Description | Notes
**EnumString** | **string** | | [optional]
**EnumInteger** | **int?** | | [optional]
**EnumNumber** | **double?** | | [optional]
**OuterEnum** | [**OuterEnum**](OuterEnum.md) | | [optional]
**OuterEnum** | **OuterEnum** | | [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)

View File

@@ -1,9 +0,0 @@
# IO.Swagger.Model.PropertyType
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Type** | **decimal?** | | [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)

View File

@@ -36,7 +36,7 @@ git_remote=`git remote`
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git

View File

@@ -6,18 +6,6 @@
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
@@ -76,6 +64,54 @@ namespace IO.Swagger.Test
}
/// <summary>
/// Test FakeOuterBooleanSerialize
/// </summary>
[Test]
public void FakeOuterBooleanSerializeTest()
{
// TODO uncomment below to test the method and replace null with proper value
//OuterBoolean body = null;
//var response = instance.FakeOuterBooleanSerialize(body);
//Assert.IsInstanceOf<OuterBoolean> (response, "response is OuterBoolean");
}
/// <summary>
/// Test FakeOuterCompositeSerialize
/// </summary>
[Test]
public void FakeOuterCompositeSerializeTest()
{
// TODO uncomment below to test the method and replace null with proper value
//OuterComposite body = null;
//var response = instance.FakeOuterCompositeSerialize(body);
//Assert.IsInstanceOf<OuterComposite> (response, "response is OuterComposite");
}
/// <summary>
/// Test FakeOuterNumberSerialize
/// </summary>
[Test]
public void FakeOuterNumberSerializeTest()
{
// TODO uncomment below to test the method and replace null with proper value
//OuterNumber body = null;
//var response = instance.FakeOuterNumberSerialize(body);
//Assert.IsInstanceOf<OuterNumber> (response, "response is OuterNumber");
}
/// <summary>
/// Test FakeOuterStringSerialize
/// </summary>
[Test]
public void FakeOuterStringSerializeTest()
{
// TODO uncomment below to test the method and replace null with proper value
//OuterString body = null;
//var response = instance.FakeOuterStringSerialize(body);
//Assert.IsInstanceOf<OuterString> (response, "response is OuterString");
}
/// <summary>
/// Test TestClientModel
/// </summary>
@@ -97,31 +133,63 @@ namespace IO.Swagger.Test
// TODO uncomment below to test the method and replace null with proper value
//decimal? number = null;
//double? _double = null;
//string _string = null;
//string patternWithoutDelimiter = null;
//byte[] _byte = null;
//int? integer = null;
//int? int32 = null;
//long? int64 = null;
//float? _float = null;
//string _string = null;
//byte[] binary = null;
//DateTime? date = null;
//DateTime? dateTime = null;
//string password = null;
//instance.TestEndpointParameters(number, _double, _string, _byte, integer, int32, int64, _float, binary, date, dateTime, password);
//string callback = null;
//instance.TestEndpointParameters(number, _double, patternWithoutDelimiter, _byte, integer, int32, int64, _float, _string, binary, date, dateTime, password, callback);
}
/// <summary>
/// Test TestEnumQueryParameters
/// Test TestEnumParameters
/// </summary>
[Test]
public void TestEnumQueryParametersTest()
public void TestEnumParametersTest()
{
// TODO uncomment below to test the method and replace null with proper value
//List<string> enumFormStringArray = null;
//string enumFormString = null;
//List<string> enumHeaderStringArray = null;
//string enumHeaderString = null;
//List<string> enumQueryStringArray = null;
//string enumQueryString = null;
//decimal? enumQueryInteger = null;
//int? enumQueryInteger = null;
//double? enumQueryDouble = null;
//instance.TestEnumQueryParameters(enumQueryString, enumQueryInteger, enumQueryDouble);
//instance.TestEnumParameters(enumFormStringArray, enumFormString, enumHeaderStringArray, enumHeaderString, enumQueryStringArray, enumQueryString, enumQueryInteger, enumQueryDouble);
}
/// <summary>
/// Test TestInlineAdditionalProperties
/// </summary>
[Test]
public void TestInlineAdditionalPropertiesTest()
{
// TODO uncomment below to test the method and replace null with proper value
//Object param = null;
//instance.TestInlineAdditionalProperties(param);
}
/// <summary>
/// Test TestJsonFormData
/// </summary>
[Test]
public void TestJsonFormDataTest()
{
// TODO uncomment below to test the method and replace null with proper value
//string param = null;
//string param2 = null;
//instance.TestJsonFormData(param, param2);
}

View File

@@ -1,81 +0,0 @@
/*
* Swagger 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: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using System;
using System.IO;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reflection;
using RestSharp;
using NUnit.Framework;
using IO.Swagger.Client;
using IO.Swagger.Api;
using IO.Swagger.Model;
namespace IO.Swagger.Test
{
/// <summary>
/// Class for testing Fake_classname_tags123Api
/// </summary>
/// <remarks>
/// This file is automatically generated by Swagger Codegen.
/// Please update the test case below to test the API endpoint.
/// </remarks>
[TestFixture]
public class Fake_classname_tags123ApiTests
{
private Fake_classname_tags123Api instance;
/// <summary>
/// Setup before each unit test
/// </summary>
[SetUp]
public void Init()
{
instance = new Fake_classname_tags123Api();
}
/// <summary>
/// Clean up after each unit test
/// </summary>
[TearDown]
public void Cleanup()
{
}
/// <summary>
/// Test an instance of Fake_classname_tags123Api
/// </summary>
[Test]
public void InstanceTest()
{
// TODO uncomment below to test 'IsInstanceOfType' Fake_classname_tags123Api
//Assert.IsInstanceOfType(typeof(Fake_classname_tags123Api), instance, "instance is a Fake_classname_tags123Api");
}
/// <summary>
/// Test TestClassname
/// </summary>
[Test]
public void TestClassnameTest()
{
// TODO uncomment below to test the method and replace null with proper value
//ModelClient body = null;
//var response = instance.TestClassname(body);
//Assert.IsInstanceOf<ModelClient> (response, "response is ModelClient");
}
}
}

View File

@@ -1,3 +1,13 @@
/*
* Swagger 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: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using System;
using System.IO;
using System.Collections.Generic;
@@ -25,45 +35,6 @@ namespace IO.Swagger.Test
{
private PetApi instance;
private long petId = 11088;
/// <summary>
/// Create a Pet object
/// </summary>
private Pet createPet()
{
// create pet
Pet p = new Pet(Name: "Csharp test", PhotoUrls: new List<string> { "http://petstore.com/csharp_test" });
p.Id = petId;
//p.Name = "Csharp test";
p.Status = Pet.StatusEnum.Available;
// create Category object
Category category = new Category();
category.Id = 56;
category.Name = "sample category name2";
List<String> photoUrls = new List<String>(new String[] {"sample photoUrls"});
// create Tag object
Tag tag = new Tag();
tag.Id = petId;
tag.Name = "csharp sample tag name1";
List<Tag> tags = new List<Tag>(new Tag[] {tag});
p.Tags = tags;
p.Category = category;
p.PhotoUrls = photoUrls;
return p;
}
/// <summary>
/// Convert string to byte array
/// </summary>
private byte[] GetBytes(string str)
{
byte[] bytes = new byte[str.Length * sizeof(char)];
System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
return bytes;
}
/// <summary>
/// Setup before each unit test
/// </summary>
@@ -71,13 +42,6 @@ namespace IO.Swagger.Test
public void Init()
{
instance = new PetApi();
// create pet
Pet p = createPet();
// add pet before testing
PetApi petApi = new PetApi("http://petstore.swagger.io/v2/");
petApi.AddPet (p);
}
/// <summary>
@@ -86,9 +50,7 @@ namespace IO.Swagger.Test
[TearDown]
public void Cleanup()
{
// remove the pet after testing
PetApi petApi = new PetApi ();
petApi.DeletePet(petId, "test key");
}
/// <summary>
@@ -97,7 +59,8 @@ namespace IO.Swagger.Test
[Test]
public void InstanceTest()
{
Assert.IsInstanceOf<PetApi>(instance);
// TODO uncomment below to test 'IsInstanceOfType' PetApi
//Assert.IsInstanceOfType(typeof(PetApi), instance, "instance is a PetApi");
}
@@ -107,9 +70,10 @@ namespace IO.Swagger.Test
[Test]
public void AddPetTest()
{
// create pet
Pet p = createPet();
instance.AddPet(p);
// TODO uncomment below to test the method and replace null with proper value
//Pet body = null;
//instance.AddPet(body);
}
/// <summary>
@@ -118,7 +82,11 @@ namespace IO.Swagger.Test
[Test]
public void DeletePetTest()
{
// no need to test as it'c covered by Cleanup() already
// TODO uncomment below to test the method and replace null with proper value
//long? petId = null;
//string apiKey = null;
//instance.DeletePet(petId, apiKey);
}
/// <summary>
@@ -127,15 +95,10 @@ namespace IO.Swagger.Test
[Test]
public void FindPetsByStatusTest()
{
PetApi petApi = new PetApi ();
List<String> tagsList = new List<String>(new String[] {"available"});
List<Pet> listPet = petApi.FindPetsByTags (tagsList);
foreach (Pet pet in listPet) // Loop through List with foreach.
{
Assert.IsInstanceOf<Pet>(pet);
Assert.AreEqual ("csharp sample tag name1", pet.Tags[0]);
}
// TODO uncomment below to test the method and replace null with proper value
//List<string> status = null;
//var response = instance.FindPetsByStatus(status);
//Assert.IsInstanceOf<List<Pet>> (response, "response is List<Pet>");
}
/// <summary>
@@ -144,9 +107,10 @@ namespace IO.Swagger.Test
[Test]
public void FindPetsByTagsTest()
{
List<string> tags = new List<String>(new String[] {"pet"});
var response = instance.FindPetsByTags(tags);
Assert.IsInstanceOf<List<Pet>>(response);
// TODO uncomment below to test the method and replace null with proper value
//List<string> tags = null;
//var response = instance.FindPetsByTags(tags);
//Assert.IsInstanceOf<List<Pet>> (response, "response is List<Pet>");
}
/// <summary>
@@ -155,96 +119,22 @@ namespace IO.Swagger.Test
[Test]
public void GetPetByIdTest()
{
// set timeout to 10 seconds
Configuration c1 = new Configuration();
c1.Timeout = 10000;
c1.UserAgent = "TEST_USER_AGENT";
PetApi petApi = new PetApi (c1);
Pet response = petApi.GetPetById (petId);
Assert.IsInstanceOf<Pet>(response);
Assert.AreEqual ("Csharp test", response.Name);
Assert.AreEqual (Pet.StatusEnum.Available, response.Status);
Assert.IsInstanceOf<List<Tag>>(response.Tags);
Assert.AreEqual (petId, response.Tags [0].Id);
Assert.AreEqual ("csharp sample tag name1", response.Tags [0].Name);
Assert.IsInstanceOf<List<String>>(response.PhotoUrls);
Assert.AreEqual ("sample photoUrls", response.PhotoUrls [0]);
Assert.IsInstanceOf<Category>(response.Category);
Assert.AreEqual (56, response.Category.Id);
Assert.AreEqual ("sample category name2", response.Category.Name);
// TODO uncomment below to test the method and replace null with proper value
//long? petId = null;
//var response = instance.GetPetById(petId);
//Assert.IsInstanceOf<Pet> (response, "response is Pet");
}
/// <summary>
/// Test GetPetByIdAsync
/// </summary>
[Test ()]
public void TestGetPetByIdAsync ()
{
PetApi petApi = new PetApi ();
var task = petApi.GetPetByIdAsync (petId);
Pet response = task.Result;
Assert.IsInstanceOf<Pet>(response);
Assert.AreEqual ("Csharp test", response.Name);
Assert.AreEqual (Pet.StatusEnum.Available, response.Status);
Assert.IsInstanceOf<List<Tag>>(response.Tags);
Assert.AreEqual (petId, response.Tags [0].Id);
Assert.AreEqual ("csharp sample tag name1", response.Tags [0].Name);
Assert.IsInstanceOf<List<String>>(response.PhotoUrls);
Assert.AreEqual ("sample photoUrls", response.PhotoUrls [0]);
Assert.IsInstanceOf<Category>(response.Category);
Assert.AreEqual (56, response.Category.Id);
Assert.AreEqual ("sample category name2", response.Category.Name);
}
/// <summary>
/// Test GetPetByIdAsyncWithHttpInfo
/// </summary>
[Test ()]
public void TestGetPetByIdAsyncWithHttpInfo ()
{
PetApi petApi = new PetApi ();
var task = petApi.GetPetByIdAsyncWithHttpInfo (petId);
Assert.AreEqual (200, task.Result.StatusCode);
Assert.IsTrue (task.Result.Headers.ContainsKey("Content-Type"));
Assert.AreEqual (task.Result.Headers["Content-Type"], "application/json");
Pet response = task.Result.Data;
Assert.IsInstanceOf<Pet>(response);
Assert.AreEqual ("Csharp test", response.Name);
Assert.AreEqual (Pet.StatusEnum.Available, response.Status);
Assert.IsInstanceOf<List<Tag>>(response.Tags);
Assert.AreEqual (petId, response.Tags [0].Id);
Assert.AreEqual ("csharp sample tag name1", response.Tags [0].Name);
Assert.IsInstanceOf<List<String>>(response.PhotoUrls);
Assert.AreEqual ("sample photoUrls", response.PhotoUrls [0]);
Assert.IsInstanceOf<Category>(response.Category);
Assert.AreEqual (56, response.Category.Id);
Assert.AreEqual ("sample category name2", response.Category.Name);
}
/// <summary>
/// Test UpdatePet
/// </summary>
[Test]
public void UpdatePetTest()
{
// create pet
Pet p = createPet();
instance.UpdatePet(p);
// TODO uncomment below to test the method and replace null with proper value
//Pet body = null;
//instance.UpdatePet(body);
}
/// <summary>
@@ -253,24 +143,12 @@ namespace IO.Swagger.Test
[Test]
public void UpdatePetWithFormTest()
{
PetApi petApi = new PetApi();
petApi.UpdatePetWithForm (petId, "new form name", "pending");
// TODO uncomment below to test the method and replace null with proper value
//long? petId = null;
//string name = null;
//string status = null;
//instance.UpdatePetWithForm(petId, name, status);
Pet response = petApi.GetPetById (petId);
Assert.IsInstanceOf<Pet>(response);
Assert.IsInstanceOf<Category>(response.Category);
Assert.IsInstanceOf<List<Tag>>(response.Tags);
Assert.AreEqual ("new form name", response.Name);
Assert.AreEqual (Pet.StatusEnum.Pending, response.Status);
Assert.AreEqual (petId, response.Tags [0].Id);
Assert.AreEqual (56, response.Category.Id);
// test optional parameter
petApi.UpdatePetWithForm (petId, "new form name2");
Pet response2 = petApi.GetPetById (petId);
Assert.AreEqual ("new form name2", response2.Name);
}
/// <summary>
@@ -279,46 +157,14 @@ namespace IO.Swagger.Test
[Test]
public void UploadFileTest()
{
Assembly _assembly = Assembly.GetExecutingAssembly();
Stream _imageStream = _assembly.GetManifestResourceStream("IO.Swagger.Test.swagger-logo.png");
PetApi petApi = new PetApi ();
// test file upload with form parameters
petApi.UploadFile(petId, "new form name", _imageStream);
// test file upload without any form parameters
// using optional parameter syntax introduced at .net 4.0
petApi.UploadFile(petId: petId, file: _imageStream);
// TODO uncomment below to test the method and replace null with proper value
//long? petId = null;
//string additionalMetadata = null;
//System.IO.Stream file = null;
//var response = instance.UploadFile(petId, additionalMetadata, file);
//Assert.IsInstanceOf<ApiResponse> (response, "response is ApiResponse");
}
/// <summary>
/// Test status code
/// </summary>
[Test ()]
public void TestStatusCodeAndHeader ()
{
PetApi petApi = new PetApi ();
var response = petApi.GetPetByIdWithHttpInfo (petId);
Assert.AreEqual (response.StatusCode, 200);
Assert.IsTrue (response.Headers.ContainsKey("Content-Type"));
Assert.AreEqual (response.Headers["Content-Type"], "application/json");
}
/// <summary>
/// Test default header (should be deprecated
/// </summary>
[Test ()]
public void TestDefaultHeader ()
{
PetApi petApi = new PetApi ();
// commented out the warning test below as it's confirmed the warning is working as expected
// there should be a warning for using AddDefaultHeader (deprecated) below
//petApi.AddDefaultHeader ("header_key", "header_value");
// the following should be used instead as suggested in the doc
petApi.Configuration.AddDefaultHeader ("header_key2", "header_value2");
}
}
}

View File

@@ -6,18 +6,6 @@
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;

View File

@@ -6,18 +6,6 @@
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;

View File

@@ -1,128 +0,0 @@
using NUnit.Framework;
using System;
using System.Collections.Generic;
using IO.Swagger.Client;
using IO.Swagger.Api;
using IO.Swagger.Model;
namespace IO.Swagger.Test
{
public class ApiClientTests
{
public ApiClientTests ()
{
}
[SetUp()]
public void BeforeEach()
{
var config = new GlobalConfiguration();
Configuration.Default = config;
}
[TearDown()]
public void TearDown()
{
// Reset to default, just in case
Configuration.Default.DateTimeFormat = "o";
}
/// <summary>
/// Test SelectHeaderContentType
/// </summary>
[Test ()]
public void TestSelectHeaderContentType ()
{
ApiClient api = new ApiClient ();
String[] contentTypes = new String[] { "application/json", "application/xml" };
Assert.AreEqual("application/json", api.SelectHeaderContentType (contentTypes));
contentTypes = new String[] { "application/xml" };
Assert.AreEqual("application/xml", api.SelectHeaderContentType (contentTypes));
contentTypes = new String[] {};
Assert.AreEqual("application/json", api.SelectHeaderContentType (contentTypes));
}
/// <summary>
/// Test ParameterToString
/// </summary>
[Test ()]
public void TestParameterToString ()
{
ApiClient api = new ApiClient ();
// test array of string
List<string> statusList = new List<String>(new String[] {"available", "sold"});
Assert.AreEqual("available,sold", api.ParameterToString (statusList));
// test array of int
List<int> numList = new List<int>(new int[] {1, 37});
Assert.AreEqual("1,37", api.ParameterToString (numList));
}
[Test ()]
public void TestParameterToStringForDateTime ()
{
ApiClient api = new ApiClient ();
// test datetime
DateTime dateUtc = DateTime.Parse ("2008-04-10T13:30:00.0000000z", null, System.Globalization.DateTimeStyles.RoundtripKind);
Assert.AreEqual ("2008-04-10T13:30:00.0000000Z", api.ParameterToString (dateUtc));
// test datetime with no timezone
DateTime dateWithNoTz = DateTime.Parse ("2008-04-10T13:30:00.000", null, System.Globalization.DateTimeStyles.RoundtripKind);
Assert.AreEqual ("2008-04-10T13:30:00.0000000", api.ParameterToString (dateWithNoTz));
}
// The test below only passes when running at -04:00 timezone
[Ignore ()]
public void TestParameterToStringWithTimeZoneForDateTime ()
{
ApiClient api = new ApiClient ();
// test datetime with a time zone
DateTimeOffset dateWithTz = DateTimeOffset.Parse("2008-04-10T13:30:00.0000000-04:00", null, System.Globalization.DateTimeStyles.RoundtripKind);
Assert.AreEqual("2008-04-10T13:30:00.0000000-04:00", api.ParameterToString(dateWithTz));
}
[Test ()]
public void TestParameterToStringForDateTimeWithUFormat ()
{
// Setup the DateTimeFormat across all of the calls
Configuration.Default.DateTimeFormat = "u";
ApiClient api = new ApiClient();
// test datetime
DateTime dateUtc = DateTime.Parse("2009-06-15 20:45:30Z", null, System.Globalization.DateTimeStyles.RoundtripKind);
Assert.AreEqual("2009-06-15 20:45:30Z", api.ParameterToString(dateUtc));
}
[Test ()]
public void TestParameterToStringForDateTimeWithCustomFormat ()
{
// Setup the DateTimeFormat across all of the calls
Configuration.Default.DateTimeFormat = "dd/MM/yy HH:mm:ss";
ApiClient api = new ApiClient();
// test datetime
DateTime dateUtc = DateTime.Parse("2009-06-15 20:45:30Z", null, System.Globalization.DateTimeStyles.RoundtripKind);
Assert.AreEqual("15/06/09 20:45:30", api.ParameterToString(dateUtc));
}
[Test ()]
public void TestSanitizeFilename ()
{
Assert.AreEqual("sun.gif", ApiClient.SanitizeFilename("sun.gif"));
Assert.AreEqual("sun.gif", ApiClient.SanitizeFilename("../sun.gif"));
Assert.AreEqual("sun.gif", ApiClient.SanitizeFilename("/var/tmp/sun.gif"));
Assert.AreEqual("sun.gif", ApiClient.SanitizeFilename("./sun.gif"));
Assert.AreEqual("sun", ApiClient.SanitizeFilename("sun"));
Assert.AreEqual("sun.gif", ApiClient.SanitizeFilename("..\\sun.gif"));
Assert.AreEqual("sun.gif", ApiClient.SanitizeFilename("\\var\\tmp\\sun.gif"));
Assert.AreEqual("sun.gif", ApiClient.SanitizeFilename("c:\\var\\tmp\\sun.gif"));
Assert.AreEqual("sun.gif", ApiClient.SanitizeFilename(".\\sun.gif"));
}
}
}

View File

@@ -1,171 +0,0 @@
using NUnit.Framework;
using System;
using System.Collections.Generic;
using IO.Swagger.Client;
using IO.Swagger.Api;
using IO.Swagger.Model;
namespace IO.Swagger.Test
{
public class ConfigurationTests
{
public ConfigurationTests ()
{
}
[SetUp()]
public void BeforeEach()
{
var config = new GlobalConfiguration();
Configuration.Default = config;
// Reset to default, just in case
Configuration.Default.DateTimeFormat = "o";
}
[Test ()]
public void TestAuthentication ()
{
Configuration c = new Configuration ();
c.Username = "test_username";
c.Password = "test_password";
c.ApiKey ["api_key_identifier"] = "1233456778889900";
c.ApiKeyPrefix ["api_key_identifier"] = "PREFIX";
Assert.AreEqual (c.GetApiKeyWithPrefix("api_key_identifier"), "PREFIX 1233456778889900");
}
[Test ()]
public void TestBasePath ()
{
PetApi p = new PetApi ("http://new-basepath.com");
Assert.AreEqual (p.Configuration.ApiClient.RestClient.BaseUrl, "http://new-basepath.com");
// Given that PetApi is initailized with a base path, a new configuration (with a new ApiClient)
// is created by default
Assert.AreNotSame (p.Configuration, Configuration.Default);
}
[Test ()]
public void TestDateTimeFormat_Default ()
{
// Should default to the Round-trip Format Specifier - "o"
// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8
Assert.AreEqual("o", Configuration.Default.DateTimeFormat);
}
[Test ()]
public void TestDateTimeFormat_UType()
{
Configuration.Default.DateTimeFormat = "u";
Assert.AreEqual("u", Configuration.Default.DateTimeFormat);
}
[Test()]
public void TestDateTimeFormat_UType_NonGlobal()
{
Configuration configuration = new Configuration();
configuration.DateTimeFormat = "u";
Assert.AreEqual("u", configuration.DateTimeFormat);
Assert.AreNotEqual("u", Configuration.Default.DateTimeFormat);
}
[Test ()]
public void TestConstruction()
{
Configuration c = new Configuration { Username = "test username", Password = "test password" };
Assert.AreEqual (c.Username, "test username");
Assert.AreEqual (c.Password, "test password");
}
[Test ()]
public void TestDefautlConfiguration ()
{
PetApi p1 = new PetApi ();
PetApi p2 = new PetApi ();
Assert.AreSame (p1.Configuration, p2.Configuration);
// same as the default
Assert.AreSame (p1.Configuration, Configuration.Default);
Configuration c = new Configuration ();
Assert.AreNotSame (c, p1.Configuration);
PetApi p3 = new PetApi (c);
// same as c
Assert.AreSame (p3.Configuration, c);
// not same as default
Assert.AreNotSame (p3.Configuration, p1.Configuration);
}
[Test ()]
public void TestUsage ()
{
// basic use case using default base URL
PetApi p1 = new PetApi ();
Assert.AreSame (p1.Configuration, Configuration.Default, "PetApi should use default configuration");
// using a different base URL
PetApi p2 = new PetApi ("http://new-base-url.com/");
Assert.AreEqual (p2.Configuration.ApiClient.RestClient.BaseUrl.ToString(), "http://new-base-url.com/");
// using a different configuration
Configuration c1 = new Configuration ();
PetApi p3 = new PetApi (c1);
Assert.AreSame (p3.Configuration, c1);
// using a different base URL via a new Configuration
String newApiClientUrl = "http://new-api-client.com";
Configuration c2 = new Configuration { BasePath = newApiClientUrl };
PetApi p4 = new PetApi (c2);
Assert.AreEqual(p4.Configuration.ApiClient.RestClient.BaseUrl, new Uri(newApiClientUrl));
}
[Test ()]
public void TestTimeout ()
{
Configuration c1 = new Configuration ();
Assert.AreEqual (100000, c1.Timeout); // default vaue
c1.Timeout = 50000;
Assert.AreEqual (50000, c1.Timeout);
Configuration c2 = new Configuration { Timeout = 20000 };
Assert.AreEqual (20000, c2.Timeout);
}
[Test()]
public void TestAddingInstanceHeadersDoesNotModifyGlobal()
{
// Arrange
Configuration.Default.DefaultHeader.Add("Content-Type", "application/json");
Configuration.Default.ApiKey.Add("api_key_identifier", "1233456778889900");
Configuration.Default.ApiKeyPrefix.Add("api_key_identifier", "PREFIX");
Configuration c = new Configuration(
Configuration.Default.DefaultHeader,
Configuration.Default.ApiKey,
Configuration.Default.ApiKeyPrefix
);
// sanity
CollectionAssert.AreEquivalent(c.DefaultHeader, Configuration.Default.DefaultHeader);
CollectionAssert.AreEquivalent(c.ApiKey, Configuration.Default.ApiKey);
CollectionAssert.AreEquivalent(c.ApiKeyPrefix, Configuration.Default.ApiKeyPrefix);
// Act
Configuration.Default.DefaultHeader["Content-Type"] = "application/xml";
Configuration.Default.ApiKey["api_key_identifier"] = "00000000000001234";
Configuration.Default.ApiKeyPrefix["api_key_identifier"] = "MODIFIED";
// Assert
CollectionAssert.AreNotEquivalent(c.DefaultHeader, Configuration.Default.DefaultHeader);
CollectionAssert.AreNotEquivalent(c.ApiKey, Configuration.Default.ApiKey);
CollectionAssert.AreNotEquivalent(c.ApiKeyPrefix, Configuration.Default.ApiKeyPrefix);
}
}
}

View File

@@ -6,19 +6,6 @@ This spec is mainly for testing Petstore server and contains fake endpoints, mod
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
@@ -65,6 +52,12 @@ limitations under the License.
<HintPath Condition="Exists('..\..\packages')">..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="JsonSubTypes">
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\JsonSubTypes.1.1.3\lib\net45\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\packages')">..\packages\JsonSubTypes.1.1.3\lib\net45\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\..\packages')">..\..\packages\JsonSubTypes.1.1.3\lib\net45\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\JsonSubTypes.1.1.3\lib\net45\JsonSubTypes.dll</HintPath>
</Reference>
<Reference Include="RestSharp">
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
<HintPath Condition="Exists('..\packages')">..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
@@ -79,20 +72,18 @@ limitations under the License.
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="**\*.cs" Exclude="obj\**" />
<Compile Include="**\*.cs"
Exclude="obj\**"/>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MsBuildToolsPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\IO.Swagger\IO.Swagger.csproj">
<Project>{391DEE9D-C48B-4846-838D-E96F4BC01E1D}</Project>
<Name>IO.Swagger</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="swagger-logo.png" />
<ProjectReference Include="..\IO.Swagger\IO.Swagger.csproj">
<Project>{321C8C3F-0156-40C1-AE42-D59761FB9B6C}</Project>
<Name>IO.Swagger</Name>
</ProjectReference>
</ItemGroup>
</Project>

View File

@@ -1,3 +1,14 @@
/*
* Swagger 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: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using NUnit.Framework;
using System;
@@ -8,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -21,7 +33,8 @@ namespace IO.Swagger.Test
[TestFixture]
public class AdditionalPropertiesClassTests
{
private AdditionalPropertiesClass instance;
// TODO uncomment below to declare an instance variable for AdditionalPropertiesClass
//private AdditionalPropertiesClass instance;
/// <summary>
/// Setup before each test
@@ -29,7 +42,8 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
instance = new AdditionalPropertiesClass();
// TODO uncomment below to create an instance of AdditionalPropertiesClass
//instance = new AdditionalPropertiesClass();
}
/// <summary>
@@ -47,10 +61,28 @@ namespace IO.Swagger.Test
[Test]
public void AdditionalPropertiesClassInstanceTest()
{
Assert.IsInstanceOfType(typeof(AdditionalPropertiesClass), instance, "instance is a AdditionalPropertiesClass");
// TODO uncomment below to test "IsInstanceOfType" AdditionalPropertiesClass
//Assert.IsInstanceOfType<AdditionalPropertiesClass> (instance, "variable 'instance' is a AdditionalPropertiesClass");
}
/// <summary>
/// Test the property 'MapProperty'
/// </summary>
[Test]
public void MapPropertyTest()
{
// TODO unit test for the property 'MapProperty'
}
/// <summary>
/// Test the property 'MapOfMapProperty'
/// </summary>
[Test]
public void MapOfMapPropertyTest()
{
// TODO unit test for the property 'MapOfMapProperty'
}
}
}

View File

@@ -1,3 +1,14 @@
/*
* Swagger 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: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using NUnit.Framework;
using System;
@@ -8,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -21,7 +33,8 @@ namespace IO.Swagger.Test
[TestFixture]
public class AnimalFarmTests
{
private AnimalFarm instance;
// TODO uncomment below to declare an instance variable for AnimalFarm
//private AnimalFarm instance;
/// <summary>
/// Setup before each test
@@ -29,7 +42,8 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
instance = new AnimalFarm();
// TODO uncomment below to create an instance of AnimalFarm
//instance = new AnimalFarm();
}
/// <summary>
@@ -47,10 +61,12 @@ namespace IO.Swagger.Test
[Test]
public void AnimalFarmInstanceTest()
{
Assert.IsInstanceOfType(typeof(AnimalFarm), instance, "instance is a AnimalFarm");
// TODO uncomment below to test "IsInstanceOfType" AnimalFarm
//Assert.IsInstanceOfType<AnimalFarm> (instance, "variable 'instance' is a AnimalFarm");
}
}
}

View File

@@ -1,3 +1,14 @@
/*
* Swagger 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: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using NUnit.Framework;
using System;
@@ -22,7 +33,8 @@ namespace IO.Swagger.Test
[TestFixture]
public class AnimalTests
{
private Animal instance;
// TODO uncomment below to declare an instance variable for Animal
//private Animal instance;
/// <summary>
/// Setup before each test
@@ -30,7 +42,8 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
instance = new Animal(ClassName: "csharp test");
// TODO uncomment below to create an instance of Animal
//instance = new Animal();
}
/// <summary>
@@ -48,7 +61,8 @@ namespace IO.Swagger.Test
[Test]
public void AnimalInstanceTest()
{
Assert.IsInstanceOfType(typeof(Animal), instance, "instance is a Animal");
// TODO uncomment below to test "IsInstanceOfType" Animal
//Assert.IsInstanceOfType<Animal> (instance, "variable 'instance' is a Animal");
}
/// <summary>
@@ -76,7 +90,15 @@ namespace IO.Swagger.Test
[Test]
public void ClassNameTest()
{
// TODO: unit test for the property 'ClassName'
// TODO unit test for the property 'ClassName'
}
/// <summary>
/// Test the property 'Color'
/// </summary>
[Test]
public void ColorTest()
{
// TODO unit test for the property 'Color'
}
}

View File

@@ -1,3 +1,14 @@
/*
* Swagger 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: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using NUnit.Framework;
using System;
@@ -8,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -21,7 +33,8 @@ namespace IO.Swagger.Test
[TestFixture]
public class ApiResponseTests
{
private ApiResponse instance;
// TODO uncomment below to declare an instance variable for ApiResponse
//private ApiResponse instance;
/// <summary>
/// Setup before each test
@@ -29,7 +42,8 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
instance = new ApiResponse();
// TODO uncomment below to create an instance of ApiResponse
//instance = new ApiResponse();
}
/// <summary>
@@ -47,16 +61,18 @@ namespace IO.Swagger.Test
[Test]
public void ApiResponseInstanceTest()
{
Assert.IsInstanceOfType(typeof(ApiResponse), instance, "instance is a ApiResponse");
// TODO uncomment below to test "IsInstanceOfType" ApiResponse
//Assert.IsInstanceOfType<ApiResponse> (instance, "variable 'instance' is a ApiResponse");
}
/// <summary>
/// Test the property 'Code'
/// </summary>
[Test]
public void CodeTest()
{
// TODO: unit test for the property 'Code'
// TODO unit test for the property 'Code'
}
/// <summary>
/// Test the property 'Type'
@@ -64,7 +80,7 @@ namespace IO.Swagger.Test
[Test]
public void TypeTest()
{
// TODO: unit test for the property 'Type'
// TODO unit test for the property 'Type'
}
/// <summary>
/// Test the property 'Message'
@@ -72,7 +88,7 @@ namespace IO.Swagger.Test
[Test]
public void MessageTest()
{
// TODO: unit test for the property 'Message'
// TODO unit test for the property 'Message'
}
}

View File

@@ -19,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -64,6 +65,7 @@ namespace IO.Swagger.Test
//Assert.IsInstanceOfType<ArrayOfArrayOfNumberOnly> (instance, "variable 'instance' is a ArrayOfArrayOfNumberOnly");
}
/// <summary>
/// Test the property 'ArrayArrayNumber'
/// </summary>

View File

@@ -19,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -64,6 +65,7 @@ namespace IO.Swagger.Test
//Assert.IsInstanceOfType<ArrayOfNumberOnly> (instance, "variable 'instance' is a ArrayOfNumberOnly");
}
/// <summary>
/// Test the property 'ArrayNumber'
/// </summary>

View File

@@ -1,3 +1,14 @@
/*
* Swagger 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: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using NUnit.Framework;
using System;
@@ -8,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -21,7 +33,8 @@ namespace IO.Swagger.Test
[TestFixture]
public class ArrayTestTests
{
private ArrayTest instance;
// TODO uncomment below to declare an instance variable for ArrayTest
//private ArrayTest instance;
/// <summary>
/// Setup before each test
@@ -29,7 +42,8 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
instance = new ArrayTest();
// TODO uncomment below to create an instance of ArrayTest
//instance = new ArrayTest();
}
/// <summary>
@@ -47,10 +61,36 @@ namespace IO.Swagger.Test
[Test]
public void ArrayTestInstanceTest()
{
Assert.IsInstanceOfType(typeof(ArrayTest), instance, "instance is a ArrayTest");
// TODO uncomment below to test "IsInstanceOfType" ArrayTest
//Assert.IsInstanceOfType<ArrayTest> (instance, "variable 'instance' is a ArrayTest");
}
/// <summary>
/// Test the property 'ArrayOfString'
/// </summary>
[Test]
public void ArrayOfStringTest()
{
// TODO unit test for the property 'ArrayOfString'
}
/// <summary>
/// Test the property 'ArrayArrayOfInteger'
/// </summary>
[Test]
public void ArrayArrayOfIntegerTest()
{
// TODO unit test for the property 'ArrayArrayOfInteger'
}
/// <summary>
/// Test the property 'ArrayArrayOfModel'
/// </summary>
[Test]
public void ArrayArrayOfModelTest()
{
// TODO unit test for the property 'ArrayArrayOfModel'
}
}
}

View File

@@ -19,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -64,6 +65,7 @@ namespace IO.Swagger.Test
//Assert.IsInstanceOfType<Capitalization> (instance, "variable 'instance' is a Capitalization");
}
/// <summary>
/// Test the property 'SmallCamel'
/// </summary>

View File

@@ -1,3 +1,14 @@
/*
* Swagger 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: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using NUnit.Framework;
using System;
@@ -8,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -21,7 +33,8 @@ namespace IO.Swagger.Test
[TestFixture]
public class CatTests
{
private Cat instance;
// TODO uncomment below to declare an instance variable for Cat
//private Cat instance;
/// <summary>
/// Setup before each test
@@ -29,7 +42,8 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
instance = new Cat(ClassName: "csharp test");
// TODO uncomment below to create an instance of Cat
//instance = new Cat();
}
/// <summary>
@@ -47,24 +61,18 @@ namespace IO.Swagger.Test
[Test]
public void CatInstanceTest()
{
Assert.IsInstanceOfType(typeof(Cat), instance, "instance is a Cat");
// TODO uncomment below to test "IsInstanceOfType" Cat
//Assert.IsInstanceOfType<Cat> (instance, "variable 'instance' is a Cat");
}
/// <summary>
/// Test the property 'ClassName'
/// </summary>
[Test]
public void ClassNameTest()
{
// TODO: unit test for the property 'ClassName'
}
/// <summary>
/// Test the property 'Declawed'
/// </summary>
[Test]
public void DeclawedTest()
{
// TODO: unit test for the property 'Declawed'
// TODO unit test for the property 'Declawed'
}
}

View File

@@ -1,3 +1,14 @@
/*
* Swagger 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: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using NUnit.Framework;
using System;
@@ -8,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -21,7 +33,8 @@ namespace IO.Swagger.Test
[TestFixture]
public class CategoryTests
{
private Category instance;
// TODO uncomment below to declare an instance variable for Category
//private Category instance;
/// <summary>
/// Setup before each test
@@ -29,7 +42,8 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
instance = new Category();
// TODO uncomment below to create an instance of Category
//instance = new Category();
}
/// <summary>
@@ -47,16 +61,18 @@ namespace IO.Swagger.Test
[Test]
public void CategoryInstanceTest()
{
Assert.IsInstanceOfType(typeof(Category), instance, "instance is a Category");
// TODO uncomment below to test "IsInstanceOfType" Category
//Assert.IsInstanceOfType<Category> (instance, "variable 'instance' is a Category");
}
/// <summary>
/// Test the property 'Id'
/// </summary>
[Test]
public void IdTest()
{
// TODO: unit test for the property 'Id'
// TODO unit test for the property 'Id'
}
/// <summary>
/// Test the property 'Name'
@@ -64,7 +80,7 @@ namespace IO.Swagger.Test
[Test]
public void NameTest()
{
// TODO: unit test for the property 'Name'
// TODO unit test for the property 'Name'
}
}

View File

@@ -19,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -64,6 +65,7 @@ namespace IO.Swagger.Test
//Assert.IsInstanceOfType<ClassModel> (instance, "variable 'instance' is a ClassModel");
}
/// <summary>
/// Test the property '_Class'
/// </summary>

View File

@@ -1,3 +1,14 @@
/*
* Swagger 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: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using NUnit.Framework;
using System;
@@ -8,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -21,7 +33,8 @@ namespace IO.Swagger.Test
[TestFixture]
public class DogTests
{
private Dog instance;
// TODO uncomment below to declare an instance variable for Dog
//private Dog instance;
/// <summary>
/// Setup before each test
@@ -29,7 +42,8 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
instance = new Dog(ClassName: "csharp test");
// TODO uncomment below to create an instance of Dog
//instance = new Dog();
}
/// <summary>
@@ -47,24 +61,18 @@ namespace IO.Swagger.Test
[Test]
public void DogInstanceTest()
{
Assert.IsInstanceOfType(typeof(Dog), instance, "instance is a Dog");
// TODO uncomment below to test "IsInstanceOfType" Dog
//Assert.IsInstanceOfType<Dog> (instance, "variable 'instance' is a Dog");
}
/// <summary>
/// Test the property 'ClassName'
/// </summary>
[Test]
public void ClassNameTest()
{
// TODO: unit test for the property 'ClassName'
}
/// <summary>
/// Test the property 'Breed'
/// </summary>
[Test]
public void BreedTest()
{
// TODO: unit test for the property 'Breed'
// TODO unit test for the property 'Breed'
}
}

View File

@@ -19,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -64,6 +65,7 @@ namespace IO.Swagger.Test
//Assert.IsInstanceOfType<EnumArrays> (instance, "variable 'instance' is a EnumArrays");
}
/// <summary>
/// Test the property 'JustSymbol'
/// </summary>

View File

@@ -1,3 +1,14 @@
/*
* Swagger 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: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using NUnit.Framework;
using System;
@@ -8,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -21,7 +33,8 @@ namespace IO.Swagger.Test
[TestFixture]
public class EnumClassTests
{
private EnumClass instance;
// TODO uncomment below to declare an instance variable for EnumClass
//private EnumClass instance;
/// <summary>
/// Setup before each test
@@ -29,7 +42,8 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
instance = new EnumClass();
// TODO uncomment below to create an instance of EnumClass
//instance = new EnumClass();
}
/// <summary>
@@ -47,25 +61,11 @@ namespace IO.Swagger.Test
[Test]
public void EnumClassInstanceTest()
{
Assert.IsInstanceOfType(typeof(EnumClass), instance, "instance is a EnumClass");
// TODO uncomment below to test "IsInstanceOfType" EnumClass
//Assert.IsInstanceOfType<EnumClass> (instance, "variable 'instance' is a EnumClass");
}
/// <summary>
/// Test EnumClass
/// </summary>
[Test]
public void EnumClassValueTest ()
{
// test serialization for string
Assert.AreEqual (Newtonsoft.Json.JsonConvert.SerializeObject(EnumClass.Abc), "\"_abc\"");
// test serialization for number
Assert.AreEqual (Newtonsoft.Json.JsonConvert.SerializeObject(EnumTest.EnumIntegerEnum.NUMBER_MINUS_1), "\"-1\"");
// test cast to int
Assert.AreEqual ((int)EnumTest.EnumIntegerEnum.NUMBER_MINUS_1, -1);
}
}

View File

@@ -1,3 +1,14 @@
/*
* Swagger 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: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using NUnit.Framework;
using System;
@@ -8,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -21,7 +33,8 @@ namespace IO.Swagger.Test
[TestFixture]
public class EnumTestTests
{
private EnumTest instance;
// TODO uncomment below to declare an instance variable for EnumTest
//private EnumTest instance;
/// <summary>
/// Setup before each test
@@ -29,7 +42,8 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
instance = new EnumTest();
// TODO uncomment below to create an instance of EnumTest
//instance = new EnumTest();
}
/// <summary>
@@ -47,16 +61,18 @@ namespace IO.Swagger.Test
[Test]
public void EnumTestInstanceTest()
{
Assert.IsInstanceOfType(typeof(EnumTest), instance, "instance is a EnumTest");
// TODO uncomment below to test "IsInstanceOfType" EnumTest
//Assert.IsInstanceOfType<EnumTest> (instance, "variable 'instance' is a EnumTest");
}
/// <summary>
/// Test the property 'EnumString'
/// </summary>
[Test]
public void EnumStringTest()
{
// TODO: unit test for the property 'EnumString'
// TODO unit test for the property 'EnumString'
}
/// <summary>
/// Test the property 'EnumInteger'
@@ -64,7 +80,7 @@ namespace IO.Swagger.Test
[Test]
public void EnumIntegerTest()
{
// TODO: unit test for the property 'EnumInteger'
// TODO unit test for the property 'EnumInteger'
}
/// <summary>
/// Test the property 'EnumNumber'
@@ -72,7 +88,15 @@ namespace IO.Swagger.Test
[Test]
public void EnumNumberTest()
{
// TODO: unit test for the property 'EnumNumber'
// TODO unit test for the property 'EnumNumber'
}
/// <summary>
/// Test the property 'OuterEnum'
/// </summary>
[Test]
public void OuterEnumTest()
{
// TODO unit test for the property 'OuterEnum'
}
}

View File

@@ -1,3 +1,14 @@
/*
* Swagger 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: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using NUnit.Framework;
using System;
@@ -22,7 +33,8 @@ namespace IO.Swagger.Test
[TestFixture]
public class FormatTestTests
{
private FormatTest instance;
// TODO uncomment below to declare an instance variable for FormatTest
//private FormatTest instance;
/// <summary>
/// Setup before each test
@@ -30,7 +42,8 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
instance = new FormatTest(Number: 123, _Byte: new byte[] { 0x20 }, Date: new DateTime(2015, 1, 18), Password: "xyz");
// TODO uncomment below to create an instance of FormatTest
//instance = new FormatTest();
}
/// <summary>
@@ -48,16 +61,18 @@ namespace IO.Swagger.Test
[Test]
public void FormatTestInstanceTest()
{
Assert.IsInstanceOfType(typeof(FormatTest), instance, "instance is a FormatTest");
// TODO uncomment below to test "IsInstanceOfType" FormatTest
//Assert.IsInstanceOfType<FormatTest> (instance, "variable 'instance' is a FormatTest");
}
/// <summary>
/// Test the property 'Integer'
/// </summary>
[Test]
public void IntegerTest()
{
// TODO: unit test for the property 'Integer'
// TODO unit test for the property 'Integer'
}
/// <summary>
/// Test the property 'Int32'
@@ -65,7 +80,7 @@ namespace IO.Swagger.Test
[Test]
public void Int32Test()
{
// TODO: unit test for the property 'Int32'
// TODO unit test for the property 'Int32'
}
/// <summary>
/// Test the property 'Int64'
@@ -73,7 +88,7 @@ namespace IO.Swagger.Test
[Test]
public void Int64Test()
{
// TODO: unit test for the property 'Int64'
// TODO unit test for the property 'Int64'
}
/// <summary>
/// Test the property 'Number'
@@ -81,7 +96,7 @@ namespace IO.Swagger.Test
[Test]
public void NumberTest()
{
// TODO: unit test for the property 'Number'
// TODO unit test for the property 'Number'
}
/// <summary>
/// Test the property '_Float'
@@ -89,7 +104,7 @@ namespace IO.Swagger.Test
[Test]
public void _FloatTest()
{
// TODO: unit test for the property '_Float'
// TODO unit test for the property '_Float'
}
/// <summary>
/// Test the property '_Double'
@@ -97,7 +112,7 @@ namespace IO.Swagger.Test
[Test]
public void _DoubleTest()
{
// TODO: unit test for the property '_Double'
// TODO unit test for the property '_Double'
}
/// <summary>
/// Test the property '_String'
@@ -105,7 +120,7 @@ namespace IO.Swagger.Test
[Test]
public void _StringTest()
{
// TODO: unit test for the property '_String'
// TODO unit test for the property '_String'
}
/// <summary>
/// Test the property '_Byte'
@@ -113,7 +128,7 @@ namespace IO.Swagger.Test
[Test]
public void _ByteTest()
{
// TODO: unit test for the property '_Byte'
// TODO unit test for the property '_Byte'
}
/// <summary>
/// Test the property 'Binary'
@@ -121,7 +136,7 @@ namespace IO.Swagger.Test
[Test]
public void BinaryTest()
{
// TODO: unit test for the property 'Binary'
// TODO unit test for the property 'Binary'
}
/// <summary>
/// Test the property 'Date'
@@ -129,23 +144,7 @@ namespace IO.Swagger.Test
[Test]
public void DateTest()
{
var item = new FormatTest(Integer: 1,
Int32: 1,
Int64: 1,
Number: 1,
_Float: 1.0f,
_Double: 1.0d,
_String: "",
_Byte: new byte[0],
Binary: null,
Date: new DateTime(year: 2000, month: 5, day: 13),
DateTime: null,
Uuid: null,
Password: "");
var serialized = JsonConvert.SerializeObject(item);
Console.WriteLine(serialized);
Assert.Greater(serialized.IndexOf("\"2000-05-13\""), 0);
// TODO unit test for the property 'Date'
}
/// <summary>
/// Test the property 'DateTime'
@@ -153,7 +152,7 @@ namespace IO.Swagger.Test
[Test]
public void DateTimeTest()
{
// TODO: unit test for the property 'DateTime'
// TODO unit test for the property 'DateTime'
}
/// <summary>
/// Test the property 'Uuid'
@@ -161,7 +160,7 @@ namespace IO.Swagger.Test
[Test]
public void UuidTest()
{
// TODO: unit test for the property 'Uuid'
// TODO unit test for the property 'Uuid'
}
/// <summary>
/// Test the property 'Password'
@@ -169,7 +168,7 @@ namespace IO.Swagger.Test
[Test]
public void PasswordTest()
{
// TODO: unit test for the property 'Password'
// TODO unit test for the property 'Password'
}
}

View File

@@ -19,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -64,6 +65,7 @@ namespace IO.Swagger.Test
//Assert.IsInstanceOfType<HasOnlyReadOnly> (instance, "variable 'instance' is a HasOnlyReadOnly");
}
/// <summary>
/// Test the property 'Bar'
/// </summary>

View File

@@ -19,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -64,6 +65,7 @@ namespace IO.Swagger.Test
//Assert.IsInstanceOfType<List> (instance, "variable 'instance' is a List");
}
/// <summary>
/// Test the property '_123List'
/// </summary>

View File

@@ -19,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -64,6 +65,7 @@ namespace IO.Swagger.Test
//Assert.IsInstanceOfType<MapTest> (instance, "variable 'instance' is a MapTest");
}
/// <summary>
/// Test the property 'MapMapOfString'
/// </summary>

View File

@@ -1,3 +1,14 @@
/*
* Swagger 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: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using NUnit.Framework;
using System;
@@ -8,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -21,7 +33,8 @@ namespace IO.Swagger.Test
[TestFixture]
public class MixedPropertiesAndAdditionalPropertiesClassTests
{
private MixedPropertiesAndAdditionalPropertiesClass instance;
// TODO uncomment below to declare an instance variable for MixedPropertiesAndAdditionalPropertiesClass
//private MixedPropertiesAndAdditionalPropertiesClass instance;
/// <summary>
/// Setup before each test
@@ -29,7 +42,8 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
instance = new MixedPropertiesAndAdditionalPropertiesClass();
// TODO uncomment below to create an instance of MixedPropertiesAndAdditionalPropertiesClass
//instance = new MixedPropertiesAndAdditionalPropertiesClass();
}
/// <summary>
@@ -47,16 +61,18 @@ namespace IO.Swagger.Test
[Test]
public void MixedPropertiesAndAdditionalPropertiesClassInstanceTest()
{
Assert.IsInstanceOfType(typeof(MixedPropertiesAndAdditionalPropertiesClass), instance, "instance is a MixedPropertiesAndAdditionalPropertiesClass");
// TODO uncomment below to test "IsInstanceOfType" MixedPropertiesAndAdditionalPropertiesClass
//Assert.IsInstanceOfType<MixedPropertiesAndAdditionalPropertiesClass> (instance, "variable 'instance' is a MixedPropertiesAndAdditionalPropertiesClass");
}
/// <summary>
/// Test the property 'Uuid'
/// </summary>
[Test]
public void UuidTest()
{
// TODO: unit test for the property 'Uuid'
// TODO unit test for the property 'Uuid'
}
/// <summary>
/// Test the property 'DateTime'
@@ -64,7 +80,15 @@ namespace IO.Swagger.Test
[Test]
public void DateTimeTest()
{
// TODO: unit test for the property 'DateTime'
// TODO unit test for the property 'DateTime'
}
/// <summary>
/// Test the property 'Map'
/// </summary>
[Test]
public void MapTest()
{
// TODO unit test for the property 'Map'
}
}

View File

@@ -1,3 +1,14 @@
/*
* Swagger 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: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using NUnit.Framework;
using System;
@@ -8,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -21,7 +33,8 @@ namespace IO.Swagger.Test
[TestFixture]
public class Model200ResponseTests
{
private Model200Response instance;
// TODO uncomment below to declare an instance variable for Model200Response
//private Model200Response instance;
/// <summary>
/// Setup before each test
@@ -29,7 +42,8 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
instance = new Model200Response();
// TODO uncomment below to create an instance of Model200Response
//instance = new Model200Response();
}
/// <summary>
@@ -47,16 +61,26 @@ namespace IO.Swagger.Test
[Test]
public void Model200ResponseInstanceTest()
{
Assert.IsInstanceOfType(typeof(Model200Response), instance, "instance is a Model200Response");
// TODO uncomment below to test "IsInstanceOfType" Model200Response
//Assert.IsInstanceOfType<Model200Response> (instance, "variable 'instance' is a Model200Response");
}
/// <summary>
/// Test the property 'Name'
/// </summary>
[Test]
public void NameTest()
{
// TODO: unit test for the property 'Name'
// TODO unit test for the property 'Name'
}
/// <summary>
/// Test the property '_Class'
/// </summary>
[Test]
public void _ClassTest()
{
// TODO unit test for the property '_Class'
}
}

View File

@@ -19,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -64,6 +65,7 @@ namespace IO.Swagger.Test
//Assert.IsInstanceOfType<ModelClient> (instance, "variable 'instance' is a ModelClient");
}
/// <summary>
/// Test the property '_Client'
/// </summary>

View File

@@ -1,3 +1,14 @@
/*
* Swagger 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: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using NUnit.Framework;
using System;
@@ -8,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -21,7 +33,8 @@ namespace IO.Swagger.Test
[TestFixture]
public class ModelReturnTests
{
private ModelReturn instance;
// TODO uncomment below to declare an instance variable for ModelReturn
//private ModelReturn instance;
/// <summary>
/// Setup before each test
@@ -29,7 +42,8 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
instance = new ModelReturn();
// TODO uncomment below to create an instance of ModelReturn
//instance = new ModelReturn();
}
/// <summary>
@@ -47,16 +61,18 @@ namespace IO.Swagger.Test
[Test]
public void ModelReturnInstanceTest()
{
Assert.IsInstanceOfType(typeof(ModelReturn), instance, "instance is a ModelReturn");
// TODO uncomment below to test "IsInstanceOfType" ModelReturn
//Assert.IsInstanceOfType<ModelReturn> (instance, "variable 'instance' is a ModelReturn");
}
/// <summary>
/// Test the property '_Return'
/// </summary>
[Test]
public void _ReturnTest()
{
// TODO: unit test for the property '_Return'
// TODO unit test for the property '_Return'
}
}

View File

@@ -1,3 +1,14 @@
/*
* Swagger 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: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using NUnit.Framework;
using System;
@@ -8,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -21,7 +33,8 @@ namespace IO.Swagger.Test
[TestFixture]
public class NameTests
{
private Name instance;
// TODO uncomment below to declare an instance variable for Name
//private Name instance;
/// <summary>
/// Setup before each test
@@ -29,7 +42,8 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
instance = new Name(_Name: 1, Property: "csharp");
// TODO uncomment below to create an instance of Name
//instance = new Name();
}
/// <summary>
@@ -47,16 +61,18 @@ namespace IO.Swagger.Test
[Test]
public void NameInstanceTest()
{
Assert.IsInstanceOfType(typeof(Name), instance, "instance is a Name");
// TODO uncomment below to test "IsInstanceOfType" Name
//Assert.IsInstanceOfType<Name> (instance, "variable 'instance' is a Name");
}
/// <summary>
/// Test the property '_Name'
/// </summary>
[Test]
public void _NameTest()
{
// TODO: unit test for the property '_Name'
// TODO unit test for the property '_Name'
}
/// <summary>
/// Test the property 'SnakeCase'
@@ -64,7 +80,7 @@ namespace IO.Swagger.Test
[Test]
public void SnakeCaseTest()
{
// TODO: unit test for the property 'SnakeCase'
// TODO unit test for the property 'SnakeCase'
}
/// <summary>
/// Test the property 'Property'
@@ -72,7 +88,15 @@ namespace IO.Swagger.Test
[Test]
public void PropertyTest()
{
// TODO: unit test for the property 'Property'
// TODO unit test for the property 'Property'
}
/// <summary>
/// Test the property '_123Number'
/// </summary>
[Test]
public void _123NumberTest()
{
// TODO unit test for the property '_123Number'
}
}

View File

@@ -19,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -64,6 +65,7 @@ namespace IO.Swagger.Test
//Assert.IsInstanceOfType<NumberOnly> (instance, "variable 'instance' is a NumberOnly");
}
/// <summary>
/// Test the property 'JustNumber'
/// </summary>

View File

@@ -1,3 +1,14 @@
/*
* Swagger 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: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using NUnit.Framework;
using System;
@@ -8,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -21,7 +33,8 @@ namespace IO.Swagger.Test
[TestFixture]
public class OrderTests
{
private Order instance;
// TODO uncomment below to declare an instance variable for Order
//private Order instance;
/// <summary>
/// Setup before each test
@@ -29,7 +42,8 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
instance = new Order();
// TODO uncomment below to create an instance of Order
//instance = new Order();
}
/// <summary>
@@ -41,32 +55,24 @@ namespace IO.Swagger.Test
}
/// <summary>
/// Test creating a new instance of Order
/// </summary>
[Test ()]
public void TestNewOrder()
{
Order o = new Order ();
Assert.IsNull (o.Id);
}
/// <summary>
/// Test an instance of Order
/// </summary>
[Test]
public void OrderInstanceTest()
{
Assert.IsInstanceOfType(typeof(Order), instance, "instance is a Order");
// TODO uncomment below to test "IsInstanceOfType" Order
//Assert.IsInstanceOfType<Order> (instance, "variable 'instance' is a Order");
}
/// <summary>
/// Test the property 'Id'
/// </summary>
[Test]
public void IdTest()
{
// TODO: unit test for the property 'Id'
// TODO unit test for the property 'Id'
}
/// <summary>
/// Test the property 'PetId'
@@ -74,7 +80,7 @@ namespace IO.Swagger.Test
[Test]
public void PetIdTest()
{
// TODO: unit test for the property 'PetId'
// TODO unit test for the property 'PetId'
}
/// <summary>
/// Test the property 'Quantity'
@@ -82,7 +88,7 @@ namespace IO.Swagger.Test
[Test]
public void QuantityTest()
{
// TODO: unit test for the property 'Quantity'
// TODO unit test for the property 'Quantity'
}
/// <summary>
/// Test the property 'ShipDate'
@@ -90,7 +96,7 @@ namespace IO.Swagger.Test
[Test]
public void ShipDateTest()
{
// TODO: unit test for the property 'ShipDate'
// TODO unit test for the property 'ShipDate'
}
/// <summary>
/// Test the property 'Status'
@@ -98,7 +104,7 @@ namespace IO.Swagger.Test
[Test]
public void StatusTest()
{
// TODO: unit test for the property 'Status'
// TODO unit test for the property 'Status'
}
/// <summary>
/// Test the property 'Complete'
@@ -106,7 +112,7 @@ namespace IO.Swagger.Test
[Test]
public void CompleteTest()
{
// TODO: unit test for the property 'Complete'
// TODO unit test for the property 'Complete'
}
}

View File

@@ -19,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -65,6 +66,7 @@ namespace IO.Swagger.Test
}
}
}

View File

@@ -19,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -64,6 +65,7 @@ namespace IO.Swagger.Test
//Assert.IsInstanceOfType<OuterComposite> (instance, "variable 'instance' is a OuterComposite");
}
/// <summary>
/// Test the property 'MyNumber'
/// </summary>

View File

@@ -19,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -65,6 +66,7 @@ namespace IO.Swagger.Test
}
}
}

View File

@@ -19,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -65,6 +66,7 @@ namespace IO.Swagger.Test
}
}
}

View File

@@ -19,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -65,6 +66,7 @@ namespace IO.Swagger.Test
}
}
}

View File

@@ -1,3 +1,14 @@
/*
* Swagger 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: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using NUnit.Framework;
using System;
@@ -8,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -21,9 +33,8 @@ namespace IO.Swagger.Test
[TestFixture]
public class PetTests
{
private Pet instance;
private long petId = 11088;
// TODO uncomment below to declare an instance variable for Pet
//private Pet instance;
/// <summary>
/// Setup before each test
@@ -31,7 +42,8 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
instance = new Pet(Name: "Csharp test", PhotoUrls: new List<string> { "http://petstore.com/csharp_test" });
// TODO uncomment below to create an instance of Pet
//instance = new Pet();
}
/// <summary>
@@ -49,16 +61,18 @@ namespace IO.Swagger.Test
[Test]
public void PetInstanceTest()
{
Assert.IsInstanceOfType(typeof(Pet), instance, "instance is a Pet");
// TODO uncomment below to test "IsInstanceOfType" Pet
//Assert.IsInstanceOfType<Pet> (instance, "variable 'instance' is a Pet");
}
/// <summary>
/// Test the property 'Id'
/// </summary>
[Test]
public void IdTest()
{
// TODO: unit test for the property 'Id'
// TODO unit test for the property 'Id'
}
/// <summary>
/// Test the property 'Category'
@@ -66,7 +80,7 @@ namespace IO.Swagger.Test
[Test]
public void CategoryTest()
{
// TODO: unit test for the property 'Category'
// TODO unit test for the property 'Category'
}
/// <summary>
/// Test the property 'Name'
@@ -74,7 +88,7 @@ namespace IO.Swagger.Test
[Test]
public void NameTest()
{
// TODO: unit test for the property 'Name'
// TODO unit test for the property 'Name'
}
/// <summary>
/// Test the property 'PhotoUrls'
@@ -82,7 +96,7 @@ namespace IO.Swagger.Test
[Test]
public void PhotoUrlsTest()
{
// TODO: unit test for the property 'PhotoUrls'
// TODO unit test for the property 'PhotoUrls'
}
/// <summary>
/// Test the property 'Tags'
@@ -90,7 +104,7 @@ namespace IO.Swagger.Test
[Test]
public void TagsTest()
{
// TODO: unit test for the property 'Tags'
// TODO unit test for the property 'Tags'
}
/// <summary>
/// Test the property 'Status'
@@ -98,72 +112,9 @@ namespace IO.Swagger.Test
[Test]
public void StatusTest()
{
// TODO: unit test for the property 'Status'
// TODO unit test for the property 'Status'
}
/// <summary>
/// Test Equal
/// </summary>
[Test ()]
public void TestEqual()
{
// create pet
Pet p1 = new Pet (Name: "Csharp test", PhotoUrls: new List<string> { "http://petstore.com/csharp_test" });
p1.Id = petId;
//p1.Name = "Csharp test";
p1.Status = Pet.StatusEnum.Available;
// create Category object
Category category1 = new Category ();
category1.Id = 56;
category1.Name = "sample category name2";
List<String> photoUrls1 = new List<String> (new String[] { "sample photoUrls" });
// create Tag object
Tag tag1 = new Tag ();
tag1.Id = petId;
tag1.Name = "csharp sample tag name1";
List<Tag> tags1 = new List<Tag> (new Tag[] { tag1 });
p1.Tags = tags1;
p1.Category = category1;
p1.PhotoUrls = photoUrls1;
// create pet 2
Pet p2 = new Pet (Name: "Csharp test", PhotoUrls: new List<string> { "http://petstore.com/csharp_test" });
p2.Id = petId;
p2.Name = "Csharp test";
p2.Status = Pet.StatusEnum.Available;
// create Category object
Category category2 = new Category ();
category2.Id = 56;
category2.Name = "sample category name2";
List<String> photoUrls2 = new List<String> (new String[] { "sample photoUrls" });
// create Tag object
Tag tag2 = new Tag ();
tag2.Id = petId;
tag2.Name = "csharp sample tag name1";
List<Tag> tags2 = new List<Tag> (new Tag[] { tag2 });
p2.Tags = tags2;
p2.Category = category2;
p2.PhotoUrls = photoUrls2;
// p1 and p2 should be equal (both object and attribute level)
Assert.IsTrue (category1.Equals (category2));
Assert.IsTrue (tags1.SequenceEqual (tags2));
Assert.IsTrue (p1.PhotoUrls.SequenceEqual (p2.PhotoUrls));
Assert.IsTrue (p1.Equals (p2));
// update attribute to that p1 and p2 are not equal
category2.Name = "new category name";
Assert.IsFalse (category1.Equals (category2));
tags2 = new List<Tag> ();
Assert.IsFalse (tags1.SequenceEqual (tags2));
// photoUrls has not changed so it should be equal
Assert.IsTrue (p1.PhotoUrls.SequenceEqual (p2.PhotoUrls));
Assert.IsFalse (p1.Equals (p2));
}
}
}

View File

@@ -1,3 +1,14 @@
/*
* Swagger 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: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using NUnit.Framework;
using System;
@@ -8,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -21,7 +33,8 @@ namespace IO.Swagger.Test
[TestFixture]
public class ReadOnlyFirstTests
{
private ReadOnlyFirst instance;
// TODO uncomment below to declare an instance variable for ReadOnlyFirst
//private ReadOnlyFirst instance;
/// <summary>
/// Setup before each test
@@ -29,7 +42,8 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
instance = new ReadOnlyFirst();
// TODO uncomment below to create an instance of ReadOnlyFirst
//instance = new ReadOnlyFirst();
}
/// <summary>
@@ -47,16 +61,18 @@ namespace IO.Swagger.Test
[Test]
public void ReadOnlyFirstInstanceTest()
{
Assert.IsInstanceOfType(typeof(ReadOnlyFirst), instance, "instance is a ReadOnlyFirst");
// TODO uncomment below to test "IsInstanceOfType" ReadOnlyFirst
//Assert.IsInstanceOfType<ReadOnlyFirst> (instance, "variable 'instance' is a ReadOnlyFirst");
}
/// <summary>
/// Test the property 'Bar'
/// </summary>
[Test]
public void BarTest()
{
// TODO: unit test for the property 'Bar'
// TODO unit test for the property 'Bar'
}
/// <summary>
/// Test the property 'Baz'
@@ -64,7 +80,7 @@ namespace IO.Swagger.Test
[Test]
public void BazTest()
{
// TODO: unit test for the property 'Baz'
// TODO unit test for the property 'Baz'
}
}

View File

@@ -1,3 +1,14 @@
/*
* Swagger 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: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using NUnit.Framework;
using System;
@@ -8,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -21,7 +33,8 @@ namespace IO.Swagger.Test
[TestFixture]
public class SpecialModelNameTests
{
private SpecialModelName instance;
// TODO uncomment below to declare an instance variable for SpecialModelName
//private SpecialModelName instance;
/// <summary>
/// Setup before each test
@@ -29,7 +42,8 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
instance = new SpecialModelName();
// TODO uncomment below to create an instance of SpecialModelName
//instance = new SpecialModelName();
}
/// <summary>
@@ -47,16 +61,18 @@ namespace IO.Swagger.Test
[Test]
public void SpecialModelNameInstanceTest()
{
Assert.IsInstanceOfType(typeof(SpecialModelName), instance, "instance is a SpecialModelName");
// TODO uncomment below to test "IsInstanceOfType" SpecialModelName
//Assert.IsInstanceOfType<SpecialModelName> (instance, "variable 'instance' is a SpecialModelName");
}
/// <summary>
/// Test the property 'SpecialPropertyName'
/// </summary>
[Test]
public void SpecialPropertyNameTest()
{
// TODO: unit test for the property 'SpecialPropertyName'
// TODO unit test for the property 'SpecialPropertyName'
}
}

View File

@@ -1,3 +1,14 @@
/*
* Swagger 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: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using NUnit.Framework;
using System;
@@ -8,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -21,7 +33,8 @@ namespace IO.Swagger.Test
[TestFixture]
public class TagTests
{
private Tag instance;
// TODO uncomment below to declare an instance variable for Tag
//private Tag instance;
/// <summary>
/// Setup before each test
@@ -29,7 +42,8 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
instance = new Tag();
// TODO uncomment below to create an instance of Tag
//instance = new Tag();
}
/// <summary>
@@ -47,16 +61,18 @@ namespace IO.Swagger.Test
[Test]
public void TagInstanceTest()
{
Assert.IsInstanceOfType(typeof(Tag), instance, "instance is a Tag");
// TODO uncomment below to test "IsInstanceOfType" Tag
//Assert.IsInstanceOfType<Tag> (instance, "variable 'instance' is a Tag");
}
/// <summary>
/// Test the property 'Id'
/// </summary>
[Test]
public void IdTest()
{
// TODO: unit test for the property 'Id'
// TODO unit test for the property 'Id'
}
/// <summary>
/// Test the property 'Name'
@@ -64,7 +80,7 @@ namespace IO.Swagger.Test
[Test]
public void NameTest()
{
// TODO: unit test for the property 'Name'
// TODO unit test for the property 'Name'
}
}

View File

@@ -1,3 +1,14 @@
/*
* Swagger 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: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using NUnit.Framework;
using System;
@@ -8,6 +19,7 @@ using IO.Swagger.Api;
using IO.Swagger.Model;
using IO.Swagger.Client;
using System.Reflection;
using Newtonsoft.Json;
namespace IO.Swagger.Test
{
@@ -21,7 +33,8 @@ namespace IO.Swagger.Test
[TestFixture]
public class UserTests
{
private User instance;
// TODO uncomment below to declare an instance variable for User
//private User instance;
/// <summary>
/// Setup before each test
@@ -29,7 +42,8 @@ namespace IO.Swagger.Test
[SetUp]
public void Init()
{
instance = new User();
// TODO uncomment below to create an instance of User
//instance = new User();
}
/// <summary>
@@ -47,16 +61,18 @@ namespace IO.Swagger.Test
[Test]
public void UserInstanceTest()
{
Assert.IsInstanceOfType(typeof(User), instance, "instance is a User");
// TODO uncomment below to test "IsInstanceOfType" User
//Assert.IsInstanceOfType<User> (instance, "variable 'instance' is a User");
}
/// <summary>
/// Test the property 'Id'
/// </summary>
[Test]
public void IdTest()
{
// TODO: unit test for the property 'Id'
// TODO unit test for the property 'Id'
}
/// <summary>
/// Test the property 'Username'
@@ -64,7 +80,7 @@ namespace IO.Swagger.Test
[Test]
public void UsernameTest()
{
// TODO: unit test for the property 'Username'
// TODO unit test for the property 'Username'
}
/// <summary>
/// Test the property 'FirstName'
@@ -72,7 +88,7 @@ namespace IO.Swagger.Test
[Test]
public void FirstNameTest()
{
// TODO: unit test for the property 'FirstName'
// TODO unit test for the property 'FirstName'
}
/// <summary>
/// Test the property 'LastName'
@@ -80,7 +96,7 @@ namespace IO.Swagger.Test
[Test]
public void LastNameTest()
{
// TODO: unit test for the property 'LastName'
// TODO unit test for the property 'LastName'
}
/// <summary>
/// Test the property 'Email'
@@ -88,7 +104,7 @@ namespace IO.Swagger.Test
[Test]
public void EmailTest()
{
// TODO: unit test for the property 'Email'
// TODO unit test for the property 'Email'
}
/// <summary>
/// Test the property 'Password'
@@ -96,7 +112,7 @@ namespace IO.Swagger.Test
[Test]
public void PasswordTest()
{
// TODO: unit test for the property 'Password'
// TODO unit test for the property 'Password'
}
/// <summary>
/// Test the property 'Phone'
@@ -104,7 +120,7 @@ namespace IO.Swagger.Test
[Test]
public void PhoneTest()
{
// TODO: unit test for the property 'Phone'
// TODO unit test for the property 'Phone'
}
/// <summary>
/// Test the property 'UserStatus'
@@ -112,7 +128,7 @@ namespace IO.Swagger.Test
[Test]
public void UserStatusTest()
{
// TODO: unit test for the property 'UserStatus'
// TODO unit test for the property 'UserStatus'
}
}

View File

@@ -3,4 +3,5 @@
<package id="NUnit" version="2.6.4" targetFramework="net45" />
<package id="RestSharp" version="105.1.0" targetFramework="net45" developmentDependency="true" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net45" developmentDependency="true" />
<package id="JsonSubTypes" version="1.1.3" targetFramework="net45" developmentDependency="true" />
</packages>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

View File

@@ -1,331 +0,0 @@
/*
* Swagger 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: \" \\
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@swagger.io
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using RestSharp;
using IO.Swagger.Client;
using IO.Swagger.Model;
namespace IO.Swagger.Api
{
/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
public interface IFake_classname_tags123Api : IApiAccessor
{
#region Synchronous Operations
/// <summary>
/// To test class name in snake case
/// </summary>
/// <remarks>
///
/// </remarks>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="body">client model</param>
/// <returns>ModelClient</returns>
ModelClient TestClassname (ModelClient body);
/// <summary>
/// To test class name in snake case
/// </summary>
/// <remarks>
///
/// </remarks>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="body">client model</param>
/// <returns>ApiResponse of ModelClient</returns>
ApiResponse<ModelClient> TestClassnameWithHttpInfo (ModelClient body);
#endregion Synchronous Operations
#region Asynchronous Operations
/// <summary>
/// To test class name in snake case
/// </summary>
/// <remarks>
///
/// </remarks>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="body">client model</param>
/// <returns>Task of ModelClient</returns>
System.Threading.Tasks.Task<ModelClient> TestClassnameAsync (ModelClient body);
/// <summary>
/// To test class name in snake case
/// </summary>
/// <remarks>
///
/// </remarks>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="body">client model</param>
/// <returns>Task of ApiResponse (ModelClient)</returns>
System.Threading.Tasks.Task<ApiResponse<ModelClient>> TestClassnameAsyncWithHttpInfo (ModelClient body);
#endregion Asynchronous Operations
}
/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
public partial class Fake_classname_tags123Api : IFake_classname_tags123Api
{
private IO.Swagger.Client.ExceptionFactory _exceptionFactory = (name, response) => null;
/// <summary>
/// Initializes a new instance of the <see cref="Fake_classname_tags123Api"/> class.
/// </summary>
/// <returns></returns>
public Fake_classname_tags123Api(String basePath)
{
this.Configuration = new Configuration { BasePath = basePath };
ExceptionFactory = IO.Swagger.Client.Configuration.DefaultExceptionFactory;
}
/// <summary>
/// Initializes a new instance of the <see cref="Fake_classname_tags123Api"/> class
/// using Configuration object
/// </summary>
/// <param name="configuration">An instance of Configuration</param>
/// <returns></returns>
public Fake_classname_tags123Api(Configuration configuration = null)
{
if (configuration == null) // use the default one in Configuration
this.Configuration = Configuration.Default;
else
this.Configuration = configuration;
ExceptionFactory = IO.Swagger.Client.Configuration.DefaultExceptionFactory;
}
/// <summary>
/// Gets the base path of the API client.
/// </summary>
/// <value>The base path</value>
public String GetBasePath()
{
return this.Configuration.ApiClient.RestClient.BaseUrl.ToString();
}
/// <summary>
/// Sets the base path of the API client.
/// </summary>
/// <value>The base path</value>
[Obsolete("SetBasePath is deprecated, please do 'Configuration.ApiClient = new ApiClient(\"http://new-path\")' instead.")]
public void SetBasePath(String basePath)
{
// do nothing
}
/// <summary>
/// Gets or sets the configuration object
/// </summary>
/// <value>An instance of the Configuration</value>
public Configuration Configuration {get; set;}
/// <summary>
/// Provides a factory method hook for the creation of exceptions.
/// </summary>
public IO.Swagger.Client.ExceptionFactory ExceptionFactory
{
get
{
if (_exceptionFactory != null && _exceptionFactory.GetInvocationList().Length > 1)
{
throw new InvalidOperationException("Multicast delegate for ExceptionFactory is unsupported.");
}
return _exceptionFactory;
}
set { _exceptionFactory = value; }
}
/// <summary>
/// Gets the default header.
/// </summary>
/// <returns>Dictionary of HTTP header</returns>
[Obsolete("DefaultHeader is deprecated, please use Configuration.DefaultHeader instead.")]
public IDictionary<String, String> DefaultHeader()
{
return new ReadOnlyDictionary<string, string>(this.Configuration.DefaultHeader);
}
/// <summary>
/// Add default header.
/// </summary>
/// <param name="key">Header field name.</param>
/// <param name="value">Header field value.</param>
/// <returns></returns>
[Obsolete("AddDefaultHeader is deprecated, please use Configuration.AddDefaultHeader instead.")]
public void AddDefaultHeader(string key, string value)
{
this.Configuration.AddDefaultHeader(key, value);
}
/// <summary>
/// To test class name in snake case
/// </summary>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="body">client model</param>
/// <returns>ModelClient</returns>
public ModelClient TestClassname (ModelClient body)
{
ApiResponse<ModelClient> localVarResponse = TestClassnameWithHttpInfo(body);
return localVarResponse.Data;
}
/// <summary>
/// To test class name in snake case
/// </summary>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="body">client model</param>
/// <returns>ApiResponse of ModelClient</returns>
public ApiResponse< ModelClient > TestClassnameWithHttpInfo (ModelClient body)
{
// verify the required parameter 'body' is set
if (body == null)
throw new ApiException(400, "Missing required parameter 'body' when calling Fake_classname_tags123Api->TestClassname");
var localVarPath = "/fake_classname_test";
var localVarPathParams = new Dictionary<String, String>();
var localVarQueryParams = new List<KeyValuePair<String, String>>();
var localVarHeaderParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var localVarFormParams = new Dictionary<String, String>();
var localVarFileParams = new Dictionary<String, FileParameter>();
Object localVarPostBody = null;
// to determine the Content-Type header
String[] localVarHttpContentTypes = new String[] {
"application/json"
};
String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);
// to determine the Accept header
String[] localVarHttpHeaderAccepts = new String[] {
"application/json"
};
String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
if (localVarHttpHeaderAccept != null)
localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
if (body != null && body.GetType() != typeof(byte[]))
{
localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter
}
else
{
localVarPostBody = body; // byte array
}
// authentication (api_key_query) required
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key_query")))
{
localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "api_key_query", Configuration.GetApiKeyWithPrefix("api_key_query")));
}
// make the HTTP request
IRestResponse localVarResponse = (IRestResponse) Configuration.ApiClient.CallApi(localVarPath,
Method.PATCH, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
localVarPathParams, localVarHttpContentType);
int localVarStatusCode = (int) localVarResponse.StatusCode;
if (ExceptionFactory != null)
{
Exception exception = ExceptionFactory("TestClassname", localVarResponse);
if (exception != null) throw exception;
}
return new ApiResponse<ModelClient>(localVarStatusCode,
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
(ModelClient) Configuration.ApiClient.Deserialize(localVarResponse, typeof(ModelClient)));
}
/// <summary>
/// To test class name in snake case
/// </summary>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="body">client model</param>
/// <returns>Task of ModelClient</returns>
public async System.Threading.Tasks.Task<ModelClient> TestClassnameAsync (ModelClient body)
{
ApiResponse<ModelClient> localVarResponse = await TestClassnameAsyncWithHttpInfo(body);
return localVarResponse.Data;
}
/// <summary>
/// To test class name in snake case
/// </summary>
/// <exception cref="IO.Swagger.Client.ApiException">Thrown when fails to make API call</exception>
/// <param name="body">client model</param>
/// <returns>Task of ApiResponse (ModelClient)</returns>
public async System.Threading.Tasks.Task<ApiResponse<ModelClient>> TestClassnameAsyncWithHttpInfo (ModelClient body)
{
// verify the required parameter 'body' is set
if (body == null)
throw new ApiException(400, "Missing required parameter 'body' when calling Fake_classname_tags123Api->TestClassname");
var localVarPath = "/fake_classname_test";
var localVarPathParams = new Dictionary<String, String>();
var localVarQueryParams = new List<KeyValuePair<String, String>>();
var localVarHeaderParams = new Dictionary<String, String>(Configuration.DefaultHeader);
var localVarFormParams = new Dictionary<String, String>();
var localVarFileParams = new Dictionary<String, FileParameter>();
Object localVarPostBody = null;
// to determine the Content-Type header
String[] localVarHttpContentTypes = new String[] {
"application/json"
};
String localVarHttpContentType = Configuration.ApiClient.SelectHeaderContentType(localVarHttpContentTypes);
// to determine the Accept header
String[] localVarHttpHeaderAccepts = new String[] {
"application/json"
};
String localVarHttpHeaderAccept = Configuration.ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts);
if (localVarHttpHeaderAccept != null)
localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept);
if (body != null && body.GetType() != typeof(byte[]))
{
localVarPostBody = Configuration.ApiClient.Serialize(body); // http body (model) parameter
}
else
{
localVarPostBody = body; // byte array
}
// authentication (api_key_query) required
if (!String.IsNullOrEmpty(Configuration.GetApiKeyWithPrefix("api_key_query")))
{
localVarQueryParams.AddRange(Configuration.ApiClient.ParameterToKeyValuePairs("", "api_key_query", Configuration.GetApiKeyWithPrefix("api_key_query")));
}
// make the HTTP request
IRestResponse localVarResponse = (IRestResponse) await Configuration.ApiClient.CallApiAsync(localVarPath,
Method.PATCH, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams,
localVarPathParams, localVarHttpContentType);
int localVarStatusCode = (int) localVarResponse.StatusCode;
if (ExceptionFactory != null)
{
Exception exception = ExceptionFactory("TestClassname", localVarResponse);
if (exception != null) throw exception;
}
return new ApiResponse<ModelClient>(localVarStatusCode,
localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
(ModelClient) Configuration.ApiClient.Deserialize(localVarResponse, typeof(ModelClient)));
}
}
}

View File

@@ -1,272 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace JsonSubTypes
{
// Copied from project https://github.com/manuc66/JsonSubTypes
// https://raw.githubusercontent.com/manuc66/JsonSubTypes/07403192ea3f4959f6d42f5966ac56ceb0d6095b/JsonSubTypes/JsonSubtypes.cs
public class JsonSubtypes : JsonConverter
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true)]
public class KnownSubTypeAttribute : Attribute
{
public Type SubType { get; private set; }
public object AssociatedValue { get; private set; }
public KnownSubTypeAttribute(Type subType, object associatedValue)
{
SubType = subType;
AssociatedValue = associatedValue;
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true)]
public class KnownSubTypeWithPropertyAttribute : Attribute
{
public Type SubType { get; private set; }
public string PropertyName { get; private set; }
public KnownSubTypeWithPropertyAttribute(Type subType, string propertyName)
{
SubType = subType;
PropertyName = propertyName;
}
}
private readonly string _typeMappingPropertyName;
private bool _isInsideRead;
private JsonReader _reader;
public override bool CanRead
{
get
{
if (!_isInsideRead)
return true;
return !string.IsNullOrEmpty(_reader.Path);
}
}
public sealed override bool CanWrite
{
get { return false; }
}
public JsonSubtypes()
{
}
public JsonSubtypes(string typeMappingPropertyName)
{
_typeMappingPropertyName = typeMappingPropertyName;
}
public override bool CanConvert(Type objectType)
{
return _typeMappingPropertyName != null;
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
throw new NotImplementedException();
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Comment)
reader.Read();
switch (reader.TokenType)
{
case JsonToken.Null:
return null;
case JsonToken.StartArray:
return ReadArray(reader, objectType, serializer);
case JsonToken.StartObject:
return ReadObject(reader, objectType, serializer);
default:
throw new Exception("Array: Unrecognized token: " + reader.TokenType);
}
}
private IList ReadArray(JsonReader reader, Type targetType, JsonSerializer serializer)
{
var elementType = GetElementType(targetType);
var list = CreateCompatibleList(targetType, elementType);
while (reader.TokenType != JsonToken.EndArray && reader.Read())
{
switch (reader.TokenType)
{
case JsonToken.Null:
list.Add(reader.Value);
break;
case JsonToken.Comment:
break;
case JsonToken.StartObject:
list.Add(ReadObject(reader, elementType, serializer));
break;
case JsonToken.EndArray:
break;
default:
throw new Exception("Array: Unrecognized token: " + reader.TokenType);
}
}
if (targetType.IsArray)
{
var array = Array.CreateInstance(targetType.GetElementType(), list.Count);
list.CopyTo(array, 0);
list = array;
}
return list;
}
private static IList CreateCompatibleList(Type targetContainerType, Type elementType)
{
IList list;
if (targetContainerType.IsArray || targetContainerType.GetTypeInfo().IsAbstract)
{
list = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(elementType));
}
else
{
list = (IList)Activator.CreateInstance(targetContainerType);
}
return list;
}
private static Type GetElementType(Type arrayOrGenericContainer)
{
Type elementType;
if (arrayOrGenericContainer.IsArray)
{
elementType = arrayOrGenericContainer.GetElementType();
}
else
{
elementType = arrayOrGenericContainer.GenericTypeArguments[0];
}
return elementType;
}
private object ReadObject(JsonReader reader, Type objectType, JsonSerializer serializer)
{
var jObject = JObject.Load(reader);
var targetType = GetType(jObject, objectType) ?? objectType;
return _ReadJson(CreateAnotherReader(jObject, reader), targetType, null, serializer);
}
private static JsonReader CreateAnotherReader(JObject jObject, JsonReader reader)
{
var jObjectReader = jObject.CreateReader();
jObjectReader.Culture = reader.Culture;
jObjectReader.CloseInput = reader.CloseInput;
jObjectReader.SupportMultipleContent = reader.SupportMultipleContent;
jObjectReader.DateTimeZoneHandling = reader.DateTimeZoneHandling;
jObjectReader.FloatParseHandling = reader.FloatParseHandling;
jObjectReader.DateFormatString = reader.DateFormatString;
jObjectReader.DateParseHandling = reader.DateParseHandling;
return jObjectReader;
}
public Type GetType(JObject jObject, Type parentType)
{
if (_typeMappingPropertyName == null)
{
return GetTypeByPropertyPresence(jObject, parentType);
}
return GetTypeFromDiscriminatorValue(jObject, parentType);
}
private static Type GetTypeByPropertyPresence(JObject jObject, Type parentType)
{
foreach (var type in parentType.GetTypeInfo().GetCustomAttributes<KnownSubTypeWithPropertyAttribute>())
{
JToken ignore;
if (jObject.TryGetValue(type.PropertyName, out ignore))
{
return type.SubType;
}
}
return null;
}
private Type GetTypeFromDiscriminatorValue(JObject jObject, Type parentType)
{
JToken jToken;
if (!jObject.TryGetValue(_typeMappingPropertyName, out jToken)) return null;
var discriminatorValue = jToken.ToObject<object>();
if (discriminatorValue == null) return null;
var typeMapping = GetSubTypeMapping(parentType);
if (typeMapping.Any())
{
return GetTypeFromMapping(typeMapping, discriminatorValue);
}
return GetTypeByName(discriminatorValue as string, parentType);
}
private static Type GetTypeByName(string typeName, Type parentType)
{
if (typeName == null)
return null;
var insideAssembly = parentType.GetTypeInfo().Assembly;
var typeByName = insideAssembly.GetType(typeName);
if (typeByName == null)
{
var searchLocation = parentType.FullName.Substring(0, parentType.FullName.Length - parentType.Name.Length);
typeByName = insideAssembly.GetType(searchLocation + typeName, false, true);
}
return typeByName;
}
private static Type GetTypeFromMapping(IReadOnlyDictionary<object, Type> typeMapping, object discriminatorValue)
{
var targetlookupValueType = typeMapping.First().Key.GetType();
var lookupValue = ConvertJsonValueToType(discriminatorValue, targetlookupValueType);
Type targetType;
return typeMapping.TryGetValue(lookupValue, out targetType) ? targetType : null;
}
private static Dictionary<object, Type> GetSubTypeMapping(Type type)
{
return type.GetTypeInfo().GetCustomAttributes<KnownSubTypeAttribute>().ToDictionary(x => x.AssociatedValue, x => x.SubType);
}
private static object ConvertJsonValueToType(object objectType, Type targetlookupValueType)
{
if (targetlookupValueType.GetTypeInfo().IsEnum)
return Enum.ToObject(targetlookupValueType, objectType);
return Convert.ChangeType(objectType, targetlookupValueType);
}
protected object _ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
_reader = reader;
_isInsideRead = true;
try
{
return serializer.Deserialize(reader, objectType);
}
finally
{
_isInsideRead = false;
}
}
}
}

View File

@@ -53,6 +53,12 @@ Contact: apiteam@swagger.io
<HintPath Condition="Exists('..\..\packages')">..\..\packages\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\Newtonsoft.Json.10.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="JsonSubTypes">
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\JsonSubTypes.1.1.3\lib\net45\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\packages')">..\packages\JsonSubTypes.1.1.3\lib\net45\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\..\packages')">..\..\packages\JsonSubTypes.1.1.3\lib\net45\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\JsonSubTypes.1.1.3\lib\net45\JsonSubTypes.dll</HintPath>
</Reference>
<Reference Include="RestSharp">
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>
<HintPath Condition="Exists('..\packages')">..\packages\RestSharp.105.1.0\lib\net45\RestSharp.dll</HintPath>

View File

@@ -41,16 +41,20 @@ namespace IO.Swagger.Model
/// Enum GreaterThanOrEqualTo for ">="
/// </summary>
[EnumMember(Value = ">=")]
GreaterThanOrEqualTo,
GreaterThanOrEqualTo = 1,
/// <summary>
/// Enum Dollar for "$"
/// </summary>
[EnumMember(Value = "$")]
Dollar
Dollar = 2
}
/// <summary>
/// Gets or Sets JustSymbol
/// </summary>
[DataMember(Name="just_symbol", EmitDefaultValue=false)]
public JustSymbolEnum? JustSymbol { get; set; }
/// <summary>
/// Gets or Sets ArrayEnum
/// </summary>
@@ -62,20 +66,16 @@ namespace IO.Swagger.Model
/// Enum Fish for "fish"
/// </summary>
[EnumMember(Value = "fish")]
Fish,
Fish = 1,
/// <summary>
/// Enum Crab for "crab"
/// </summary>
[EnumMember(Value = "crab")]
Crab
Crab = 2
}
/// <summary>
/// Gets or Sets JustSymbol
/// </summary>
[DataMember(Name="just_symbol", EmitDefaultValue=false)]
public JustSymbolEnum? JustSymbol { get; set; }
/// <summary>
/// Gets or Sets ArrayEnum
/// </summary>

View File

@@ -35,19 +35,19 @@ namespace IO.Swagger.Model
/// Enum Abc for "_abc"
/// </summary>
[EnumMember(Value = "_abc")]
Abc,
Abc = 1,
/// <summary>
/// Enum Efg for "-efg"
/// </summary>
[EnumMember(Value = "-efg")]
Efg,
Efg = 2,
/// <summary>
/// Enum Xyz for "(xyz)"
/// </summary>
[EnumMember(Value = "(xyz)")]
Xyz
Xyz = 3
}
}

View File

@@ -41,21 +41,26 @@ namespace IO.Swagger.Model
/// Enum UPPER for "UPPER"
/// </summary>
[EnumMember(Value = "UPPER")]
UPPER,
UPPER = 1,
/// <summary>
/// Enum Lower for "lower"
/// </summary>
[EnumMember(Value = "lower")]
Lower,
Lower = 2,
/// <summary>
/// Enum Empty for ""
/// </summary>
[EnumMember(Value = "")]
Empty
Empty = 3
}
/// <summary>
/// Gets or Sets EnumString
/// </summary>
[DataMember(Name="enum_string", EmitDefaultValue=false)]
public EnumStringEnum? EnumString { get; set; }
/// <summary>
/// Gets or Sets EnumInteger
/// </summary>
@@ -76,6 +81,11 @@ namespace IO.Swagger.Model
NUMBER_MINUS_1 = -1
}
/// <summary>
/// Gets or Sets EnumInteger
/// </summary>
[DataMember(Name="enum_integer", EmitDefaultValue=false)]
public EnumIntegerEnum? EnumInteger { get; set; }
/// <summary>
/// Gets or Sets EnumNumber
/// </summary>
@@ -87,38 +97,33 @@ namespace IO.Swagger.Model
/// Enum NUMBER_1_DOT_1 for 1.1
/// </summary>
[EnumMember(Value = "1.1")]
NUMBER_1_DOT_1,
NUMBER_1_DOT_1 = 1,
/// <summary>
/// Enum NUMBER_MINUS_1_DOT_2 for -1.2
/// </summary>
[EnumMember(Value = "-1.2")]
NUMBER_MINUS_1_DOT_2
NUMBER_MINUS_1_DOT_2 = 2
}
/// <summary>
/// Gets or Sets EnumString
/// </summary>
[DataMember(Name="enum_string", EmitDefaultValue=false)]
public EnumStringEnum? EnumString { get; set; }
/// <summary>
/// Gets or Sets EnumInteger
/// </summary>
[DataMember(Name="enum_integer", EmitDefaultValue=false)]
public EnumIntegerEnum? EnumInteger { get; set; }
/// <summary>
/// Gets or Sets EnumNumber
/// </summary>
[DataMember(Name="enum_number", EmitDefaultValue=false)]
public EnumNumberEnum? EnumNumber { get; set; }
/// <summary>
/// Gets or Sets OuterEnum
/// </summary>
[DataMember(Name="outerEnum", EmitDefaultValue=false)]
public OuterEnum? OuterEnum { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="EnumTest" /> class.
/// </summary>
/// <param name="EnumString">EnumString.</param>
/// <param name="EnumInteger">EnumInteger.</param>
/// <param name="EnumNumber">EnumNumber.</param>
/// <param name="OuterEnum">OuterEnum.</param>
public EnumTest(EnumStringEnum? EnumString = default(EnumStringEnum?), EnumIntegerEnum? EnumInteger = default(EnumIntegerEnum?), EnumNumberEnum? EnumNumber = default(EnumNumberEnum?), OuterEnum OuterEnum = default(OuterEnum))
public EnumTest(EnumStringEnum? EnumString = default(EnumStringEnum?), EnumIntegerEnum? EnumInteger = default(EnumIntegerEnum?), EnumNumberEnum? EnumNumber = default(EnumNumberEnum?), OuterEnum? OuterEnum = default(OuterEnum?))
{
this.EnumString = EnumString;
this.EnumInteger = EnumInteger;
@@ -129,11 +134,6 @@ namespace IO.Swagger.Model
/// <summary>
/// Gets or Sets OuterEnum
/// </summary>
[DataMember(Name="outerEnum", EmitDefaultValue=false)]
public OuterEnum OuterEnum { get; set; }
/// <summary>
/// Returns the string presentation of the object

View File

@@ -30,7 +30,6 @@ namespace IO.Swagger.Model
[DataContract]
public partial class MapTest : IEquatable<MapTest>, IValidatableObject
{
/// <summary>
/// Gets or Sets Inner
/// </summary>
@@ -42,15 +41,16 @@ namespace IO.Swagger.Model
/// Enum UPPER for "UPPER"
/// </summary>
[EnumMember(Value = "UPPER")]
UPPER,
UPPER = 1,
/// <summary>
/// Enum Lower for "lower"
/// </summary>
[EnumMember(Value = "lower")]
Lower
Lower = 2
}
/// <summary>
/// Gets or Sets MapOfEnumString
/// </summary>

View File

@@ -42,19 +42,19 @@ namespace IO.Swagger.Model
/// Enum Placed for "placed"
/// </summary>
[EnumMember(Value = "placed")]
Placed,
Placed = 1,
/// <summary>
/// Enum Approved for "approved"
/// </summary>
[EnumMember(Value = "approved")]
Approved,
Approved = 2,
/// <summary>
/// Enum Delivered for "delivered"
/// </summary>
[EnumMember(Value = "delivered")]
Delivered
Delivered = 3
}
/// <summary>

View File

@@ -35,19 +35,19 @@ namespace IO.Swagger.Model
/// Enum Placed for "placed"
/// </summary>
[EnumMember(Value = "placed")]
Placed,
Placed = 1,
/// <summary>
/// Enum Approved for "approved"
/// </summary>
[EnumMember(Value = "approved")]
Approved,
Approved = 2,
/// <summary>
/// Enum Delivered for "delivered"
/// </summary>
[EnumMember(Value = "delivered")]
Delivered
Delivered = 3
}
}

View File

@@ -42,19 +42,19 @@ namespace IO.Swagger.Model
/// Enum Available for "available"
/// </summary>
[EnumMember(Value = "available")]
Available,
Available = 1,
/// <summary>
/// Enum Pending for "pending"
/// </summary>
[EnumMember(Value = "pending")]
Pending,
Pending = 2,
/// <summary>
/// Enum Sold for "sold"
/// </summary>
[EnumMember(Value = "sold")]
Sold
Sold = 3
}
/// <summary>

View File

@@ -2,4 +2,5 @@
<packages>
<package id="RestSharp" version="105.1.0" targetFramework="net45" developmentDependency="true" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net45" developmentDependency="true" />
<package id="JsonSubTypes" version="1.1.3" targetFramework="net45" developmentDependency="true" />
</packages>

View File

@@ -6,7 +6,7 @@ Name | Type | Description | Notes
**EnumString** | **string** | | [optional]
**EnumInteger** | **int?** | | [optional]
**EnumNumber** | **double?** | | [optional]
**OuterEnum** | [**OuterEnum**](OuterEnum.md) | | [optional]
**OuterEnum** | **OuterEnum** | | [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)

View File

@@ -36,7 +36,7 @@ git_remote=`git remote`
if [ "$git_remote" = "" ]; then # git remote not defined
if [ "$GIT_TOKEN" = "" ]; then
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment."
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git
else
git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git

View File

@@ -52,6 +52,12 @@ Contact: apiteam@swagger.io
<HintPath Condition="Exists('..\..\packages')">..\..\packages\Newtonsoft.Json.10.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\Newtonsoft.Json.10.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="JsonSubTypes">
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\JsonSubTypes.1.1.3\lib\net40\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\packages')">..\packages\JsonSubTypes.1.1.3\lib\net40\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\..\packages')">..\..\packages\JsonSubTypes.1.1.3\lib\net40\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\JsonSubTypes.1.1.3\lib\net40\JsonSubTypes.dll</HintPath>
</Reference>
<Reference Include="RestSharp">
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.105.1.0\lib\net4\RestSharp.dll</HintPath>
<HintPath Condition="Exists('..\packages')">..\packages\RestSharp.105.1.0\lib\net4\RestSharp.dll</HintPath>

View File

@@ -3,4 +3,5 @@
<package id="NUnit" version="2.6.4" targetFramework="net40" />
<package id="RestSharp" version="105.1.0" targetFramework="net4" developmentDependency="true" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net40" developmentDependency="true" />
<package id="JsonSubTypes" version="1.1.3" targetFramework="net40" developmentDependency="true" />
</packages>

View File

@@ -1,272 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace JsonSubTypes
{
// Copied from project https://github.com/manuc66/JsonSubTypes
// https://raw.githubusercontent.com/manuc66/JsonSubTypes/07403192ea3f4959f6d42f5966ac56ceb0d6095b/JsonSubTypes/JsonSubtypes.cs
public class JsonSubtypes : JsonConverter
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true)]
public class KnownSubTypeAttribute : Attribute
{
public Type SubType { get; private set; }
public object AssociatedValue { get; private set; }
public KnownSubTypeAttribute(Type subType, object associatedValue)
{
SubType = subType;
AssociatedValue = associatedValue;
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = true)]
public class KnownSubTypeWithPropertyAttribute : Attribute
{
public Type SubType { get; private set; }
public string PropertyName { get; private set; }
public KnownSubTypeWithPropertyAttribute(Type subType, string propertyName)
{
SubType = subType;
PropertyName = propertyName;
}
}
private readonly string _typeMappingPropertyName;
private bool _isInsideRead;
private JsonReader _reader;
public override bool CanRead
{
get
{
if (!_isInsideRead)
return true;
return !string.IsNullOrEmpty(_reader.Path);
}
}
public sealed override bool CanWrite
{
get { return false; }
}
public JsonSubtypes()
{
}
public JsonSubtypes(string typeMappingPropertyName)
{
_typeMappingPropertyName = typeMappingPropertyName;
}
public override bool CanConvert(Type objectType)
{
return _typeMappingPropertyName != null;
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
throw new NotImplementedException();
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
if (reader.TokenType == JsonToken.Comment)
reader.Read();
switch (reader.TokenType)
{
case JsonToken.Null:
return null;
case JsonToken.StartArray:
return ReadArray(reader, objectType, serializer);
case JsonToken.StartObject:
return ReadObject(reader, objectType, serializer);
default:
throw new Exception("Array: Unrecognized token: " + reader.TokenType);
}
}
private IList ReadArray(JsonReader reader, Type targetType, JsonSerializer serializer)
{
var elementType = GetElementType(targetType);
var list = CreateCompatibleList(targetType, elementType);
while (reader.TokenType != JsonToken.EndArray && reader.Read())
{
switch (reader.TokenType)
{
case JsonToken.Null:
list.Add(reader.Value);
break;
case JsonToken.Comment:
break;
case JsonToken.StartObject:
list.Add(ReadObject(reader, elementType, serializer));
break;
case JsonToken.EndArray:
break;
default:
throw new Exception("Array: Unrecognized token: " + reader.TokenType);
}
}
if (targetType.IsArray)
{
var array = Array.CreateInstance(targetType.GetElementType(), list.Count);
list.CopyTo(array, 0);
list = array;
}
return list;
}
private static IList CreateCompatibleList(Type targetContainerType, Type elementType)
{
IList list;
if (targetContainerType.IsArray || targetContainerType.IsAbstract)
{
list = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(elementType));
}
else
{
list = (IList)Activator.CreateInstance(targetContainerType);
}
return list;
}
private static Type GetElementType(Type arrayOrGenericContainer)
{
Type elementType;
if (arrayOrGenericContainer.IsArray)
{
elementType = arrayOrGenericContainer.GetElementType();
}
else
{
elementType = arrayOrGenericContainer.GetGenericArguments().FirstOrDefault();
}
return elementType;
}
private object ReadObject(JsonReader reader, Type objectType, JsonSerializer serializer)
{
var jObject = JObject.Load(reader);
var targetType = GetType(jObject, objectType) ?? objectType;
return _ReadJson(CreateAnotherReader(jObject, reader), targetType, null, serializer);
}
private static JsonReader CreateAnotherReader(JObject jObject, JsonReader reader)
{
var jObjectReader = jObject.CreateReader();
jObjectReader.Culture = reader.Culture;
jObjectReader.CloseInput = reader.CloseInput;
jObjectReader.SupportMultipleContent = reader.SupportMultipleContent;
jObjectReader.DateTimeZoneHandling = reader.DateTimeZoneHandling;
jObjectReader.FloatParseHandling = reader.FloatParseHandling;
jObjectReader.DateFormatString = reader.DateFormatString;
jObjectReader.DateParseHandling = reader.DateParseHandling;
return jObjectReader;
}
public Type GetType(JObject jObject, Type parentType)
{
if (_typeMappingPropertyName == null)
{
return GetTypeByPropertyPresence(jObject, parentType);
}
return GetTypeFromDiscriminatorValue(jObject, parentType);
}
private static Type GetTypeByPropertyPresence(JObject jObject, Type parentType)
{
foreach (var type in parentType.GetCustomAttributes(false).OfType<KnownSubTypeWithPropertyAttribute>())
{
JToken ignore;
if (jObject.TryGetValue(type.PropertyName, out ignore))
{
return type.SubType;
}
}
return null;
}
private Type GetTypeFromDiscriminatorValue(JObject jObject, Type parentType)
{
JToken jToken;
if (!jObject.TryGetValue(_typeMappingPropertyName, out jToken)) return null;
var discriminatorValue = jToken.ToObject<object>();
if (discriminatorValue == null) return null;
var typeMapping = GetSubTypeMapping(parentType);
if (typeMapping.Any())
{
return GetTypeFromMapping(typeMapping, discriminatorValue);
}
return GetTypeByName(discriminatorValue as string, parentType);
}
private static Type GetTypeByName(string typeName, Type parentType)
{
if (typeName == null)
return null;
var insideAssembly = parentType.Assembly;
var typeByName = insideAssembly.GetType(typeName);
if (typeByName == null)
{
var searchLocation = parentType.FullName.Substring(0, parentType.FullName.Length - parentType.Name.Length);
typeByName = insideAssembly.GetType(searchLocation + typeName, false, true);
}
return typeByName;
}
private static Type GetTypeFromMapping(IDictionary<object, Type> typeMapping, object discriminatorValue)
{
var targetlookupValueType = typeMapping.First().Key.GetType();
var lookupValue = ConvertJsonValueToType(discriminatorValue, targetlookupValueType);
Type targetType;
return typeMapping.TryGetValue(lookupValue, out targetType) ? targetType : null;
}
private static Dictionary<object, Type> GetSubTypeMapping(Type type)
{
return type.GetCustomAttributes(false).OfType<KnownSubTypeAttribute>().ToDictionary(x => x.AssociatedValue, x => x.SubType);
}
private static object ConvertJsonValueToType(object objectType, Type targetlookupValueType)
{
if (targetlookupValueType.IsEnum)
return Enum.ToObject(targetlookupValueType, objectType);
return Convert.ChangeType(objectType, targetlookupValueType);
}
protected object _ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
_reader = reader;
_isInsideRead = true;
try
{
return serializer.Deserialize(reader, objectType);
}
finally
{
_isInsideRead = false;
}
}
}
}

View File

@@ -53,6 +53,12 @@ Contact: apiteam@swagger.io
<HintPath Condition="Exists('..\..\packages')">..\..\packages\Newtonsoft.Json.10.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\Newtonsoft.Json.10.0.3\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="JsonSubTypes">
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\JsonSubTypes.1.1.3\lib\net40\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\packages')">..\packages\JsonSubTypes.1.1.3\lib\net40\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\..\packages')">..\..\packages\JsonSubTypes.1.1.3\lib\net40\JsonSubTypes.dll</HintPath>
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\JsonSubTypes.1.1.3\lib\net40\JsonSubTypes.dll</HintPath>
</Reference>
<Reference Include="RestSharp">
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.105.1.0\lib\net4\RestSharp.dll</HintPath>
<HintPath Condition="Exists('..\packages')">..\packages\RestSharp.105.1.0\lib\net4\RestSharp.dll</HintPath>

View File

@@ -41,16 +41,20 @@ namespace IO.Swagger.Model
/// Enum GreaterThanOrEqualTo for ">="
/// </summary>
[EnumMember(Value = ">=")]
GreaterThanOrEqualTo,
GreaterThanOrEqualTo = 1,
/// <summary>
/// Enum Dollar for "$"
/// </summary>
[EnumMember(Value = "$")]
Dollar
Dollar = 2
}
/// <summary>
/// Gets or Sets JustSymbol
/// </summary>
[DataMember(Name="just_symbol", EmitDefaultValue=false)]
public JustSymbolEnum? JustSymbol { get; set; }
/// <summary>
/// Gets or Sets ArrayEnum
/// </summary>
@@ -62,20 +66,16 @@ namespace IO.Swagger.Model
/// Enum Fish for "fish"
/// </summary>
[EnumMember(Value = "fish")]
Fish,
Fish = 1,
/// <summary>
/// Enum Crab for "crab"
/// </summary>
[EnumMember(Value = "crab")]
Crab
Crab = 2
}
/// <summary>
/// Gets or Sets JustSymbol
/// </summary>
[DataMember(Name="just_symbol", EmitDefaultValue=false)]
public JustSymbolEnum? JustSymbol { get; set; }
/// <summary>
/// Gets or Sets ArrayEnum
/// </summary>

View File

@@ -35,19 +35,19 @@ namespace IO.Swagger.Model
/// Enum Abc for "_abc"
/// </summary>
[EnumMember(Value = "_abc")]
Abc,
Abc = 1,
/// <summary>
/// Enum Efg for "-efg"
/// </summary>
[EnumMember(Value = "-efg")]
Efg,
Efg = 2,
/// <summary>
/// Enum Xyz for "(xyz)"
/// </summary>
[EnumMember(Value = "(xyz)")]
Xyz
Xyz = 3
}
}

View File

@@ -41,21 +41,26 @@ namespace IO.Swagger.Model
/// Enum UPPER for "UPPER"
/// </summary>
[EnumMember(Value = "UPPER")]
UPPER,
UPPER = 1,
/// <summary>
/// Enum Lower for "lower"
/// </summary>
[EnumMember(Value = "lower")]
Lower,
Lower = 2,
/// <summary>
/// Enum Empty for ""
/// </summary>
[EnumMember(Value = "")]
Empty
Empty = 3
}
/// <summary>
/// Gets or Sets EnumString
/// </summary>
[DataMember(Name="enum_string", EmitDefaultValue=false)]
public EnumStringEnum? EnumString { get; set; }
/// <summary>
/// Gets or Sets EnumInteger
/// </summary>
@@ -76,6 +81,11 @@ namespace IO.Swagger.Model
NUMBER_MINUS_1 = -1
}
/// <summary>
/// Gets or Sets EnumInteger
/// </summary>
[DataMember(Name="enum_integer", EmitDefaultValue=false)]
public EnumIntegerEnum? EnumInteger { get; set; }
/// <summary>
/// Gets or Sets EnumNumber
/// </summary>
@@ -87,38 +97,33 @@ namespace IO.Swagger.Model
/// Enum NUMBER_1_DOT_1 for 1.1
/// </summary>
[EnumMember(Value = "1.1")]
NUMBER_1_DOT_1,
NUMBER_1_DOT_1 = 1,
/// <summary>
/// Enum NUMBER_MINUS_1_DOT_2 for -1.2
/// </summary>
[EnumMember(Value = "-1.2")]
NUMBER_MINUS_1_DOT_2
NUMBER_MINUS_1_DOT_2 = 2
}
/// <summary>
/// Gets or Sets EnumString
/// </summary>
[DataMember(Name="enum_string", EmitDefaultValue=false)]
public EnumStringEnum? EnumString { get; set; }
/// <summary>
/// Gets or Sets EnumInteger
/// </summary>
[DataMember(Name="enum_integer", EmitDefaultValue=false)]
public EnumIntegerEnum? EnumInteger { get; set; }
/// <summary>
/// Gets or Sets EnumNumber
/// </summary>
[DataMember(Name="enum_number", EmitDefaultValue=false)]
public EnumNumberEnum? EnumNumber { get; set; }
/// <summary>
/// Gets or Sets OuterEnum
/// </summary>
[DataMember(Name="outerEnum", EmitDefaultValue=false)]
public OuterEnum? OuterEnum { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="EnumTest" /> class.
/// </summary>
/// <param name="EnumString">EnumString.</param>
/// <param name="EnumInteger">EnumInteger.</param>
/// <param name="EnumNumber">EnumNumber.</param>
/// <param name="OuterEnum">OuterEnum.</param>
public EnumTest(EnumStringEnum? EnumString = default(EnumStringEnum?), EnumIntegerEnum? EnumInteger = default(EnumIntegerEnum?), EnumNumberEnum? EnumNumber = default(EnumNumberEnum?), OuterEnum OuterEnum = default(OuterEnum))
public EnumTest(EnumStringEnum? EnumString = default(EnumStringEnum?), EnumIntegerEnum? EnumInteger = default(EnumIntegerEnum?), EnumNumberEnum? EnumNumber = default(EnumNumberEnum?), OuterEnum? OuterEnum = default(OuterEnum?))
{
this.EnumString = EnumString;
this.EnumInteger = EnumInteger;
@@ -129,11 +134,6 @@ namespace IO.Swagger.Model
/// <summary>
/// Gets or Sets OuterEnum
/// </summary>
[DataMember(Name="outerEnum", EmitDefaultValue=false)]
public OuterEnum OuterEnum { get; set; }
/// <summary>
/// Returns the string presentation of the object

View File

@@ -30,7 +30,6 @@ namespace IO.Swagger.Model
[DataContract]
public partial class MapTest : IEquatable<MapTest>, IValidatableObject
{
/// <summary>
/// Gets or Sets Inner
/// </summary>
@@ -42,15 +41,16 @@ namespace IO.Swagger.Model
/// Enum UPPER for "UPPER"
/// </summary>
[EnumMember(Value = "UPPER")]
UPPER,
UPPER = 1,
/// <summary>
/// Enum Lower for "lower"
/// </summary>
[EnumMember(Value = "lower")]
Lower
Lower = 2
}
/// <summary>
/// Gets or Sets MapOfEnumString
/// </summary>

Some files were not shown because too many files have changed in this diff Show More