Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] C# allof inheritance ok, but local properties mssing #1858

Closed
ericbl opened this issue Jan 8, 2019 · 3 comments
Closed

[BUG] C# allof inheritance ok, but local properties mssing #1858

ericbl opened this issue Jan 8, 2019 · 3 comments

Comments

@ericbl
Copy link

ericbl commented Jan 8, 2019

Description

As already mentioned in few bugs, the allof still has issues.

I want to generate C# code from a swagger file in which I use allOf to create inheritance.
The generated child class should inherits the parent class and has its own properties.

The generated code (see below) received only the inheritance, without the local properties: the properties defined for the child class were not generated.

openapi-generator version

Lastest pull of docker image / SwaggerEditor UI, thus using generator version 3.2 ?

OpenAPI declaration file content or url

I defined the following in my swagger file:

  Result:
    type: object
    required:
      - value
    properties:
      value:
        type: object
 AugmentedResult:
    allOf: 
      - $ref: '#/definitions/Result'
    properties:
      recommendations:
        type: object
        properties:
          intents:
            type: array
            items:
              type: string
Steps to reproduce

I tried both generate server/aspnetcore and generate client/csharp from SwaggerEditor

I get the 2 classes in the models, where AugmentedResult inherits from Result.
But the properties defined in AugmentedResult are NOT generated.

And the rest of the class is also useless, starting with (GetHashCode, Equals, ToString()) where the local properties are also missing.

    public partial class AugmentedResult : Result,  IEquatable<AugmentedResult>, IValidatableObject
    {
        [JsonConstructorAttribute]
        protected AugmentedResult() { }
        public AugmentedResult(string type = default(string), Object value = default(Object)) : base(type, value)
        {
        }       
        public override string ToString()
        {
            var sb = new StringBuilder();
            sb.Append("class AugmentedResult {\n");
            sb.Append("  ").Append(base.ToString().Replace("\n", "\n  ")).Append("\n");
            sb.Append("}\n");
            return sb.ToString();
        }

        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                int hashCode = base.GetHashCode();
                return hashCode;
            }
        }
Related issues/PRs

Maybe 704
#1842

@ericbl ericbl changed the title [BUG] C# allof inheritance ok, but local properties ignored [BUG] C# allof inheritance ok, but local properties mssing Jan 8, 2019
@wing328
Copy link
Member

wing328 commented Jan 8, 2019

@ericbl please try the latest snapshot: https://github.com/OpenAPITools/openapi-generator#11---compatibility (JAR or docker images)

@nolanlocke
Copy link

This is also an issue in the typescript-fetch client

Using latest snapshot this is still an occurring issue

@InfoSec812
Copy link
Contributor

@ericbl and @nolanlocke This appears to be working as expected in the latest 5.0.0-beta, could you test and confirm?

@wing328 wing328 closed this as completed Sep 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants