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

Disable ctor parameter sorting when ClassStyle is Record #2657

Open
Micha-kun opened this issue Jan 29, 2020 · 1 comment
Open

Disable ctor parameter sorting when ClassStyle is Record #2657

Micha-kun opened this issue Jan 29, 2020 · 1 comment

Comments

@Micha-kun
Copy link

I'm generating my api client using your tool (fantastic by now) but I'm annoyed with the fact that when ClassStyle is setted to Record, ctor parameters ignore yaml sorted items and reorder them in alphabetical order, making instantation a bother because I expect to have the same order as in yaml definition. For example:

UpdateInternalNameCommandDto:
  type: object
  properties:
    CorrelationId:
      type: string
      format: uuid
    Headers:
      type: object
      additionalProperties:
        type: string
    Timestamp:
      type: string
      format: date-time
    AggregateId:
      type: string
      format: uuid
    InternalName:
      type: string
  required:
      - CorrelationId
      - Headers
      - Timestamp
      - AggregateId
  additionalProperties: false

Generates this class (observe ctor parameter order):

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.4.0 (Newtonsoft.Json v11.0.0.0)")]
public partial class UpdateInternalNameCommandDto 
{
    [Newtonsoft.Json.JsonConstructor]
    public UpdateInternalNameCommandDto(System.Guid @aggregateId,
                                        System.Guid @correlationId,
                                        System.Collections.Generic.IDictionary<string, string> @headers,
                                        string @internalName,
                                        System.DateTimeOffset @timestamp)
    {
        this.CorrelationId = @correlationId;
        this.Headers = @headers;
        this.Timestamp = @timestamp;
        this.AggregateId = @aggregateId;
        this.InternalName = @internalName;
    }

    ...
}

But i would prefer it like this (focus on ctor):

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "10.1.4.0 (Newtonsoft.Json v11.0.0.0)")]
public partial class UpdateInternalNameCommandDto 
{
    [Newtonsoft.Json.JsonConstructor]
    public UpdateInternalNameCommandDto(System.Guid @correlationId,
                                        System.Collections.Generic.IDictionary<string, string> @headers,
                                        System.DateTimeOffset @timestamp,
                                        System.Guid @aggregateId,
                                        string @internalName)
    {
        this.CorrelationId = @correlationId;
        this.Headers = @headers;
        this.Timestamp = @timestamp;
        this.AggregateId = @aggregateId;
        this.InternalName = @internalName;
    }

    ....
}

Currently, this is possible to configure?

Thank you.

@RicoSuter
Copy link
Owner

Duplicate of RicoSuter/NJsonSchema#1055

@RicoSuter RicoSuter marked this as a duplicate of RicoSuter/NJsonSchema#1055 Jan 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants