Skip to content

Commit

Permalink
Issue swagger-api#5419 - Part 1 - C# Servers updated and samples gene…
Browse files Browse the repository at this point in the history
…rated
  • Loading branch information
kenisteward committed May 9, 2017
1 parent 621ff06 commit 1d5e35f
Show file tree
Hide file tree
Showing 78 changed files with 8,935 additions and 37 deletions.
2 changes: 1 addition & 1 deletion bin/aspnetcore-petstore-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ fi

# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="$@ generate -l aspnetcore -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -o samples/server/petstore/aspnetcore --additional-properties packageGuid={3C799344-F285-4669-8FD5-7ED9B795D5C5}"
ags="$@ generate -l aspnetcore -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -o samples/server/petstore/aspnetcore --additional-properties packageGuid={3C799344-F285-4669-8FD5-7ED9B795D5C5}"

java $JAVA_OPTS -jar $executable $ags
2 changes: 1 addition & 1 deletion bin/nancyfx-petstore-server.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ fi

# if you've executed sbt assembly previously it will use that instead.
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
ags="generate $@ -t modules/swagger-codegen/src/main/resources/nancyfx -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l nancyfx -o samples/server/petstore/nancyfx --additional-properties packageGuid={768B8DC6-54EE-4D40-9B20-7857E1D742A4}"
ags="generate $@ -t modules/swagger-codegen/src/main/resources/nancyfx -i modules/swagger-codegen/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -l nancyfx -o samples/server/petstore/nancyfx --additional-properties packageGuid={768B8DC6-54EE-4D40-9B20-7857E1D742A4}"

java $JAVA_OPTS -jar $executable $ags
2 changes: 1 addition & 1 deletion bin/windows/aspnetcore-petstore-server.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ If Not Exist %executable% (
)

REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -l aspnetcore -o samples\server\petstore\aspnetcore\ --additional-properties packageGuid={3C799344-F285-4669-8FD5-7ED9B795D5C5}
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -l aspnetcore -o samples\server\petstore\aspnetcore\ --additional-properties packageGuid={3C799344-F285-4669-8FD5-7ED9B795D5C5}

java %JAVA_OPTS% -jar %executable% %ags%
2 changes: 1 addition & 1 deletion bin/windows/nancyfx-petstore-server.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ If Not Exist %executable% (
)

REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -l nancyfx -o samples\server\petstore\nancyfx\
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -l nancyfx -o samples\server\petstore\nancyfx\

java %JAVA_OPTS% -jar %executable% %ags%
2 changes: 1 addition & 1 deletion samples/server/petstore/aspnetcore/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# IO.Swagger - ASP.NET Core 1.0 Server

This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\

## Run

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* 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: [email protected]
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Net;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Swashbuckle.SwaggerGen.Annotations;
using IO.Swagger.Models;

