Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !6232
An error occurred while fetching the assigned milestone of the selected merge_request.

[c-sharp] Fix default values with discriminator

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/tomelfring/bugfix/6225 into master 5 years ago
  • Overview 0
  • Commits 5
  • Pipelines 0
  • Changes 249

Created by: tomelfring

Fixes a part of #6225 (closed), where the default values aren't registered correctly due to a mismatch in comparing between name and baseName in the class CSharpClientCodegen.java.

Chosen for comparing name because that's the value used more in the same file.

Testcase is already in the samplefiles at: samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Cat.cs The default value of className is now set to "Cat" instead of default(string).

Additional testcase is provided in #6225 (closed).

To fix #6225 (closed)

PR checklist

  • Read the contribution guidelines.
  • If contributing template-only or documentation-only changes which will change sample output, build the project before.
  • Run the shell script(s) under ./bin/ (or Windows batch scripts under.\bin\windows) to update Petstore samples related to your fix. This is important, as CI jobs will verify all generator outputs of your HEAD commit, and these must match the expectations made by your contribution. You only need to run ./bin/{LANG}-petstore.sh, ./bin/openapi3/{LANG}-petstore.sh if updating the code or mustache templates for a language ({LANG}) (e.g. php, ruby, python, etc).
  • File the PR against the correct branch: master, 4.3.x, 5.0.x. Default: master.
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

@mandrean (2017/08), @jimschubert (2017/09) :heart:️ @frankyjuang (2019/09) @shibayan (2020/02)

Compare
  • master (base)

and
  • latest version
    5ba645ca
    5 commits, 2 years ago

249 files
+ 11097
- 1038

    Preferences

    File browser
    Compare changes
