OpenAPITools / OpenAPITools/openapi-generator

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

Open
#3,311 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the provided Maven plugin configuration and the aspnetcore generator, using the useCollection and returnICollection options. Inspect the generated class file and compare its collection types and using statements with the requested output. Done means the appropriate collection imports and configured interface types are generated consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.