16 Commits

Author SHA1 Message Date
agilob
90d8c32906
[Dart] Fix enum generation (#6729)
* [Dart] Fix enum generation

* Update generated Order file

* Re-add constructor

* Generate dart2 files

* Dart - nicer enum formatting

* Dart - generate enum name as className+enumName

* Dart - dont initialize vars to null by default

Fixes #3633

* Dart - Generate inlined enums and deserialize them

* Merge branch 'master' of github.com:agilob/openapi-generator into 6727

* Dart - Fix using default value

* Fix typo

* Regenerate add dart files

* dart Revert override for dart dio and jaguar

* Fix dart model tests

* Fix dart1 generated template

* Use {{{datatypeWithEnum}}}

* Dart - throw when enum not known

* Fix generating enum with datatype from list
2020-07-23 11:26:25 +08:00
Jim Schubert
54d7e8c488
[CLI] Initial implementation for batch generation (#3789)
* [CLI] Initial implementation for batch generation

Allows for generating multiple outputs via config. Just specify multiple
config files on command line.

Intent for this is to reduce CI times to generate outputs as well as to
reduce time for users to run ensure-up-to-date to meet PR standards.

Example command:

  openapi-generator batch --includes-base-dir `pwd` --fail-fast  -- bin/ci/*

---

As part of this implementation, the batch command support a customized
JSON key, `!include`. If this key's value refers to an existing file,
that file's contents are "unwrapped" into the config during
deserialization. This allows us to easily point to the same configs used
by our sample scripts without modifying the CLI generate task's switches
or assumptions.

* Allow for path-relative outputs
* Add batch JSON objects
* Include INFO log about threads used and includes/root
* Ensure GlobalSettings.reset()
* Improved thread-safety of ModelUtils
2019-10-09 12:51:52 -04:00
Nick Meinhold
41acae19e4 Dart fix template tests (#4015)
* Clean up samples directory before fixing tests

- removed from samples/client/petstore/dart2 :
  - purge_test.sh (doesn't seem to be used and not helpful)
  - openapi folder (is to be re-generated with more meaningful name)
- updated dart2-petstore.sh to generate client library with new name
- used updated shell script to re-generate client library
- updated CI/.drone.yml to use the new client library for tests

* Update petstore tests to use faked http client

- skipped all of the tests that hit a live endpoint
- made a fake http client that can be set to check for expected values
   and/or return a provided response
- added some files with test data recorded from live api calls
- updated the README to reflect changes to tests

* Update .drone.yml so CI will run the tests
2019-10-02 11:16:05 +08:00
William Cheng
8236424aff
Fix Dart2 default template (#3790)
* fix dart2 default template

* update dart samples
2019-08-29 15:10:19 +08:00
William Cheng
136c1407ac
Move tests to Drone.io CI (#3754)
* move tests to drone.io

* ls dir

* debug

* use bash

* use jdk 11 image

* move tests to drone.io

* use maven wrapper

* comment out scripts in circleci

* update dart samples

* remove commented tests

* update dart samples
2019-08-26 00:35:51 +08:00
Nick Meinhold
a05f68431a [Dart] Avoid redundant null checking in fromJson (#3632)
* Move dart null checks inside mustache type checks

- removed surrounding null check
- added a conditional expression to each case except the redundant one

* Run shell scripts so CIs can verify the change
2019-08-25 01:16:32 +08:00
Paul Mundt
4b0fc3013f [dart2] Fix up test code generation, double deserialization, 'new' keyword deprecation (#3576)
* dart2: Use the correct classname in test generation

At present test generation has a stray hard-coded reference to the pet
store Pet() class, which should reflect the actual classname under test.

* dart2: Call toDouble() in generated code for double types

At present the generated code does not correctly handle transitioning
to double when dealing with non-integer types in JSON deserialization.
This ends up with dart raising an unhandled type mismatch exception:

Unhandled exception: type 'int' is not a subtype of type 'double' where
...

Using the .toDouble() conversion when a double type is expected fixes
this up by making the typing explicit.

* dart2: Drop use of deprecated 'new' keyword in generated code

The use of the 'new' keyword in dart2 is deprecated and should be
avoided, as per the official guidance of the dart2 authors:

https://dart.dev/guides/language/effective-dart/usage#dont-use-new

* dart2: Regenerate samples for mustache template changes
2019-08-09 00:15:45 +08:00
Alexis Yushin
4b414d81d4 dart2: Do not add non-nullable fields to model json (#2777)
* do not add non-nullable fields to model json

This fix would avoid adding and sending fields that are not isNullable in the request.

* updated sample for issue #2535
2019-05-02 16:31:38 +08:00
Paul Mundt
c08c45de05 dart2 linter updates for prefer_equal_for_default_values, prefer_is_empty (#2654)
* Use isNotEmpty instead of length in dart2 validity checks

In dart2 the preferred method of checking whether an object is empty or
not is to use the .isNotEmpty property. An aspect that is now warned
about by the linter.

While not an issue in this particular case - testing length can also
have negative performance implications for Iterable collections, which
are not required to know or provide their length deterministically.

* Prefer equals for default values in dart2

The dart2 linter complains about m({a: 1}) style assignments, preferring
m({a = 1}) instead. Update the api_client generation to follow this.

* Regenerate dart2 samples for mustache template changes
2019-04-17 10:57:06 +08:00
Dale King
d93fd31bb1 [dart] Fix authentication for dart (#2419)
* [dart] Fix authentication so all forms of Swagger 2.0 authentication work

* Run changes on petstore examples

* Amend dart2 generated README to cover basic authentication

* Amend dart2 generated README to cover authentication methods

* [dart] Fix authentication so all forms of Swagger 2.0 authentication work

* Run changes on petstore examples
2019-03-19 10:08:43 +08:00
d3v-cl
49b15ee518 Dart queryargs (#2250)
* [DART2]: fix encoding query args

* [DART]fix: url encode query arguments

* [DART][DART2]feat: rebuild petstore
2019-03-07 15:52:34 +08:00
d3v-cl
bc6997f0e5 [DART2]: fix Map<String, nativeType> fromJson (#1936) 2019-01-25 10:54:46 +08:00
d3v-cl
9ccf872290 [DART] fix: set fields to null if json value is null. (#1798)
* fix: set fields to null if json value is null.

* rebuild dart2 petstore

* rebuild dart petstore

* rebuild petstore

* [DART]fix: set fields to null if json value is null.
2019-01-09 00:26:46 +08:00
ircecho
58e43ceeec [DART2] Maps could not be deserialized in dart 2 (#1007)
* fix[dart2]: due to stronger type checking in dart 2, maps could not be deserialized

* rebuild dart2 petstore
2018-09-14 18:40:37 +08:00
William Cheng
d9400caf69
Set Dart2 as default, better format Dart code with dartfmt (#949)
* change dart default to v2

* add dart2 author

* add dartfmt to postProcess file in dart generator

* add dartfmt to format dart code
2018-09-02 17:59:42 +08:00
Yimin Lin
d327c5be46 [Dart 2] Add support for Dart 2 (#754)
* Add an option for Dart2

* add dart2 samples, update travis

* fix dart installation

* Upper constraints on the SDK version

* Update dependencies

* supportDart2 option can now be passed through --additional-properties

* Update petstore tests

* Update dart2-petstore.sh

* Running tests on Dart VM

* Fixed JSON deserialization bugs

* Fixed missing initialization of postBody

* Run bin/dart2-petstore.sh to regenerate libraries

* Update pom.xml

* Added SDK version constraints in pubspec.mustache

* Run bin/dart2-petstore.sh to regenerate libraries

* move dart2 test to the end
2018-09-01 01:49:18 +08:00