modules/…/…/…/…‎/…/…/…/languages‎
CSharpClient‎Codegen.java‎ +1 -1
CSharpNetCoreCl‎ientCodegen.java‎ +1 -1
sam‎ples‎
client/‎petstore‎
csh‎arp‎
OpenAPIClien‎t/src/…/Model‎
Cat‎.cs‎ +1 -1
Dog‎.cs‎ +1 -1
OpenAPIClientNet35/‎src/Org.OpenAPITools‎
A‎pi‎
FakeA‎pi.cs‎ +1 -1
Mo‎del‎
Cat‎.cs‎ +1 -1
Dog‎.cs‎ +1 -1
OpenAPIClientNet40/‎src/Org.OpenAPITools‎
A‎pi‎
FakeA‎pi.cs‎ +1 -1
Mo‎del‎
Cat‎.cs‎ +1 -1
Dog‎.cs‎ +1 -1
OpenAPIClient‎NetCoreProject‎
.openapi-‎generator‎
FI‎LES‎ +122 -0
do‎cs‎
AdditionalProp‎ertiesClass.md‎ +3 -3
src/Org.Op‎enAPITools‎
A‎pi‎
FakeA‎pi.cs‎ +2 -2
Mo‎del‎
Cat‎.cs‎ +1 -1
Dog‎.cs‎ +1 -1
OpenAPIClien‎tNetStandard‎
do‎cs‎
Defaul‎tApi.md‎ +77 -0
Foo‎.md‎ +13 -0
HealthChec‎kResult.md‎ +13 -0
InlineO‎bject.md‎ +14 -0
InlineOb‎ject1.md‎ +14 -0
InlineOb‎ject2.md‎ +14 -0
InlineOb‎ject3.md‎ +26 -0
InlineOb‎ject4.md‎ +14 -0
InlineOb‎ject5.md‎ +14 -0
InlineRespon‎seDefault.md‎ +13 -0
Nullable‎Class.md‎ +24 -0
OuterEnumDef‎aultValue.md‎ +12 -0
OuterEnum‎Integer.md‎ +12 -0
OuterEnumIntege‎rDefaultValue.md‎ +12 -0
src/Org.Op‎enAPITools‎
A‎pi‎
Defaul‎tApi.cs‎ +300 -0
FakeA‎pi.cs‎ +2 -2
Mo‎del‎
Cat‎.cs‎ +1 -1
Dog‎.cs‎ +1 -1
Foo‎.cs‎ +120 -0
HealthChec‎kResult.cs‎ +113 -0
InlineO‎bject.cs‎ +130 -0
InlineOb‎ject1.cs‎ +130 -0
InlineOb‎ject2.cs‎ +187 -0
InlineOb‎ject3.cs‎ +376 -0
InlineOb‎ject4.cs‎ +153 -0
InlineOb‎ject5.cs‎ +144 -0
InlineRespon‎seDefault.cs‎ +112 -0
Nullable‎Class.cs‎ +306 -0
OuterEnumDef‎aultValue.cs‎ +53 -0
OuterEnum‎Integer.cs‎ +53 -0
OuterEnumIntege‎rDefaultValue.cs‎ +53 -0
Org.OpenAPI‎Tools.csproj‎ +1 -1
OpenAPIClientWit‎hPropertyChanged‎
do‎cs‎
Defaul‎tApi.md‎ +77 -0
Foo‎.md‎ +13 -0
HealthChec‎kResult.md‎ +13 -0
InlineO‎bject.md‎ +14 -0
InlineOb‎ject1.md‎ +14 -0
InlineOb‎ject2.md‎ +14 -0
InlineOb‎ject3.md‎ +26 -0
InlineOb‎ject4.md‎ +14 -0
InlineOb‎ject5.md‎ +14 -0
InlineRespon‎seDefault.md‎ +13 -0
Nullable‎Class.md‎ +24 -0
OuterEnumDef‎aultValue.md‎ +12 -0
OuterEnum‎Integer.md‎ +12 -0
OuterEnumIntege‎rDefaultValue.md‎ +12 -0
src/Org.Op‎enAPITools‎
A‎pi‎
Defaul‎tApi.cs‎ +300 -0
FakeA‎pi.cs‎ +2 -2
Mo‎del‎
Cat‎.cs‎ +1 -1
Dog‎.cs‎ +1 -1
Foo‎.cs‎ +155 -0
HealthChec‎kResult.cs‎ +148 -0
InlineO‎bject.cs‎ +165 -0
InlineOb‎ject1.cs‎ +165 -0
InlineOb‎ject2.cs‎ +222 -0
InlineOb‎ject3.cs‎ +505 -0
InlineOb‎ject4.cs‎ +188 -0
InlineOb‎ject5.cs‎ +179 -0
InlineRespon‎seDefault.cs‎ +147 -0
Nullable‎Class.cs‎ +341 -0
OuterEnumDef‎aultValue.cs‎ +57 -0
OuterEnum‎Integer.cs‎ +57 -0
OuterEnumIntege‎rDefaultValue.cs‎ +57 -0
csharp-dotne‎t2/…/…/…/docs‎
InlineO‎bject.md‎ +10 -0
InlineOb‎ject1.md‎ +10 -0
csharp-‎netcore‎
OpenAPIClien‎t/src/…/Model‎
Cat‎.cs‎ +2 -2
Dog‎.cs‎ +2 -2
OpenAPIClientC‎ore/src/…/Model‎
Cat‎.cs‎ +2 -2
Dog‎.cs‎ +2 -2
openapi3/client/…/c‎sharp/OpenAPIClient‎
.openapi-‎generator‎
VER‎SION‎ +1 -1
do‎cs‎
AdditionalProp‎ertiesClass.md‎ +5 -1
Anim‎al.md‎ +5 -1
AnotherF‎akeApi.md‎ +23 -9
ApiResp‎onse.md‎ +6 -2
ArrayOfArrayO‎fNumberOnly.md‎ +6 -2
ArrayOfNum‎berOnly.md‎ +6 -2
ArrayT‎est.md‎ +6 -2
Capitali‎zation.md‎ +5 -1
Cat‎.md‎ +6 -2
CatAl‎lOf.md‎ +13 -0
Categ‎ory.md‎ +6 -2
ClassM‎odel.md‎ +5 -1
Defaul‎tApi.md‎ +23 -9
Dog‎.md‎ +5 -1
DogAl‎lOf.md‎ +13 -0
EnumAr‎rays.md‎ +5 -1
EnumCl‎ass.md‎ +5 -1
EnumT‎est.md‎ +11 -7
FakeA‎pi.md‎ +482 -139
FakeClassname‎Tags123Api.md‎ +23 -9
Fil‎e.md‎ +5 -1
FileSchemaT‎estClass.md‎ +5 -1
Foo‎.md‎ +5 -1
Format‎Test.md‎ +14 -10
HasOnlyRe‎adOnly.md‎ +7 -3
HealthChec‎kResult.md‎ +5 -1
InlineO‎bject.md‎ +5 -1
InlineOb‎ject1.md‎ +5 -1
InlineOb‎ject2.md‎ +5 -1
InlineOb‎ject3.md‎ +13 -9
InlineOb‎ject4.md‎ +5 -1
InlineOb‎ject5.md‎ +5 -1
InlineRespon‎seDefault.md‎ +5 -1
Lis‎t.md‎ +5 -1
MapTe‎st.md‎ +7 -3
MixedPropertiesAndAddit‎ionalPropertiesClass.md‎ +7 -3
Model200R‎esponse.md‎ +6 -2
ModelCl‎ient.md‎ +5 -1
Nam‎e.md‎ +8 -4
Nullable‎Class.md‎ +5 -1
Number‎Only.md‎ +6 -2
Orde‎r.md‎ +10 -6
OuterCom‎posite.md‎ +7 -3
OuterE‎num.md‎ +5 -1
OuterEnumDef‎aultValue.md‎ +5 -1
OuterEnum‎Integer.md‎ +5 -1
OuterEnumIntege‎rDefaultValue.md‎ +5 -1
Pet‎.md‎ +6 -2
PetA‎pi.md‎ +234 -102
ReadOnly‎First.md‎ +6 -2
Retu‎rn.md‎ +6 -2
SpecialMo‎delName.md‎ +6 -2
Store‎Api.md‎ +102 -42
Tag‎.md‎ +6 -2
Use‎r.md‎ +7 -3
UserA‎pi.md‎ +191 -74
s‎rc‎
Org.Open‎APITools‎
A‎pi‎
AnotherF‎akeApi.cs‎ +2 -2
Defaul‎tApi.cs‎ +2 -2
FakeA‎pi.cs‎ +541 -95
FakeClassname‎Tags123Api.cs‎ +2 -2
PetA‎pi.cs‎ +43 -43
Store‎Api.cs‎ +32 -32
UserA‎pi.cs‎ +3 -3
Cli‎ent‎
ApiCli‎ent.cs‎ +5 -1
ApiExce‎ption.cs‎ +1 -1
ApiResp‎onse.cs‎ +1 -1
Configur‎ation.cs‎ +1 -1
Exception‎Factory.cs‎ +1 -1
GlobalConfi‎guration.cs‎ +1 -1
IApiAcc‎essor.cs‎ +1 -1
IReadableCon‎figuration.cs‎ +1 -1
OpenAPIDate‎Converter.cs‎ +1 -1
Mo‎del‎
AdditionalProp‎ertiesClass.cs‎ +3 -1
Anim‎al.cs‎ +4 -3
ApiResp‎onse.cs‎ +3 -3
ArrayOfArrayO‎fNumberOnly.cs‎ +4 -3
ArrayOfNum‎berOnly.cs‎ +4 -3
ArrayT‎est.cs‎ +6 -3
Capitali‎zation.cs‎ +1 -1
Cat‎.cs‎ +3 -3
CatAl‎lOf.cs‎ +124 -0
Categ‎ory.cs‎ +5 -4
ClassM‎odel.cs‎ +1 -1
Dog‎.cs‎ +2 -2
DogAl‎lOf.cs‎ +124 -0
EnumAr‎rays.cs‎ +2 -1
EnumCl‎ass.cs‎ +1 -1
EnumT‎est.cs‎ +25 -23
Fil‎e.cs‎ +1 -1
FileSchemaT‎estClass.cs‎ +2 -1
Foo‎.cs‎ +1 -1
Format‎Test.cs‎ +55 -35
HasOnlyRe‎adOnly.cs‎ +1 -1
HealthChec‎kResult.cs‎ +3 -2
InlineO‎bject.cs‎ +1 -1
InlineOb‎ject1.cs‎ +1 -1
InlineOb‎ject2.cs‎ +2 -1
InlineOb‎ject3.cs‎ +51 -33
InlineOb‎ject4.cs‎ +5 -3
InlineOb‎ject5.cs‎ +3 -2
InlineRespon‎seDefault.cs‎ +1 -1
Lis‎t.cs‎ +1 -1
MapTe‎st.cs‎ +8 -4
MixedPropertiesAndAddit‎ionalPropertiesClass.cs‎ +5 -4
Model200R‎esponse.cs‎ +3 -3
ModelCl‎ient.cs‎ +1 -1
Nam‎e.cs‎ +7 -6
Nullable‎Class.cs‎ +27 -11
Number‎Only.cs‎ +3 -3
Orde‎r.cs‎ +7 -7
OuterCom‎posite.cs‎ +4 -4
OuterE‎num.cs‎ +1 -1
OuterEnumDef‎aultValue.cs‎ +1 -1
OuterEnum‎Integer.cs‎ +1 -1
OuterEnumIntege‎rDefaultValue.cs‎ +1 -1
Pet‎.cs‎ +9 -5
ReadOnly‎First.cs‎ +1 -1
Retu‎rn.cs‎ +3 -3
SpecialMo‎delName.cs‎ +3 -3
Tag‎.cs‎ +3 -3
Use‎r.cs‎ +4 -4
Org.OpenAPI‎Tools.csproj‎ +14 -12
Org.OpenAPI‎Tools.nuspec‎ +2 -2
package‎s.config‎ +3 -2
Org.OpenAP‎ITools.Test‎
Mo‎del‎
CatAllOf‎Tests.cs‎ +79 -0
DogAllOf‎Tests.cs‎ +79 -0
package‎s.config‎ +3 -3
READ‎ME.md‎ +38 -18
buil‎d.bat‎ +2 -2
buil‎d.sh‎ +2 -2
git_p‎ush.sh‎ +10 -4
mono_nuni‎t_test.sh‎ +3 -3
server/‎petstore‎
nan‎cyfx‎
.openapi-‎generator‎
FI‎LES‎ +15 -0
VER‎SION‎ +1 -1
src/Org.Op‎enAPITools‎
Mod‎els‎
ApiResp‎onse.cs‎ +1 -1
Categ‎ory.cs‎ +1 -1
Orde‎r.cs‎ +5 -5
Pet‎.cs‎ +1 -1
Tag‎.cs‎ +1 -1
Use‎r.cs‎ +1 -1
Mod‎ules‎
PetMod‎ule.cs‎ +19 -19
StoreMo‎dule.cs‎ +11 -11
UserMo‎dule.cs‎ +35 -35
Ut‎ils‎
LocalDateC‎onverter.cs‎ +1 -1
Parame‎ters.cs‎ +1 -1
Org.OpenAPI‎Tools.csproj‎ +1 -1
Org.OpenAP‎ITools.sln‎ +25 -0
nancyf‎x-async‎
.openapi-‎generator‎
FI‎LES‎ +15 -0
VER‎SION‎ +1 -1
src/Org.Op‎enAPITools‎
Mod‎els‎
ApiResp‎onse.cs‎ +185 -0
Categ‎ory.cs‎ +165 -0
Orde‎r.cs‎ +247 -0
Pet‎.cs‎ +254 -0
Tag‎.cs‎ +165 -0
Use‎r.cs‎ +285 -0
Mod‎ules‎
PetMod‎ule.cs‎ +247 -0
StoreMo‎dule.cs‎ +129 -0
UserMo‎dule.cs‎ +234 -0
Ut‎ils‎
LocalDateC‎onverter.cs‎ +55 -0
Parame‎ters.cs‎ +450 -0
Org.OpenAPI‎Tools.csproj‎ +66 -0
Org.OpenAPI‎Tools.nuspec‎ +13 -0
package‎s.config‎ +7 -0
Org.OpenAP‎ITools.sln‎ +25 -0
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpClientCodegen.java
+ 1
- 1
  • View file @ 5ba645ca


@@ -604,7 +604,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
}
for (final CodegenProperty property : codegenModel.readWriteVars) {
if (property.defaultValue == null && parentCodegenModel.discriminator != null && property.baseName.equals(parentCodegenModel.discriminator.getPropertyName())) {
if (property.defaultValue == null && parentCodegenModel.discriminator != null && property.name.equals(parentCodegenModel.discriminator.getPropertyName())) {
property.defaultValue = "\"" + name + "\"";
}
}
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CSharpNetCoreClientCodegen.java
+ 1
- 1
  • View file @ 5ba645ca


@@ -299,7 +299,7 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
}
for (final CodegenProperty property : codegenModel.readWriteVars) {
if (property.defaultValue == null && parentCodegenModel.discriminator != null && property.baseName.equals(parentCodegenModel.discriminator.getPropertyName())) {
if (property.defaultValue == null && parentCodegenModel.discriminator != null && property.name.equals(parentCodegenModel.discriminator.getPropertyName())) {
property.defaultValue = "\"" + name + "\"";
}
}
samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Cat.cs
+ 1
- 1
  • View file @ 5ba645ca


@@ -39,7 +39,7 @@ namespace Org.OpenAPITools.Model
/// Initializes a new instance of the <see cref="Cat" /> class.
/// </summary>
/// <param name="declawed">declawed.</param>
public Cat(bool declawed = default(bool), string className = default(string), string color = "red") : base(className, color)
public Cat(bool declawed = default(bool), string className = "Cat", string color = "red") : base(className, color)
{
this.Declawed = declawed;
}
samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools/Model/Dog.cs
+ 1
- 1
  • View file @ 5ba645ca


@@ -39,7 +39,7 @@ namespace Org.OpenAPITools.Model
/// Initializes a new instance of the <see cref="Dog" /> class.
/// </summary>
/// <param name="breed">breed.</param>
public Dog(string breed = default(string), string className = default(string), string color = "red") : base(className, color)
public Dog(string breed = default(string), string className = "Dog", string color = "red") : base(className, color)
{
this.Breed = breed;
}
samples/client/petstore/csharp/OpenAPIClientNet35/src/Org.OpenAPITools/Api/FakeApi.cs
+ 1
- 1
  • View file @ 5ba645ca


@@ -1568,7 +1568,7 @@ namespace Org.OpenAPITools.Api
if (pipe != null) localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("csv", "pipe", pipe)); // query parameter
if (ioutil != null) localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("csv", "ioutil", ioutil)); // query parameter
if (http != null) localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("space", "http", http)); // query parameter
if (http != null) localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("ssv", "http", http)); // query parameter
if (url != null) localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("csv", "url", url)); // query parameter
if (context != null) localVarQueryParams.AddRange(this.Configuration.ApiClient.ParameterToKeyValuePairs("multi", "context", context)); // query parameter
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 participants
Reference:
Source branch: github/fork/tomelfring/bugfix/6225

Menu

Explore Projects Groups Snippets