zijianhuang / openapiclientgen

Generate strongly typed C# and TypeScript client codes from Open API / Swagger definitions supporting jQuery, Angular, AXIOS, Fetch API, Aurelia and Angular Strictly Typed Forms
MIT License
64 stars 13 forks source link

ArrayAs setting not working #41

Closed codertimu closed 2 years ago

codertimu commented 2 years ago

Take the following example api spec:

openapi: 3.0.3
info:
  title: Test openapi spec file for dictionary field
  version: v1
paths:
  '/hello':
    get:
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TestModel'

components:
  schemas:
    TestModel:
      description: Model information
      properties:
        myArray:
          type: array
          items:
            type: string
          nullable: true
{
  "ClientNamespace": "MyNS",
  "ClientLibraryProjectFolderName": "./TestModels",
  "CreateFolder": true,
  "GenerateModelsOnly": true,
  "ArrayAs": 6
}

Using ArrayAs setting does not change the type of the array, it is always the regular array type:

namespace MyNS
{

    /// <summary>
    /// Model information
    /// </summary>
    public class TestModel
    {

        [System.Text.Json.Serialization.JsonPropertyName("myArray")]
        public string[] MyArray { get; set; }
    }
}
Kim-SSi commented 2 years ago

In Fonlow.OpenApiClientGen.ClientTypes: It looks like TypeRefHelper.CreateArrayTypeReference does not handle settings.ArrayAs. An example is ComponentsHelper.CreateArrayOfCustomTypeReference

zijianhuang commented 2 years ago

fixed. to be released in 2.3.2