question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] CodegenParameter.baseType is different than CodegenProperty.baseType

See original GitHub issue

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What’s the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When generating specs with a container type, the behavior of CodegenParameter and CodegenProperty is inconsistent.

  • in CodegenParameter the baseType refers to the items type
  • in CodegenProperty the baseType refers to the container type (the correct behavior)

e.g. generating modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml with any generator (tested with csharp and dart-dio-next)

  • operation createUsersWithArrayInput has array of User as body parameter when debugging this:
    "bodyParam" : {
          "dataType" : "BuiltList<User>",
          "baseType" : "User",
    ...
    }
    
  • Model NullableClass has property array_nullable_prop which is a list of objects when debugging this:
    {
        "dataType" : "BuiltList<JsonObject>",
        "datatypeWithEnum" : "BuiltList<JsonObject>",
        "baseType" : "BuiltList", 
    ...
    }
    
openapi-generator version

5.2.1 (latest master commit a7de7095a7bfb6f84f8a7115b009db612db24a26)

Generation Details

for dart-dio-next: ./bin/generate-samples.sh bin/configs/dart-dio-next* -- --global-property debugOperations,debugModels > log.txt for csharp: ./bin/generate-samples.sh bin/configs/other/openapi3/csharp-OpenAPIClientNetStandard.yaml -- --global-property debugOperations,debugModels > log_cs.txt

cc @wing328 @kuhnroyal @agilob

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ahmednfwelacommented, Aug 18, 2021

yes, the problem is there is no way to get the list type alone in the operation parameters

0reactions
kuhnroyalcommented, Aug 18, 2021

Yea, not sure where this is handled. You can try to rewrite the baseType similar to the handling here: https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioNextClientCodegen.java#L294

All the information needed (container type, unique items) should be available.

Read more comments on GitHub >

github_iconTop Results From Across the Web

io.swagger.codegen.languages.DefaultCodegenConfig ...
Go to download ... CodegenParameter; import io.swagger.codegen. ... baseType, toEnumName(baseItem)); // naming the enum with respect to the language enum ...
Read more >
modules/openapi-generator/src/main/java/org/openapitools ...
baseType = getSchemaType(p); // this can cause issues for clients which don't support enums if (property.isEnum) { property.
Read more >
CodegenParameter (swagger-codegen (core library) 2.4.1 API)
public class CodegenParameter extends Object ... Methods inherited from class java.lang. ... baseType. public String baseType ...
Read more >
io.swagger.codegen.languages.ElixirClientCodegen.java ...
if you want to create one template for file, you can do so here. * for multiple files for model, just put another...
Read more >
openapi-generator / - src / - main / - java / - org - Program Talk
Learn how to use api ... may not be properly formatted by uncrustify (0.66 or later) or other code formatter. To ... baseType;...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found