namespace IO.Swagger.Controllers
{
/// <summary>
///
/// </summary>
public class FakeApiController : Controller
{

/// <summary>
/// To test \&quot;client\&quot; model
/// </summary>
/// <remarks>To test \&quot;client\&quot; model</remarks>
/// <param name="body">client model</param>
/// <response code="200">successful operation</response>
[HttpPatch]
[Route("/v2/fake")]
[SwaggerOperation("TestClientModel")]
[SwaggerResponse(200, type: typeof(Client))]
public virtual IActionResult TestClientModel([FromBody]Client body)
{
string exampleJson = null;

var example = exampleJson != null
? JsonConvert.DeserializeObject<Client>(exampleJson)
: default(Client);
return new ObjectResult(example);
}


/// <summary>
/// Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
/// </summary>
/// <remarks>Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 </remarks>
/// <param name="number">None</param>
/// <param name="double">None</param>
/// <param name="patternWithoutDelimiter">None</param>
/// <param name="byte">None</param>
/// <param name="integer">None</param>
/// <param name="int32">None</param>
/// <param name="int64">None</param>
/// <param name="float">None</param>
/// <param name="string">None</param>
/// <param name="binary">None</param>
/// <param name="date">None</param>
/// <param name="dateTime">None</param>
/// <param name="password">None</param>
/// <param name="callback">None</param>
/// <response code="400">Invalid username supplied</response>
/// <response code="404">User not found</response>
[HttpPost]
[Route("/v2/fake")]
[SwaggerOperation("TestEndpointParameters")]
public virtual void TestEndpointParameters([FromForm]decimal? number, [FromForm]double? double, [FromForm]string patternWithoutDelimiter, [FromForm]byte[] byte, [FromForm]int? integer, [FromForm]int? int32, [FromForm]long? int64, [FromForm]float? float, [FromForm]string string, [FromForm]byte[] binary, [FromForm]DateTime? date, [FromForm]DateTime? dateTime, [FromForm]string password, [FromForm]string callback)
{
throw new NotImplementedException();
}


/// <summary>
/// To test enum parameters
/// </summary>
/// <remarks>To test enum parameters</remarks>
/// <param name="enumFormStringArray">Form parameter enum test (string array)</param>
/// <param name="enumFormString">Form parameter enum test (string)</param>
/// <param name="enumHeaderStringArray">Header parameter enum test (string array)</param>
/// <param name="enumHeaderString">Header parameter enum test (string)</param>
/// <param name="enumQueryStringArray">Query parameter enum test (string array)</param>
/// <param name="enumQueryString">Query parameter enum test (string)</param>
/// <param name="enumQueryInteger">Query parameter enum test (double)</param>
/// <param name="enumQueryDouble">Query parameter enum test (double)</param>
/// <response code="400">Invalid request</response>
/// <response code="404">Not found</response>
[HttpGet]
[Route("/v2/fake")]
[SwaggerOperation("TestEnumParameters")]
public virtual void TestEnumParameters([FromForm]List<string> enumFormStringArray, [FromForm]string enumFormString, [FromHeader]List<string> enumHeaderStringArray, [FromHeader]string enumHeaderString, [FromQuery]List<string> enumQueryStringArray, [FromQuery]string enumQueryString, [FromQuery]int? enumQueryInteger, [FromForm]double? enumQueryDouble)
{
throw new NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Swagger Petstore
*
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
* 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: [email protected]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Swagger Petstore
*
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
* 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: [email protected]
Expand Down Expand Up @@ -37,7 +37,7 @@ public class StoreApiController : Controller
/// <response code="400">Invalid ID supplied</response>
/// <response code="404">Order not found</response>
[HttpDelete]
[Route("/v2/store/order/{orderId}")]
[Route("/v2/store/order/{order_id}")]
[SwaggerOperation("DeleteOrder")]
public virtual void DeleteOrder([FromRoute]string orderId)
{
Expand Down Expand Up @@ -74,7 +74,7 @@ public virtual IActionResult GetInventory()
/// <response code="400">Invalid ID supplied</response>
/// <response code="404">Order not found</response>
[HttpGet]
[Route("/v2/store/order/{orderId}")]
[Route("/v2/store/order/{order_id}")]
[SwaggerOperation("GetOrderById")]
[SwaggerResponse(200, type: typeof(Order))]
public virtual IActionResult GetOrderById([FromRoute]long? orderId)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* Swagger Petstore
*
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
* 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: [email protected]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/*
* 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: [email protected]
* Generated by: https://github.com/swagger-api/swagger-codegen.git
*/

using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.Serialization;
using Newtonsoft.Json;

namespace IO.Swagger.Models
{

/// <summary>
///
/// </summary>
[DataContract]
public partial class AdditionalPropertiesClass : IEquatable<AdditionalPropertiesClass>
{

/// <summary>
/// Initializes a new instance of the <see cref="AdditionalPropertiesClass" /> class.
/// </summary>
/// <param name="MapProperty">MapProperty.</param>
/// <param name="MapOfMapProperty">MapOfMapProperty.</param>
public AdditionalPropertiesClass(Dictionary<string, string> MapProperty = default(Dictionary<string, string>), Dictionary<string, Dictionary<string, string>> MapOfMapProperty = default(Dictionary<string, Dictionary<string, string>>))
{
this.MapProperty = MapProperty;
this.MapOfMapProperty = MapOfMapProperty;

}

/// <summary>
/// Gets or Sets MapProperty
/// </summary>
[DataMember(Name="map_property")]
public Dictionary<string, string> MapProperty { get; set; }
/// <summary>
/// Gets or Sets MapOfMapProperty
/// </summary>
[DataMember(Name="map_of_map_property")]
public Dictionary<string, Dictionary<string, string>> MapOfMapProperty { get; set; }

/// <summary>
/// Returns the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString()
{
var sb = new StringBuilder();
sb.Append("class AdditionalPropertiesClass {\n");
sb.Append(" MapProperty: ").Append(MapProperty).Append("\n");
sb.Append(" MapOfMapProperty: ").Append(MapOfMapProperty).Append("\n");
sb.Append("}\n");
return sb.ToString();
}

/// <summary>
/// Returns the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public string ToJson()
{
return JsonConvert.SerializeObject(this, Formatting.Indented);
}

/// <summary>
/// Returns true if objects are equal
/// </summary>
/// <param name="obj">Object to be compared</param>
/// <returns>Boolean</returns>
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false;
return Equals((AdditionalPropertiesClass)obj);
}

/// <summary>
/// Returns true if AdditionalPropertiesClass instances are equal
/// </summary>
/// <param name="other">Instance of AdditionalPropertiesClass to be compared</param>
/// <returns>Boolean</returns>
public bool Equals(AdditionalPropertiesClass other)
{

if (ReferenceEquals(null, other)) return false;
if (ReferenceEquals(this, other)) return true;

return
(
this.MapProperty == other.MapProperty ||
this.MapProperty != null &&
this.MapProperty.SequenceEqual(other.MapProperty)
) &&
(
this.MapOfMapProperty == other.MapOfMapProperty ||
this.MapOfMapProperty != null &&
this.MapOfMapProperty.SequenceEqual(other.MapOfMapProperty)
);
}

/// <summary>
/// Gets the hash code
/// </summary>
/// <returns>Hash code</returns>
public override int GetHashCode()
{
// credit: http://stackoverflow.com/a/263416/677735
unchecked // Overflow is fine, just wrap
{
int hash = 41;
// Suitable nullity checks etc, of course :)
if (this.MapProperty != null)
hash = hash * 59 + this.MapProperty.GetHashCode();
if (this.MapOfMapProperty != null)
hash = hash * 59 + this.MapOfMapProperty.GetHashCode();
return hash;
}
}

#region Operators

public static bool operator ==(AdditionalPropertiesClass left, AdditionalPropertiesClass right)
{
return Equals(left, right);
}

public static bool operator !=(AdditionalPropertiesClass left, AdditionalPropertiesClass right)
{
return !Equals(left, right);
}

#endregion Operators

}
}
Loading

0 comments on commit 1d5e35f

Please sign in to comment.