Skip to content

Commit

Permalink
upgrade sample to netcoreapp3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
lahma committed May 10, 2022
1 parent 50aaa4a commit fc872f8
Show file tree
Hide file tree
Showing 21 changed files with 84 additions and 198 deletions.
17 changes: 8 additions & 9 deletions build/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,17 +313,16 @@ protected override void OnBuildInitialized()
}
}
/* TODO should upgrade sample to NET 6.0
var samplesPath = RootDirectory / "samples";
var sampleSolution = ProjectModelTasks.ParseSolution(samplesPath / "Samples.sln");
NSwagRun(sampleSolution.GetProject("Sample.AspNetCore21"), "nswag_assembly", "NetCore21", Configuration.Release, true);
NSwagRun(sampleSolution.GetProject("Sample.AspNetCore21"), "nswag_project", "NetCore21", Configuration.Release, false);
NSwagRun(sampleSolution.GetProject("Sample.AspNetCore21"), "nswag_reflection", "NetCore21", Configuration.Release, true);
NSwagRun(sampleSolution.GetProject("Sample.AspNetCore21"), "nswag_assembly", "NetCore21", Configuration.Debug, true);
NSwagRun(sampleSolution.GetProject("Sample.AspNetCore21"), "nswag_project", "NetCore21", Configuration.Debug, false);
NSwagRun(sampleSolution.GetProject("Sample.AspNetCore21"), "nswag_reflection", "NetCore21", Configuration.Debug, true);
*/
var sampleProject = sampleSolution.GetProject(new Guid("55E2BF82-3ECE-45E2-96BD-65C09C42843D"));
NSwagRun(sampleProject, "nswag_assembly", "NetCore31", Configuration.Release, true);
NSwagRun(sampleProject, "nswag_project", "NetCore31", Configuration.Release, false);
NSwagRun(sampleProject, "nswag_reflection", "NetCore31", Configuration.Release, true);
NSwagRun(sampleProject, "nswag_assembly", "NetCore31", Configuration.Debug, true);
NSwagRun(sampleProject, "nswag_project", "NetCore31", Configuration.Debug, false);
NSwagRun(sampleProject, "nswag_reflection", "NetCore31", Configuration.Debug, true);
});

void PublishAndCopyConsoleProjects()
Expand Down
9 changes: 1 addition & 8 deletions samples/Samples.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29613.14
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.AspNetCore20", "WithoutMiddleware\Sample.AspNetCore20\Sample.AspNetCore20.csproj", "{5A204483-5A44-4B80-8B0B-A58284CC4CCB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.AspNetCore21", "WithoutMiddleware\Sample.AspNetCore21\Sample.AspNetCore21.csproj", "{55E2BF82-3ECE-45E2-96BD-65C09C42843D}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Sample.AspNetCore31", "WithoutMiddleware\Sample.AspNetCore31\Sample.AspNetCore31.csproj", "{55E2BF82-3ECE-45E2-96BD-65C09C42843D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.NetOwinMiddleware", "WithMiddleware\Sample.NetOwinMiddleware\Sample.NetOwinMiddleware.csproj", "{F8839807-B6F6-41E3-BC98-DFAD3C03085E}"
EndProject
Expand All @@ -23,10 +21,6 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5A204483-5A44-4B80-8B0B-A58284CC4CCB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5A204483-5A44-4B80-8B0B-A58284CC4CCB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5A204483-5A44-4B80-8B0B-A58284CC4CCB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5A204483-5A44-4B80-8B0B-A58284CC4CCB}.Release|Any CPU.Build.0 = Release|Any CPU
{55E2BF82-3ECE-45E2-96BD-65C09C42843D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{55E2BF82-3ECE-45E2-96BD-65C09C42843D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{55E2BF82-3ECE-45E2-96BD-65C09C42843D}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -48,7 +42,6 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{5A204483-5A44-4B80-8B0B-A58284CC4CCB} = {BF07E900-C7DE-4ADA-8563-E09E6B5AACF0}
{55E2BF82-3ECE-45E2-96BD-65C09C42843D} = {BF07E900-C7DE-4ADA-8563-E09E6B5AACF0}
{F8839807-B6F6-41E3-BC98-DFAD3C03085E} = {29EDA9F6-189B-4F96-B5BE-B7B82EB8A62A}
{2F6620B8-D19D-4710-AAB9-4E2B785F5FA5} = {29EDA9F6-189B-4F96-B5BE-B7B82EB8A62A}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//----------------------
// <auto-generated>
// Generated using the NSwag toolchain v13.8.2.0 (NJsonSchema v10.2.1.0 (Newtonsoft.Json v12.0.0.0)) (http://NSwag.org)
// Generated using the NSwag toolchain v13.14.5.0 (NJsonSchema v10.5.2.0 (Newtonsoft.Json v12.0.0.0)) (http://NSwag.org)
// </auto-generated>
//----------------------

Expand All @@ -9,20 +9,22 @@
#pragma warning disable 472 // Disable "CS0472 The result of the expression is always 'false' since a value of type 'Int32' is never equal to 'null' of type 'Int32?'
#pragma warning disable 1573 // Disable "CS1573 Parameter '...' has no matching param tag in the XML comment for ...
#pragma warning disable 1591 // Disable "CS1591 Missing XML comment for publicly visible type or member ..."
#pragma warning disable 8073 // Disable "CS8073 The result of the expression is always 'false' since a value of type 'T' is never equal to 'null' of type 'T?'"
#pragma warning disable 3016 // Disable "CS3016 Arrays as attribute arguments is not CLS-compliant"

namespace Apimundo.Client
{
using System = global::System;
[System.CodeDom.Compiler.GeneratedCode("NSwag", "13.8.2.0 (NJsonSchema v10.2.1.0 (Newtonsoft.Json v12.0.0.0))")]

[System.CodeDom.Compiler.GeneratedCode("NSwag", "13.14.5.0 (NJsonSchema v10.5.2.0 (Newtonsoft.Json v12.0.0.0))")]
public partial class WeatherForecastClient
{
private System.Net.Http.HttpClient _httpClient;
private System.Lazy<Newtonsoft.Json.JsonSerializerSettings> _settings;

public WeatherForecastClient(System.Net.Http.HttpClient httpClient)
{
_httpClient = httpClient;
_httpClient = httpClient;
_settings = new System.Lazy<Newtonsoft.Json.JsonSerializerSettings>(CreateSerializerSettings);
}

Expand All @@ -36,10 +38,11 @@ private Newtonsoft.Json.JsonSerializerSettings CreateSerializerSettings()
protected Newtonsoft.Json.JsonSerializerSettings JsonSerializerSettings { get { return _settings.Value; } }

partial void UpdateJsonSerializerSettings(Newtonsoft.Json.JsonSerializerSettings settings);


partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, string url);
partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, System.Text.StringBuilder urlBuilder);
partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response);

/// <exception cref="ApiException">A server side error occurred.</exception>
public System.Threading.Tasks.Task<System.Collections.ObjectModel.ObservableCollection<WeatherForecast>> GetAsync()
{
Expand All @@ -63,8 +66,10 @@ public async System.Threading.Tasks.Task<System.Collections.ObjectModel.Observab
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));

PrepareRequest(client_, request_, urlBuilder_);

var url_ = urlBuilder_.ToString();
request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute);

