openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG] ASPNETCORE Collection And ICollection - Missing using System.Collections.ObjectModel;

Open manhao-chen opened this issue 6 years ago • 3 comments

using 4.0.2 generating for aspnetcore below are my settings

    <groupId>org.openapitools</groupId>
    <artifactId>openapi-generator-maven-plugin</artifactId>
    <version>4.0.2</version>
    <executions>
      <execution>
        <phase>process-sources</phase>
        <goals>
          <goal>generate</goal>
        </goals>
        <configuration>
          <inputSpec>${project.namespace}/bin/swagger/swagger.yaml</inputSpec>
          <generatorName>aspnetcore</generatorName>
          <output>./</output>
          <generateApiTests>false</generateApiTests>
          <generateModelTests>false</generateModelTests>
          <generateApiDocumentation>false</generateApiDocumentation>
          <generateModelDocumentation>false</generateModelDocumentation>
          <skipValidateSpec>true</skipValidateSpec>
          <apiPackage>${project.namespace}.Api</apiPackage>
          <modelPackage>${project.namespace}.Model</modelPackage>
          <configOptions>
              <returnICollection>true</returnICollection>
              <useCollection>true</useCollection>
              <generateBody>false</generateBody>
              <operationResultTask>true</operationResultTask>
              <classModifier>abstract</classModifier>
              <operationModifier>abstract</operationModifier>
              <sourceFolder>./</sourceFolder>
              <packageName>${project.namespace}</packageName>
          </configOptions>
        </configuration>
      </execution>
    </executions>
  </plugin>

2 issues found

  1. useCollection property works but missing the using System.Collections.ObjectModel;
  2. returnICollection doesn't appear to work it still generates as Collection not ICollection

expect the using System.Collections.ObjectModel; statement to also be generated and placed at the top of class file

other nice to have please additional options if possible

  • Dictionary as IDictionary
  • List as IList

manhao-chen avatar Jul 08 '19 21:07 manhao-chen

@manhao-chen Could you please try again with the latest 5.0.0-beta? I'm wondering if this is still valid

InfoSec812 avatar Aug 16 '20 12:08 InfoSec812

Not sure if it's related, but I'm using 5.2.1 and returnICollection with the csharp-netcore generator does not do anything either

UnstoppableMango avatar Sep 05 '21 18:09 UnstoppableMango

It's now 5 years later and this issue is still there in the current latest version 7.5.0. Are there any plans to fix this? @wing328

marcselman avatar May 24 '24 10:05 marcselman