64 Commits

Author SHA1 Message Date
William Cheng
4602f18ca8
Add model name mapping feature to C# codegen (#16209)
* add model name mapping feature to C# codegen

* rename file

* update samples

* update doc
2023-08-02 10:06:11 +08:00
William Cheng
0a02860b50
add parameter name mapping (#16160) 2023-07-24 15:54:40 +08:00
William Cheng
6983a3acf3
Add nameMapping option to Java client, server generators (#16103)
* add nameMapping to java codegen

* update doc

* update samples

* fix typo

* update toParamName
2023-07-17 11:37:49 +08:00
William Cheng
0a6671044f
Rename inlineSchemaNameDefaults to inlineSchemaOptions (#16048)
* rename InlineSchemaNameDefaults to InlineSchemaOptions

* update doc

* rename options
2023-07-11 18:07:09 +08:00
Michael Glanznig
05b9a899e4
add support for dry-run flag to Maven and Gradle plugins, fixes #15729 (#15734) 2023-06-03 11:06:58 +08:00
martin-mfg
e0f42961c5
add missing documentation for maven and gradle options (#15322) 2023-04-27 12:43:37 +08:00
Oleh Kurpiak
18e28ab761
[Java] maven plugin to clean-up output before generation (#14935) 2023-03-25 15:44:40 +08:00
Oleh Kurpiak
2bc963f00c
Generate merge spec (#14387) 2023-02-17 10:40:05 +08:00
William Cheng
b71aecbe9e
Add OpenAPI Normalizer (#14172)
* add x-parent support

* add docstring

* add openapi normalizer rule to use ref as parent in allof

* add openapi normalizer with 1 rule

* revise wordings

* fix javadoc warnings

* better test

* fix docstring

* minor update

* minor improvements

* fix typo
2022-12-30 16:03:21 +08:00
Nathan Baulch
9f1fa0e440
Fix another batch of spelling typos (#13915)
* Fix typos

* Remove repeated words

* Minor grammar fixes
2022-11-07 21:30:24 +08:00
Rostislav Krasny
4694a9f0af
[maven] Use one of two default paths of output directory according to the lifecycle phase (#13151)
In case the lifecycle phase is "generate-test-sources" the default output directory is:
"${project.build.directory}/generated-test-sources/openapi"

In case of any other lifecycle phase the default output directory is:
"${project.build.directory}/generated-sources/openapi"

Also use the "src/main/java" as the only default source folder in the output path for both
cases when addCompileSourceRoot == true and when addTestCompileSourceRoot == true.
In case you really need "src/test/java" it still can be set in the configOptions manually:

    <configOptions>
        <sourceFolder>src/test/java</sourceFolder>
    </configOptions>
2022-09-04 17:21:16 +08:00
William Cheng
2d3bfaf96d
Add schema mappings (#12600)
* add option schema mappings

* add schema mapping support, update tests

* minor fix

* update other generators, tests
2022-07-03 17:46:39 +08:00
William Cheng
ee9b9843db
Add new option to customize inline model naming convention (#12562)
* temp fix

* add support to customize inline schema naming convention

* Revert "temp fix"

This reverts commit e3bca56bfbb0032d382fe79cd2a8565f4aad630c.

* minor fix, add tests

* update description
2022-06-11 09:12:22 +08:00
Peter Leibiger
111675b89b
[dart][core] Fix reservedWordsMappings (#12436)
* [core] Fix naming of reservedWordsMappings 

* `GeneratorSettings` used a wrong name (missing `s`) which resulted in config loaded from YAMl files not working

* [dart] Respect reservedWordsMappings when checking for reserved words
2022-05-25 11:56:51 +08:00
William Cheng
53eebc953f
New option to map inline schema names (#12237)
* add option to specify inline schema nam mapping

* update samples

* update samples

* add new option to plugins

* better code format

* better code format

* better log info

* better docstring

* add tests
2022-04-27 01:13:45 +08:00
Oleh Kurpiak
346dfbc102
Configure apiNameSuffix via plugins (#12062) 2022-04-09 09:34:06 +08:00
sullis
4a7f46cba5
[java] openapi-generator-maven-plugin: add jaxrs-jersey2 test (#11658) 2022-02-19 18:50:50 +08:00
Larry Diamond
10b310d33f
Optimize: entrySet is faster than keySet + get to prevent N lookups (#10496)
* Optimize: replace keySet + N get calls with entrySet saving N calls to get method in a few places

* missed one performance optimization

* Rolling back a change that was dependent on Java 11
2021-10-04 16:37:34 +08:00
Nathan Baulch
5d68bd6a03
Fix thousands of spelling typos (#10272) 2021-08-28 22:58:24 +08:00
David Hutchison
fce10c7284
fix: correctly checks the hash file when using a classpath input spec (#9840)
The skipIfSpecIsUnchanged did not work when the input spec came from a
classpath resource, which could lead to infinite build loops when the
plugin was used in eclipse

#5805
2021-08-15 16:04:57 +08:00
Thibault Duperron
4462d35195
Link filehash with execution id (#7848)
Co-authored-by: William Cheng <wing328hk@gmail.com>
2021-04-05 21:11:27 +08:00
cal
862e9cb79a
[cleanup] erefactor/EclipseJdt - Remove unused imports (#9066)
EclipseJdt cleanup 'RemoveUnusedImport' applied by erefactor.

For EclipseJdt see https://www.eclipse.org/eclipse/news/4.19/jdt.php
For erefactor see https://github.com/cal101/erefactor
2021-03-25 10:51:53 +08:00
William Cheng
91805936e6
[maven plugin] fix security issues (#8795)
* use Files.createTempFile in maven plugin to avoid security issues

* error check when creating a folder
2021-02-24 11:45:44 +08:00
agilob
e7f50f66a3
Make all loggers non-static (#8799)
* Make all loggers non-static

Reduces memory usage on startup by between 2 and 4 MB

* Fix compile error in some autogenerated? module
2021-02-23 14:46:56 +08:00
William Cheng
9c20050bdc
Add an option to skip operation examples (#8731)
* add flag to skip operation examples

* reset to false
2021-02-20 11:51:21 +08:00
Jim Schubert
ee1cbf6f4b
[bug][maven] Fix custom windows classpaths in maven plugin (#7587)
* [maven] Fallback to templates using classpath rather than OS-specific paths

Previous checks would cause logic in Windows to return early, for
built-in templates only. This reorganizes and simplifies the ordering
behavior.

* Match classpath check in WorkflowSettings with that in TemplateManager

* [maven] Much needed unit/integration tests

This follows similar approach used in PMD and other plugins managed by
maven.

Unit tests simply verify we can load configuration as expected into the
Mojo.

Integration tests execute actual sample projects bound to the current
build's Maven plugin. This uses maven-invoker-plugin, which also allows
for specifying the maven options in invoker.properties to execute the test.
It also provides a verification framework using groovy files with the
required naming convention of "verify.groovy". This allows us to quickly
and easily check that certain files are outputted by generation, and we
may also spotcheck file contents.

templateResourcePath option is skipped on windows. I've tested back to
version 3.3.3 and this doesn't seem to have worked consistently with how
the property works on non-Windows.

* Set groovy 3.0.5 for test harness

* Print stacktrace on Maven error in Travis

* [maven] Set groovy version in tests to supported in Java 11+

* Puts maven integration tests in separate profile called 'integration'
2020-10-18 12:05:56 -04:00
Jim Schubert
150e24dc55
[maven] environmentVariables -> globalProperties (#7559) 2020-10-01 21:33:17 -04:00
Jim Schubert
7e5f720f20
Remove deprecations 5.0 (#6060)
* [breaking] Enforce vendor extension naming convention

* [breaking] Rename system properties to global properties

* [docs] Update site with global properties list and usage explanation

* Use proper vendor extension casing in all templates

* Set remaining vendor extensions to convention of lower kebab-cased with x- prefix

* [samples] Regenerate

* Update modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java

Before we were adding hasPathParams twice, once with !op.pathParams.isEmpty(), and then again with hasPathParams. This was probably caused by a mistaken merge.

This is causing the difference in samples

Co-authored-by: Richard Whitehouse <richard.whitehouse@metaswitch.com>

* [Samples] Regenerated!

* Fix -D conversion to additional-properties, missed in bat files

* JERSEY2 option changed

* [samples] Regenerate

* [scala][finch] Fix remaining vendor extensions format to conventino

* [scala] The -D option was replaced with --global-property

* [samples] Regenerate

* Fix -DskipFormModel usage which has been moved to --global-property skipFormModel=true

* [samples] Regenerate

Co-authored-by: Richard Whitehouse <richard.whitehouse@metaswitch.com>
2020-05-31 19:14:31 +08:00
Falko Modler
3f174d8a30
[maven] Introduce addTestCompileSourceRoot (#6120) 2020-05-09 14:32:54 -04:00
Falko Modler
84099eefdc
[maven] mark Mojo threadSafe=true + fix concurrency issue in Co… (#5898) 2020-04-18 20:40:09 -04:00
Jim Schubert
2957dd4d45
[cli] Add --global-property for -D replacement (#5687)
-D option has been deprecated as it was previously used to:

* Pass "system properties"
* Pass additional properties

This was confusing because we already have --additional-properties and
because Java System Properties are passed as -D before program
arguments.

Confusion around the -D option had existed for some time, but when we
introduced the thread-safe GlobalSettings to avoid overwriting Java
System Properties, we created a hard break from Java System Properties
in the generator. This also disconnected the previous "system
properties" from accepting additional properties.

Once these newly deprecated methods are removed, we will have a clear
separation of concerns between:

* Java System Properties
* Global generator properties (used as workflow context)
* Additional properties (used as generator options)

This commit marks multiple places for cleanup in 5.0. These will be
breaking changes, and lower effort to break in 5.0 with deprecation
warnings now rather than adding sibling properties throughout the code
and potentially introducing logic errors.
2020-04-02 11:11:02 +08:00
Peter Steiner
eecd8c056a
Java importmapping 3589 (#4350)
* type aliasing issue

* Add example OpenAPI document from issue 3589

https://github.com/OpenAPITools/openapi-generator/issues/3589

* Add test to reproduce the issue

- type of TypeAlias changed from 'string' to 'object'
  (not sure if importMapping is supposed also for 'string' types...)
- there might be better ways to write the test, it's kind of a brute
  force test (generate a file and parse it with a regexp)

* Remove duplicate test file

* Add new method override handleMethodResponse

Fixes broken unit test after merge from master

Co-authored-by: bkoziak <bkoziak@gmail.com>
Co-authored-by: William Cheng <wing328hk@gmail.com>
2020-02-13 22:05:53 +08:00
Jim Schubert
4602596df2
[maven]📝 Docs and minor refactoring (#5251)
The maven documentation was missing a few option, a couple of option
properties, and was inconsistent regarding selective generation for apis
an models. This adds properties and options where appropriate and
updates the docs. All options in the README have been reordered to match
property declaration order in CodegenMojo, hopefully making it easier
for maintainers to recognized when there are docs missing or out of
date.

This also slightly refactors the code in CodegenMojo to reduce the
cyclomatic complexity of the `execute` method.
2020-02-08 20:50:14 -05:00
Jim Schubert
507f80617d
[bug] Templates via classpath (#5164)
* Fixes issue with templates loading via classpath

The templating engines were originally written to load templates via the
classpath, but this functionality was blocked by file-only checks
further up the stack. This loosens those file-only checks, allowing
files and relatively imported files to be included via classpath.

* [docs] Add details about classpath-level templates

* [feat][maven] templateResourcePath for template on classpath
  - NOTE templateResourcePath is not needed for gradle, as it accepts
    a string for the target template directory, which supports classpath
2020-01-31 17:36:06 -05:00
Jim Schubert
c9ec084418
🐛 Fixing some issues with threading and NPE (#5107)
* 🐛 Fixing some issues with threading and NPE

After running Sonar on the master branch, some major analysis
opportunities were displayed.

This fixes the use of SimpleDateFormat stored as static fields.
SimpleDateFormat is not thread-safe, and may retain data across threads.
While there's no indicator that this has caused any issues (these are
mostly used for example code), we should follow these best practices.

This also fixes a handful of NPE and other minor issues such as
comparing Boolean.TRUE to strings and no wrapping some closeables in
try-with-resources.

* [cli] Unit test GenerateBatch custom deserialization helper

* Quiet batch mode in sonar.yml

* Suppress unnecessary warnings (ThreadLocals in static fields)
2020-01-25 18:28:16 -05:00
Jim Schubert
ea55968737
Evaluating https issues in CircleCI (on top of CiscoM31-maven-h… (#5034)
* replace http with https. Replace http://central.maven.org with https://repo1.maven.org

* replace http://www.apache.org/licenses/LICENSE-2.0 with https://www.apache.org/licenses/LICENSE-2.0

* Force HTTPS for mavenCentral gradle DSL

Co-authored-by: Sebastien Rosset <serosset@cisco.com>
2020-01-18 18:53:05 -05:00
Dec12 | Fujigon
dd152eefcc Following up for #3440 (1792 fix remote spec handling and hash calculation) (#3826)
* This patch fixes the bug that we cannot access to remote files when checking file updates.
Following up #3440, supporting auth.

* 1792 fix remote spec handling and hash calculation (#3440)

(cherry picked from commit 2a2eefe93d81b8d253745b8adb002ab2cb9eee04)

* fix detecting remote file / local file logic while finding the hash file, taking care of IllegalArgumentException for local files.

* add testcase
2019-09-06 16:48:42 +08:00
William Cheng
03edb64030 Revert "1792 fix remote spec handling and hash calculation (#3440)"
This reverts commit 2a2eefe93d81b8d253745b8adb002ab2cb9eee04.
2019-09-04 19:01:47 +08:00
Тумилович Павел
2a2eefe93d 1792 fix remote spec handling and hash calculation (#3440) 2019-09-04 16:24:08 +08:00
Quim Muntal
8f13b88ed9 Support custom git repository (#3757)
* add gitHost param to GeneratorSettings and related

* parameterize gitHost in READMEs

* parameterize gitHost in go.mod

* parameterize gitHost in git_push

* update petstore samples

* run ./bin/utils/export_docs_generators.sh

* run meta-codehen.sh

* Revert "run meta-codehen.sh"

This reverts commit d6d579f6159186531257cdfdd73b9caf9e9ffeba.

* Revert "run ./bin/utils/export_docs_generators.sh"

This reverts commit 1b81538198d4319fd1b4e97447303e3cc0e8dc99.

* Revert "update petstore samples"

This reverts commit f513add88396707f6991ae2e4920359583ec88f1.

* run ensure-up-to-date
2019-09-03 21:35:49 +08:00
Martin Hátaš
d36dd47b12 [maven-plugin] Allow to set User-Agent (#3777) 2019-08-28 10:17:41 +02:00
Jim Schubert
4b6499c636
[maven] Support user overrides for serverVariables (carryover from #3363) (#3609)
*  Adds server variables overrides option to the Maven plugin
2019-08-11 14:49:51 -04:00
Jim Schubert
06533b977c
[core][gradle] User-defined server variable substitutions (#3363)
* [core] Initial support for server variable overrides
* [gradle] Support user overrides for serverVariables
* [core] Clarify server variable overrides, and propagate them to templates in the "servers" array
2019-08-11 09:57:36 -04:00
wing328
7534df4520 Merge remote-tracking branch 'origin/master' into 4.1.x 2019-06-26 16:01:23 +08:00
Jim Schubert
a96ab1cf9d
[core] GeneratorSettings, WorkflowSettings, and cleanup in CodegenConfigurator (#2946)
* Introduce GeneratorSettings + cleanup

GeneratorSettings is an immutable settings object, intended to limit the
manipulation of generator settings.

To move to GeneratorSettings, lots of modification was done to
CodegenConfigurator. The goal  here is that CodegenConfigurator
would create the contextual information required to initiate a
generator run:

* GeneratorSettings
* Workflow related settings
* Configuring "system" GeneratorProperties (ThreadLocal properties)
* Deserializing from file to config object
* Input spec document (OpenAPI, intending to target others)

ClientOpts was generally unused, and the few places it was being used
have been updated to pass the properties to
codegen.additionalProperties.

* Add sanity to system properties

The -D argument for the generate command is an application argument
which is easily confused for Java System Properties. This isn't the
case, as setting values here doesn't update the configuration in
System.getProperties().

This adds a warning and deprecation to that option, as defining these
values as system properties will also continue to work as expected. This
makes the -D application argument redundant and confusing.

* Contextualize generator/workflow settings

This splits settings relevant to generator configuration (the what) and
workflow configuration (the how) in an attempt to make configuration
easier to conceptualize.

* Update Gradle task w/ CodegenConfigurator setters

* Remove -D usage in scripts

* Add -p option for additional properties

* Regnerate samples
2019-06-07 13:07:52 -04:00
Jérémie Bresson
ad06496887 [maven-plugin] fix strictSpec parameter without alias (#3095)
* Revert "[maven-plugin] fix strictSpec parameter (#3071)"

This reverts commit 8c9a1512ae824d35866375eb69ddd085309d0251.

* [maven-plugin] fix strictSpec parameter without alias
2019-06-05 08:21:51 -04:00
Jérémie Bresson
8c9a1512ae [maven-plugin] fix strictSpec parameter (#3071) 2019-06-03 22:43:19 +08:00
Deven Phillips
ddf21f0ca5 Resolves #2962 - Add properties config to Maven parameters (#2963)
* Resolves #2962 - Add properties config to Maven parameters

* Fixed formatting

* Fixed formatting

* Fix missing hyphen

* Added propery for `engine` parameter
2019-05-31 09:43:57 +08:00
azizamaan
91af76700e Engine param in maven plugin. (#2881) 2019-05-29 21:31:21 +08:00
Jim Schubert
a2fb88c1c1
[all] Adds strict spec option (#2783)
* [all] Adds strict spec option

Introduces an option to allow user customization of strict specification
behaviors. For instance, OpenAPI 3.x requires a path object name to be
prefixed with '/' so we append any missing '/', but this may not be
desirable to some users or generators. In this commit, this fix specifically is
the only modification affected.

* Clarify strict-spec docs, add option to README.md

* Update CLI options in docs/usage.md
2019-05-03 10:57:47 -04:00