PrepareRequest(client_, request_, url_);

var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false);
Expand All @@ -83,7 +88,7 @@ public async System.Threading.Tasks.Task<System.Collections.ObjectModel.Observab
var status_ = (int)response_.StatusCode;
if (status_ == 200)
{
var objectResponse_ = await ReadObjectResponseAsync<System.Collections.ObjectModel.ObservableCollection<WeatherForecast>>(response_, headers_).ConfigureAwait(false);
var objectResponse_ = await ReadObjectResponseAsync<System.Collections.ObjectModel.ObservableCollection<WeatherForecast>>(response_, headers_, cancellationToken).ConfigureAwait(false);
if (objectResponse_.Object == null)
{
throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null);
Expand All @@ -92,7 +97,7 @@ public async System.Threading.Tasks.Task<System.Collections.ObjectModel.Observab
}
else
{
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false);
throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null);
}
}
Expand Down Expand Up @@ -125,7 +130,7 @@ public ObjectResponseResult(T responseObject, string responseText)

public bool ReadResponseAsString { get; set; }

protected virtual async System.Threading.Tasks.Task<ObjectResponseResult<T>> ReadObjectResponseAsync<T>(System.Net.Http.HttpResponseMessage response, System.Collections.Generic.IReadOnlyDictionary<string, System.Collections.Generic.IEnumerable<string>> headers)
protected virtual async System.Threading.Tasks.Task<ObjectResponseResult<T>> ReadObjectResponseAsync<T>(System.Net.Http.HttpResponseMessage response, System.Collections.Generic.IReadOnlyDictionary<string, System.Collections.Generic.IEnumerable<string>> headers, System.Threading.CancellationToken cancellationToken)
{
if (response == null || response.Content == null)
{
Expand Down Expand Up @@ -171,7 +176,7 @@ private string ConvertToString(object value, System.Globalization.CultureInfo cu
{
if (value == null)
{
return null;
return "";
}

if (value is System.Enum)
Expand All @@ -190,7 +195,8 @@ private string ConvertToString(object value, System.Globalization.CultureInfo cu
}
}

return System.Convert.ToString(System.Convert.ChangeType(value, System.Enum.GetUnderlyingType(value.GetType()), cultureInfo));
var converted = System.Convert.ToString(System.Convert.ChangeType(value, System.Enum.GetUnderlyingType(value.GetType()), cultureInfo));
return converted == null ? string.Empty : converted;
}
}
else if (value is bool)
Expand All @@ -208,11 +214,11 @@ private string ConvertToString(object value, System.Globalization.CultureInfo cu
}

var result = System.Convert.ToString(value, cultureInfo);
return (result is null) ? string.Empty : result;
return result == null ? "" : result;
}
}

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.2.1.0 (Newtonsoft.Json v12.0.0.0)")]
[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.5.2.0 (Newtonsoft.Json v12.0.0.0)")]
public partial class WeatherForecast : System.ComponentModel.INotifyPropertyChanged
{
private System.DateTime _date;
Expand All @@ -224,11 +230,11 @@ public partial class WeatherForecast : System.ComponentModel.INotifyPropertyChan
public System.DateTime Date
{
get { return _date; }
set
set
{
if (_date != value)
{
_date = value;
_date = value;
RaisePropertyChanged();
}
}
Expand All @@ -238,11 +244,11 @@ public System.DateTime Date
public int TemperatureC
{
get { return _temperatureC; }
set
set
{
if (_temperatureC != value)
{
_temperatureC = value;
_temperatureC = value;
RaisePropertyChanged();
}
}
Expand All @@ -252,11 +258,11 @@ public int TemperatureC
public int TemperatureF
{
get { return _temperatureF; }
set
set
{
if (_temperatureF != value)
{
_temperatureF = value;
_temperatureF = value;
RaisePropertyChanged();
}
}
Expand All @@ -266,24 +272,24 @@ public int TemperatureF
public string Summary
{
get { return _summary; }
set
set
{
if (_summary != value)
{
_summary = value;
_summary = value;
RaisePropertyChanged();
}
}
}

public string ToJson()
public string ToJson()
{
return Newtonsoft.Json.JsonConvert.SerializeObject(this);
return Newtonsoft.Json.JsonConvert.SerializeObject(this, new Newtonsoft.Json.JsonSerializerSettings());
}

public static WeatherForecast FromJson(string data)
{
return Newtonsoft.Json.JsonConvert.DeserializeObject<WeatherForecast>(data);
return Newtonsoft.Json.JsonConvert.DeserializeObject<WeatherForecast>(data, new Newtonsoft.Json.JsonSerializerSettings());
}

public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
Expand All @@ -297,7 +303,7 @@ protected virtual void RaisePropertyChanged([System.Runtime.CompilerServices.Cal

}

[System.CodeDom.Compiler.GeneratedCode("NSwag", "13.8.2.0 (NJsonSchema v10.2.1.0 (Newtonsoft.Json v12.0.0.0))")]
[System.CodeDom.Compiler.GeneratedCode("NSwag", "13.14.5.0 (NJsonSchema v10.5.2.0 (Newtonsoft.Json v12.0.0.0))")]
public partial class ApiException : System.Exception
{
public int StatusCode { get; private set; }
Expand All @@ -310,7 +316,7 @@ public ApiException(string message, int statusCode, string response, System.Coll
: base(message + "\n\nStatus: " + statusCode + "\nResponse: \n" + ((response == null) ? "(null)" : response.Substring(0, response.Length >= 512 ? 512 : response.Length)), innerException)
{
StatusCode = statusCode;
Response = response;
Response = response;
Headers = headers;
}

Expand All @@ -320,7 +326,7 @@ public override string ToString()
}
}

[System.CodeDom.Compiler.GeneratedCode("NSwag", "13.8.2.0 (NJsonSchema v10.2.1.0 (Newtonsoft.Json v12.0.0.0))")]
[System.CodeDom.Compiler.GeneratedCode("NSwag", "13.14.5.0 (NJsonSchema v10.5.2.0 (Newtonsoft.Json v12.0.0.0))")]
public partial class ApiException<TResult> : ApiException
{
public TResult Result { get; private set; }
Expand All @@ -338,4 +344,5 @@ public ApiException(string message, int statusCode, string response, System.Coll
#pragma warning restore 1573
#pragma warning restore 472
#pragma warning restore 114
#pragma warning restore 108
#pragma warning restore 108
#pragma warning restore 3016
2 changes: 1 addition & 1 deletion samples/WithMiddleware/Sample.AspNetCore31/openapi.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"x-generator": "NSwag v13.8.2.0 (NJsonSchema v10.2.1.0 (Newtonsoft.Json v9.0.0.0))",
"x-generator": "NSwag v13.14.5.0 (NJsonSchema v10.5.2.0 (Newtonsoft.Json v9.0.0.0))",
"openapi": "3.0.0",
"info": {
"title": "My Sample App",
Expand Down
Loading

0 comments on commit fc872f8

Please sign in to comment.