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

could not process model nullenum #185

Closed
NANASHI0X74 opened this issue Oct 30, 2020 · 14 comments
Closed

could not process model nullenum #185

NANASHI0X74 opened this issue Oct 30, 2020 · 14 comments
Labels
enhancement New feature or request fix confirmation pending issue has been fixed and confirmation from issue reporter is pending

Comments

@NANASHI0X74
Copy link

Describe the bug
I just wanted to try out generating some client code in dart against our backend, but running the openapitools generator, I get an unhelpful error: Could not process model 'NullEnum'.Please make sure that your schema is correct! (see end of output below). I tried a few other generators too and got the same error

To Reproduce

manage.py spectacular > openapi-spec.yml

generator command run and output
~/Documents/prewoe_backend> openapi-generator-cli generate -i app/openapi-spec.yml -g dart -o sample-generated.dart
[main] WARN  o.o.c.ignore.CodegenIgnoreProcessor - Output directory does not exist, or is inaccessible. No file (.openapi-generator-ignore) will be evaluated.
[main] INFO  o.o.codegen.DefaultGenerator - OpenAPI Generator: dart (client)
[main] INFO  o.o.codegen.DefaultGenerator - Generator 'dart' is considered stable.
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] WARN  o.o.codegen.utils.ModelUtils - Multiple schemas found in the OAS 'content' section, returning only the first one (application/json)
[main] INFO  o.o.c.languages.DartClientCodegen - Environment variable DART_POST_PROCESS_FILE not defined so the Dart code may not be properly formatted. To define it, try `export DART_POST_PROCESS_FILE="/usr/local/bin/dartfmt -w"` (Linux/Mac)
[main] INFO  o.o.c.languages.DartClientCodegen - NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).
[main] INFO  o.o.c.languages.DartClientCodegen - Dart version: 2.x
[main] WARN  o.o.codegen.utils.URLPathUtils - 'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [http://localhost] for server URL [http://localhost/]
[main] WARN  o.o.codegen.utils.URLPathUtils - 'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [http://localhost] for server URL [http://localhost/]
Exception in thread "main" java.lang.RuntimeException: Could not process model 'NullEnum'.Please make sure that your schema is correct!
        at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:473)
        at org.openapitools.codegen.DefaultGenerator.generate(DefaultGenerator.java:938)
        at org.openapitools.codegen.cmd.Generate.run(Generate.java:423)
        at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:61)
Caused by: java.lang.NullPointerException
        at org.openapitools.codegen.languages.DartClientCodegen.buildEnumFromValues(DartClientCodegen.java:480)
        at org.openapitools.codegen.languages.DartClientCodegen.postProcessModelsEnum(DartClientCodegen.java:453)
        at org.openapitools.codegen.languages.DartClientCodegen.postProcessModels(DartClientCodegen.java:443)
        at org.openapitools.codegen.DefaultGenerator.processModels(DefaultGenerator.java:1214)
        at org.openapitools.codegen.DefaultGenerator.generateModels(DefaultGenerator.java:468)
        ... 3 more

Expected behavior
The generator generates some code or tells me what i can do to make it work 😅

Not sure if I should rather file this issue on the codegenerator or if I'm doing something wrong, but I thought maybe someone here can help me understand this exception

@tfranzel
Copy link
Owner

Hi @NANASHI0X74 , so first of all, all those Multiple schemas found are "normal" and can be ignored

the last release contained a feature that models null=True and blank=True on choice fields.

    B:
      type: object
      properties:
        language:
          nullable: true
          oneOf:
          - $ref: '#/components/schemas/LanguageEnum'
          - $ref: '#/components/schemas/BlankEnum'
          - $ref: '#/components/schemas/NullEnum'
      required:
      - language
    BlankEnum:
      enum:
      - ''
    LanguageEnum:
      enum:
      - en
      - es
      - ru
      - cn
      type: string
    NullEnum:
      enum:
      - null

apparently the generator does not like the NullEnum even though that is most likely the correct schema. you can run ./manage spectacular --validate --file foo.yaml to run the schema validation. The specification says that nullable: true AND - null as choice must be present. the last i checked the typescript-fetch target did in fact accept it.

its a unfortunate situation where a "proper" schema lets the generator bail.

@tfranzel
Copy link
Owner

tfranzel commented Nov 1, 2020

@NANASHI0X74 with the latest openapi-generator version from docker and target dart it does not throw errors for me. i used the tests/test_postprocessing.yml which does contain above example with NullEnum and BlankEnum

can you test with the latest generator?

# ./helper/generate-client.sh tests/test_postprocessing.yml dart pp-dart
removing old client at .../drf-spectacular/generated_clients/pp-dart
Using default tag: latest
latest: Pulling from openapitools/openapi-generator-cli
Digest: sha256:7234abf7315e456fd08588a7179c4efdc18defcfd18448a7905e7a4e24333fa5
Status: Image is up to date for openapitools/openapi-generator-cli:latest
docker.io/openapitools/openapi-generator-cli:latest
generator version: 5.0.0-SNAPSHOT
[main] INFO  o.o.codegen.DefaultGenerator - Generating with dryRun=false
[main] INFO  o.o.c.ignore.CodegenIgnoreProcessor - No .openapi-generator-ignore file found.
[main] INFO  o.o.codegen.DefaultGenerator - OpenAPI Generator: dart (client)
[main] INFO  o.o.codegen.DefaultGenerator - Generator 'dart' is considered stable.
[main] INFO  o.o.c.languages.DartClientCodegen - Environment variable DART_POST_PROCESS_FILE not defined so the Dart code may not be properly formatted. To define it, try `export DART_POST_PROCESS_FILE="/usr/local/bin/dartfmt -w"` (Linux/Mac)
[main] INFO  o.o.c.languages.DartClientCodegen - NOTE: To enable file post-processing, 'enablePostProcessFile' must be set to `true` (--enable-post-process-file for CLI).
[main] INFO  o.o.codegen.utils.URLPathUtils - 'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [http://localhost] for server URL [http://localhost/]
[main] INFO  o.o.codegen.utils.URLPathUtils - 'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [http://localhost] for server URL [http://localhost/]
[main] INFO  o.o.codegen.TemplateManager - writing file /build/lib/model/a.dart
[main] INFO  o.o.codegen.TemplateManager - writing file /build/test/a_test.dart
[main] INFO  o.o.codegen.TemplateManager - writing file /build/doc/A.md
[main] INFO  o.o.codegen.TemplateManager - writing file /build/lib/model/b.dart
[main] INFO  o.o.codegen.TemplateManager - writing file /build/test/b_test.dart
[main] INFO  o.o.codegen.TemplateManager - writing file /build/doc/B.md
[main] INFO  o.o.codegen.TemplateManager - writing file /build/lib/model/blank_enum.dart
[main] INFO  o.o.codegen.TemplateManager - writing file /build/test/blank_enum_test.dart
[main] INFO  o.o.codegen.TemplateManager - writing file /build/doc/BlankEnum.md
[main] INFO  o.o.codegen.TemplateManager - writing file /build/lib/model/language_enum.dart
[main] INFO  o.o.codegen.TemplateManager - writing file /build/test/language_enum_test.dart
[main] INFO  o.o.codegen.TemplateManager - writing file /build/doc/LanguageEnum.md
[main] INFO  o.o.codegen.TemplateManager - writing file /build/lib/model/null_enum.dart
[main] INFO  o.o.codegen.TemplateManager - writing file /build/test/null_enum_test.dart
[main] INFO  o.o.codegen.TemplateManager - writing file /build/doc/NullEnum.md
[main] INFO  o.o.codegen.utils.URLPathUtils - 'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [http://localhost] for server URL [http://localhost/]
[main] INFO  o.o.codegen.TemplateManager - writing file /build/lib/api/a_api.dart
[main] INFO  o.o.codegen.TemplateManager - writing file /build/test/a_api_test.dart
[main] INFO  o.o.codegen.TemplateManager - writing file /build/doc/AApi.md
[main] INFO  o.o.codegen.utils.URLPathUtils - 'host' (OAS 2.0) or 'servers' (OAS 3.0) not defined in the spec. Default to [http://localhost] for server URL [http://localhost/]
[main] INFO  o.o.codegen.TemplateManager - writing file /build/pubspec.yaml
[main] INFO  o.o.codegen.TemplateManager - writing file /build/lib/api_client.dart
[main] INFO  o.o.codegen.TemplateManager - writing file /build/lib/api_exception.dart
[main] INFO  o.o.codegen.TemplateManager - writing file /build/lib/api_helper.dart
[main] INFO  o.o.codegen.TemplateManager - writing file /build/lib/api.dart
[main] INFO  o.o.codegen.TemplateManager - writing file /build/lib/auth/authentication.dart
[main] INFO  o.o.codegen.TemplateManager - writing file /build/lib/auth/http_basic_auth.dart
[main] INFO  o.o.codegen.TemplateManager - writing file /build/lib/auth/http_bearer_auth.dart
[main] INFO  o.o.codegen.TemplateManager - writing file /build/lib/auth/api_key_auth.dart
[main] INFO  o.o.codegen.TemplateManager - writing file /build/lib/auth/oauth.dart
[main] INFO  o.o.codegen.TemplateManager - writing file /build/git_push.sh
[main] INFO  o.o.codegen.TemplateManager - writing file /build/.gitignore
[main] INFO  o.o.codegen.TemplateManager - writing file /build/README.md
[main] INFO  o.o.codegen.TemplateManager - writing file /build/.travis.yml
[main] INFO  o.o.codegen.TemplateManager - writing file /build/.openapi-generator-ignore
[main] INFO  o.o.codegen.TemplateManager - writing file /build/.openapi-generator/VERSION
[main] INFO  o.o.codegen.TemplateManager - writing file /build/.openapi-generator/FILES
#

@tfranzel tfranzel added the question Further information is requested label Nov 1, 2020
@NANASHI0X74
Copy link
Author

ok, it works with version 4.3.1. I'd tried version 4.2.2 and a snapshot of 5.0.0.
Closing, thanks :)

@tfranzel
Copy link
Owner

tfranzel commented Nov 2, 2020

awesome! let me know if generated client is functioning properly with regards to this Enum thing.

@NANASHI0X74
Copy link
Author

At the moment, the dart generator doesn't support oneof properly :(
see OpenAPITools/openapi-generator#3965 OpenAPITools/openapi-generator#3884
I realized that a bit late, even though the code doesn't even compile :/

@NANASHI0X74
Copy link
Author

I guess I'll try version 0.9.14 instead

@NANASHI0X74
Copy link
Author

still doesn't work, but now it throws a different error:

build output
../dart-apiclient/lib/model/company_edit.dart:37:8: Error: Type 'AnyType' not found.

  List<AnyType> subscriptions = [];

       ^^^^^^^

../dart-apiclient/lib/model/patched_company_edit.dart:37:8: Error: Type 'AnyType' not found.

  List<AnyType> subscriptions = [];

       ^^^^^^^

../dart-apiclient/lib/model/company_edit.dart:37:8: Error: 'AnyType' isn't a type.

  List<AnyType> subscriptions = [];

       ^^^^^^^

../dart-apiclient/lib/model/company_edit.dart:199:7: Error: The getter 'AnyType' isn't defined for the class 'CompanyEdit'.

 - 'CompanyEdit' is from 'package:openapi/api.dart' ('../dart-apiclient/lib/api.dart').

Try correcting the name to the name of an existing getter, or defining a getter or field named 'AnyType'.

      AnyType.listFromJson(json['subscriptions']);

      ^^^^^^^

../dart-apiclient/lib/model/patched_company_edit.dart:37:8: Error: 'AnyType' isn't a type.

  List<AnyType> subscriptions = [];

       ^^^^^^^

../dart-apiclient/lib/model/patched_company_edit.dart:199:7: Error: The getter 'AnyType' isn't defined for the class 'PatchedCompanyEdit'.

 - 'PatchedCompanyEdit' is from 'package:openapi/api.dart' ('../dart-apiclient/lib/api.dart').

Try correcting the name to the name of an existing getter, or defining a getter or field named 'AnyType'.

      AnyType.listFromJson(json['subscriptions']);

      ^^^^^^^

FAILURE: Build failed with an exception.

@NANASHI0X74
Copy link
Author

almost works with openapitools version 4.2.2, but then there's no method Object.listFromJson :/
Now I'm kind of at my wit's end 😬

@tfranzel
Copy link
Owner

ok so first of all i would recommend using version v5.0.0, either the snapshot or the most recent beta, i.e. openapi-generator v5.0.0-beta2. it has a lot of improvements over 4.x. at least that is my experience.

i have noticed that this feature also made some trouble for us. it might be better to make it optional via setting. even though the schema is technically "more" correct like this, it is a meaningless win if it breaks the clients.

we employ oneOf etc at several locations. you might have been lucky avoiding these other ones. once you use anything polymorphic there is no way around it, but that might just not be the case for you.

@NANASHI0X74
Copy link
Author

yeah I had the same thought that it would be handy to have a cli switch or something to switch off the null/blankenum stuff

The issues and related PRs for dart are still open, so I don't think switching to a newer version will really help me, For now I think I'll just take the parts that I really need right now from the generated code and whack them into shape manually :p

@tfranzel
Copy link
Owner

i see. makes sense. it would prob be easier just remove those parts in the schema. may be easier than editing the client.

i will deal with this asap.

@tfranzel tfranzel reopened this Nov 12, 2020
@tfranzel tfranzel added enhancement New feature or request and removed question Further information is requested labels Nov 12, 2020
@lsaavedr
Copy link
Contributor

please make this feature optional T_T

@tfranzel
Copy link
Owner

@lsaavedr @NANASHI0X74 . generally, i try to make the schema as accurate as possible by default (regardless of generators). after that i try to provide options to make the client-generator usable. just as a rationale for the default ON choice.

please confirm that this works as expected

@tfranzel tfranzel added the fix confirmation pending issue has been fixed and confirmation from issue reporter is pending label Nov 13, 2020
@lsaavedr
Copy link
Contributor

@tfranzel works flawlessly, thanks you very much!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fix confirmation pending issue has been fixed and confirmation from issue reporter is pending
Projects
None yet
Development

No branches or pull requests

3 participants