mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-08 01:36:09 +00:00
Compare commits
1 Commits
v4.0.0-bet
...
duke_scrip
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
eb627dedfd |
117
.github/.test/auto-labeler.js
vendored
117
.github/.test/auto-labeler.js
vendored
@@ -1,117 +0,0 @@
|
||||
let fs = require('fs');
|
||||
let path = require('path');
|
||||
let util = require('util');
|
||||
let yaml = require('./js-yaml.js');
|
||||
let samples = require('./samples.json');
|
||||
|
||||
class LabelMatch {
|
||||
constructor (match, label) {
|
||||
this.match = match;
|
||||
this.label = label;
|
||||
}
|
||||
}
|
||||
|
||||
class FileError {
|
||||
constructor (file, actualLabels, expectedLabels) {
|
||||
this.file = file;
|
||||
this.actual = actualLabels;
|
||||
this.expected = expectedLabels;
|
||||
}
|
||||
}
|
||||
|
||||
class TextError {
|
||||
constructor (text, actualLabels, expectedLabels) {
|
||||
this.text = text;
|
||||
this.actual = actualLabels;
|
||||
this.expected = expectedLabels;
|
||||
}
|
||||
}
|
||||
|
||||
let labels = [];
|
||||
|
||||
function labelsForFile(file) {
|
||||
let body = fs.readFileSync(file);
|
||||
return labelsForText(body)
|
||||
}
|
||||
|
||||
function labelsForText(text) {
|
||||
let addLabels = new Set();
|
||||
let body = text;
|
||||
for (const v of labels) {
|
||||
if (v.match.test(body)) {
|
||||
addLabels.add(v.label)
|
||||
}
|
||||
// reset regex state
|
||||
v.match.lastIndex = 0
|
||||
}
|
||||
return addLabels;
|
||||
}
|
||||
|
||||
try {
|
||||
let config = yaml.safeLoad(fs.readFileSync('../auto-labeler.yml', 'utf8'));
|
||||
|
||||
if (config && config.labels && Object.keys(config.labels).length > 0) {
|
||||
for (const labelName in config.labels) {
|
||||
if (config.labels.hasOwnProperty(labelName)) {
|
||||
let matchAgainst = config.labels[labelName];
|
||||
if (Array.isArray(matchAgainst)) {
|
||||
matchAgainst.forEach(regex => {
|
||||
// noinspection JSCheckFunctionSignatures
|
||||
labels.push(new LabelMatch(new RegExp(regex, 'g'), labelName));
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (labels.length === 0) {
|
||||
// noinspection ExceptionCaughtLocallyJS
|
||||
throw new Error("Expected to parse config.labels, but failed.")
|
||||
}
|
||||
|
||||
let fileErrors = [];
|
||||
samples.files.forEach(function(tester){
|
||||
let file = path.normalize(path.join('..', '..', 'bin', tester.input));
|
||||
let expectedLabels = new Set(tester.matches);
|
||||
let actualLabels = labelsForFile(file);
|
||||
let difference = new Set([...actualLabels].filter(x => !expectedLabels.has(x)));
|
||||
if (difference.size > 0) {
|
||||
fileErrors.push(new FileError(file, actualLabels, expectedLabels));
|
||||
}
|
||||
});
|
||||
|
||||
let textErrors = [];
|
||||
samples.text.forEach(function(tester){
|
||||
let expectedLabels = new Set(tester.matches);
|
||||
let actualLabels = labelsForText(tester.input);
|
||||
let difference = new Set([...actualLabels].filter(x => !expectedLabels.has(x)));
|
||||
if (difference.size > 0) {
|
||||
textErrors.push(new TextError(tester.input, actualLabels, expectedLabels));
|
||||
}
|
||||
});
|
||||
|
||||
// These are separate (file vs text) in case we want to preview where these would fail in the file. not priority at the moment.
|
||||
if (fileErrors.length > 0) {
|
||||
console.warn('There were %d file tester errors', fileErrors.length);
|
||||
fileErrors.forEach(function(errs) {
|
||||
console.log("file: %j\n actual: %j\n expected: %j", errs.file, util.inspect(errs.actual), util.inspect(errs.expected))
|
||||
});
|
||||
}
|
||||
|
||||
if (textErrors.length > 0) {
|
||||
console.warn('There were %d text tester errors', textErrors.length);
|
||||
textErrors.forEach(function(errs){
|
||||
console.log("input: %j\n actual: %j\n expected: %j", errs.text, util.inspect(errs.actual), util.inspect(errs.expected))
|
||||
})
|
||||
}
|
||||
|
||||
let totalErrors = fileErrors.length + textErrors.length;
|
||||
if (totalErrors === 0) {
|
||||
console.log('Success!');
|
||||
} else {
|
||||
console.log('Failure: %d total errors', totalErrors);
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
|
||||
3917
.github/.test/js-yaml.js
vendored
3917
.github/.test/js-yaml.js
vendored
File diff suppressed because it is too large
Load Diff
1292
.github/.test/samples.json
vendored
1292
.github/.test/samples.json
vendored
File diff suppressed because it is too large
Load Diff
10
.github/ISSUE_TEMPLATE/announcement.md
vendored
10
.github/ISSUE_TEMPLATE/announcement.md
vendored
@@ -1,10 +0,0 @@
|
||||
---
|
||||
name: Announcement
|
||||
about: Announcements related to the project
|
||||
title: "[Announcement] TITLE"
|
||||
labels: Announcement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
|
||||
54
.github/ISSUE_TEMPLATE/bug_report.md
vendored
54
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -1,54 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a bug report to help us improve
|
||||
title: "[BUG] Description"
|
||||
labels: 'Issue: Bug'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
<!--
|
||||
Please follow the issue template below for bug reports.
|
||||
Also please indicate in the issue title which language/library is concerned. Eg: [BUG][JAVA] Bug generating foo with bar
|
||||
-->
|
||||
|
||||
##### Description
|
||||
|
||||
<!-- describe what is the question, suggestion or issue and why this is a problem for you. -->
|
||||
|
||||
##### openapi-generator version
|
||||
|
||||
<!-- which version of openapi-generator are you using, is it a regression? -->
|
||||
|
||||
##### OpenAPI declaration file content or url
|
||||
|
||||
<!-- if it is a bug, a json or yaml that produces it.
|
||||
If you post the code inline, please wrap it with
|
||||
```yaml
|
||||
(here your code)
|
||||
```
|
||||
(for YAML code) or
|
||||
```json
|
||||
(here your code)
|
||||
```
|
||||
(for JSON code), so it becomes more readable. If it is longer than about ten lines,
|
||||
please create a Gist (https://gist.github.com) or upload it somewhere else and
|
||||
link it here.
|
||||
-->
|
||||
|
||||
##### Command line used for generation
|
||||
|
||||
<!-- including the language, libraries and various options -->
|
||||
|
||||
##### Steps to reproduce
|
||||
|
||||
<!-- unambiguous set of steps to reproduce the bug.-->
|
||||
|
||||
##### Related issues/PRs
|
||||
|
||||
<!-- has a similar issue/PR been reported/opened before? Please do a search in https://github.com/openapitools/openapi-generator/issues?utf8=%E2%9C%93&q=is%3Aissue%20 -->
|
||||
|
||||
##### Suggest a fix
|
||||
|
||||
<!-- if you can't fix the bug yourself, perhaps you can point to what might be
|
||||
causing the problem (line of code or commit), or simply make a suggestion -->
|
||||
24
.github/ISSUE_TEMPLATE/feature_request.md
vendored
24
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@@ -1,24 +0,0 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: "[REQ] Feature Request Description"
|
||||
labels: 'Enhancement: Feature'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
### Is your feature request related to a problem? Please describe.
|
||||
|
||||
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
|
||||
|
||||
## Describe the solution you'd like
|
||||
|
||||
<!-- A clear and concise description of what you want to happen. -->
|
||||
|
||||
## Describe alternatives you've considered
|
||||
|
||||
<!-- A clear and concise description of any alternative solutions or features you've considered. -->
|
||||
|
||||
## Additional context
|
||||
|
||||
<!-- Add any other context or screenshots about the feature request here. -->
|
||||
290
.github/auto-labeler.yml
vendored
290
.github/auto-labeler.yml
vendored
@@ -1,290 +0,0 @@
|
||||
comment: |
|
||||
👍 Thanks for opening this issue!
|
||||
🏷 I have applied any labels matching special text in your issue.
|
||||
|
||||
The team will review the labels and make any necessary changes.
|
||||
labels:
|
||||
'Announcement':
|
||||
- '\s*?\[[Aa]nnouncement\]\s*?'
|
||||
'Breaking change (with fallback)':
|
||||
- '\s*?[bB]reaking [cC]hange [wW]ith [fF]allback\s*?'
|
||||
'Breaking change (without fallback)':
|
||||
- '\s*?[bB]reaking [cC]hange [wW]ithout [fF]allback\s*?'
|
||||
'Client: Ada':
|
||||
- '\s*?\[ada\]\s*?'
|
||||
- '\s*?-[gl] ada(?!-)\b'
|
||||
'Client: Android':
|
||||
- '\s*?\[android\]\s*?'
|
||||
- '\s*?-[gl] android(?!-)\b'
|
||||
'Client: Apex':
|
||||
- '\s*?\[apex\]\s*?'
|
||||
- '\s*?-[gl] apex(?!-)\b'
|
||||
'Client: Bash':
|
||||
- '\s*?\[bash\]\s*?'
|
||||
- '\s*?-[gl] bash(?!-)\b'
|
||||
'Client: C':
|
||||
- '\s*?\[[cC]\]\s*?'
|
||||
- '\s*?-[gl] c(?!-)\b'
|
||||
# 'Client: Ceylon':
|
||||
'Client: C++':
|
||||
- '\s*?\[cpp(-.*)?-client\]\s*?'
|
||||
- '\s*?-[gl] cpp(-.*)?-client\s*?'
|
||||
- '\s*?-[gl] cpp-restsdk(?!-)\b'
|
||||
- '\s*?-[gl] cpp-tizen(?!-)\b'
|
||||
'Client: C-Sharp':
|
||||
- '\s*?-[gl] csharp(?!-)\b'
|
||||
- '\s*?[cC]-[sS]harp [cC]lient\s*?'
|
||||
- '\s*?-[gl] csharp-dotnet2\s*?'
|
||||
- '\s*?-[gl] csharp-refactor?\s*?'
|
||||
- '\s*?\[[Cc]#\]'
|
||||
- '\s*?\[csharp\]\s*?'
|
||||
'Client: Clojure':
|
||||
- '\s*?\[clojure\]\s*?'
|
||||
- '\s*?-[gl] clojure(?!-)\b'
|
||||
# 'Client: Crystal':
|
||||
'Client: Dart':
|
||||
- '\s*?\[dart\]\s*?'
|
||||
- '\s*?-[gl] dart(?!-)\b'
|
||||
'Client: Dukescript':
|
||||
- '\s*?\[dukescript\]\s*?'
|
||||
- '\s*?-g dukescript\s*?'
|
||||
'Client: Eiffel':
|
||||
- '\s*?\[eiffel\]\s*?'
|
||||
- '\s*?-[gl] eiffel(?!-)\b'
|
||||
'Client: Elixir':
|
||||
- '\s*?\[elixir\]\s*?'
|
||||
- '\s*?-[gl] elixir(?!-)\b'
|
||||
'Client: Elm':
|
||||
- '\s*?\[elm\]\s*?'
|
||||
- '\s*?-[gl] elm(?!-)\b'
|
||||
'Client: Erlang':
|
||||
- '\s*?\[erlang(-.*)?-client\]\s*?'
|
||||
- '\s*?-[gl] erlang(-.*)?-client\s*?'
|
||||
- '\s*?\[erlang-proper\]\s*?'
|
||||
- '\s*?-[gl] erlang-proper\s*?'
|
||||
'Client: Flash/ActionScript':
|
||||
- '\s*?\[flash\]\s*?'
|
||||
- '\s*?-[gl] flash(?!-)\b'
|
||||
'Client: Go':
|
||||
- '\s*?\[go\]\s*?'
|
||||
- '\s*?-[gl] go(?!-)\b'
|
||||
'Client: Groovy':
|
||||
- '\s*?\[groovy\]\s*?'
|
||||
- '\s*?-[gl] groovy(?!-)\b'
|
||||
'Client: HTML':
|
||||
- '\s*?\[html[2]?\]\s*?'
|
||||
- '\s*?-[gl] html[2]?\s*?'
|
||||
'Client: Haskell':
|
||||
- '\s*?\[haskell(-.*)?-client\]\s*?'
|
||||
- '\s*?-[gl] haskell(-.*)?-client\s*?'
|
||||
'Client: JMeter':
|
||||
- '\s*?\[jmeter\]\s*?'
|
||||
- '\s*?-[gl] jmeter\s*?'
|
||||
'Client: Java':
|
||||
- '\s*?\[java\]\s*?'
|
||||
- '\s*?-[gl] java(?!-)\b'
|
||||
'Client: JavaScript/Node.js':
|
||||
- '\s*?\[javascript\]\s*?'
|
||||
- '\s*?-[gl] javascript\s*?'
|
||||
- '\s*?-[gl] javascript-(\S)*\s*?'
|
||||
# 'Client: Julia': # NOTE: Not yet implemented
|
||||
'Client: Kotlin':
|
||||
- '\s*?\[kotlin\]\s*?'
|
||||
- '\s*?-[gl] kotlin(?!-)\b'
|
||||
'Client: Lisp':
|
||||
- '\s*?\[lisp\]\s*?'
|
||||
- '\s*?-[gl] lisp(?!-)\b'
|
||||
'Client: Lua':
|
||||
- '\s*?\[lua\]\s*?'
|
||||
- '\s*?-[gl] lua(?!-)\b'
|
||||
'Client: Objc':
|
||||
- '\s*?\[objc\]\s*?'
|
||||
- '\s*?-[gl] objc\s*?'
|
||||
# 'Client: OCaml':
|
||||
'Client: Perl':
|
||||
- '\s*?\[perl\]\s*?'
|
||||
- '\s*?-[gl] perl(?!-)\b'
|
||||
# 'Client: PHP':
|
||||
'Client: PowerShell':
|
||||
- '\s*?\[powershell\]\s*?'
|
||||
- '\s*?-[gl] powershell\s*?'
|
||||
'Client: Python':
|
||||
- '\s*?\[python\]\s*?'
|
||||
- '\s*?-[gl] python(?!-)\b'
|
||||
'Client: QT':
|
||||
- '\s*?\[cpp-qt5-client\]\s*?'
|
||||
- '\s*?-[gl] cpp-qt5-client\s*?'
|
||||
'Client: R':
|
||||
- '\s*?\[[rR]\]\s*?'
|
||||
- '\s*?-[gl] r(?!-)\b'
|
||||
'Client: Reason ML':
|
||||
- '\s*?\[reasonml\]\s*?'
|
||||
- '\s*?-[g] reasonml\s*?'
|
||||
'Client: Retrofit':
|
||||
- '\s*?retrofit.*?\s*?'
|
||||
'Client: Ruby':
|
||||
- '\s*?\[ruby\]\s*?'
|
||||
- '\s*?-[gl] ruby(?!-)\b'
|
||||
'Client: Rust':
|
||||
- '\s*?\[rust\]\s*?'
|
||||
- '\s*?-[gl] rust(?!-)\b'
|
||||
'Client: Scala':
|
||||
- '\s*?\[scalaz\]\s*?'
|
||||
- '\s*?-[gl] scalaz\s*?'
|
||||
- '\s*?\[scala-(?!finch)[a-z]+\]\b'
|
||||
- '\s*?-[gl] scala-(?!finch)[a-z]+?(?!-)\b'
|
||||
'Client: Swift':
|
||||
- '\s*?\[swift[34]+\]\s*?'
|
||||
- '\s*?-[gl] swift[34]+\s*?'
|
||||
- '\s*?-[gl] swift2-deprecated\s*?'
|
||||
'Client: TypeScript':
|
||||
- '\s*?\[typescript-[\-a-z]+\]\s*?'
|
||||
- '\s*?-[gl] typescript-[\-a-z]+\s*?'
|
||||
# 'Client: VB/VB.net': # NOTE: Not yet implemented
|
||||
# 'Client: Visual Basic': # TODO: REMOVE UNUSED LABEL
|
||||
'Config: Apache':
|
||||
- '\s*?\[apache2\]\s*?'
|
||||
- '\s*?-[gl] apache2\s*?'
|
||||
'Docker':
|
||||
- '\s*?\[docker\]\s*?'
|
||||
'Documentation: Cwiki':
|
||||
- '\s*?\[cwiki\]\s*?'
|
||||
- '\s*?-[gl] cwiki\s*?'
|
||||
'Documentation: Dynamic HTML':
|
||||
- '\s*?\[dynamic-html\]\s*?'
|
||||
- '\s*?-[gl] dynamic-html\s*?'
|
||||
'Enhancement: CI/Test':
|
||||
- '\s*?\[ci\]\s*?'
|
||||
'Enhancement: Code format':
|
||||
- '\s*?\[format(ting)?\]\s*?'
|
||||
# 'Enhancement: Compatibility':
|
||||
'Enhancement: Feature':
|
||||
- '\s*?\[feat(ure)?s*?'
|
||||
'Enhancement: General':
|
||||
- '\s*?\[general\]\s*?'
|
||||
- '\s*?\[core\]\s*?'
|
||||
# 'Enhancement: New generator':
|
||||
'Enhancement: Performance':
|
||||
- '\s*?\[perf\]\s*?'
|
||||
# 'Feature List: API clients':
|
||||
# 'Feature List: API documentations':
|
||||
# 'Feature List: API servers':
|
||||
# 'Feature: Authentication':
|
||||
# 'Feature: Composition / Inheritance':
|
||||
# 'Feature: Documentation':
|
||||
# 'Feature: Enum':
|
||||
# 'Feature: Generator':
|
||||
'Feature: OAS 3.0 spec support':
|
||||
- '\s*?\[oas3[\.0]?\]\s*?'
|
||||
# 'General: Awaiting feedback':
|
||||
'General: Discussion':
|
||||
- '\s*?\[discussion\]\s*?'
|
||||
'General: Question':
|
||||
- '\s*?\[question\]\s*?'
|
||||
'General: Suggestion':
|
||||
- '\s*?\[suggestion\]\s*?'
|
||||
'General: Support':
|
||||
- '\s*?\[support\]\s*?'
|
||||
'Issue: Bug':
|
||||
- '\s*?\[bug(s)?\]\s*?'
|
||||
- '\s*?\[fix(es)?\]\s*?'
|
||||
# 'Issue: Invalid spec':
|
||||
# 'Issue: Migration':
|
||||
# 'Issue: Non-operational':
|
||||
# 'Issue: Platform':
|
||||
# 'Issue: Regression':
|
||||
'Issue: Security':
|
||||
- '\s*?\[security\]\s*?'
|
||||
# 'Issue: Unable to reproduce':
|
||||
# 'Issue: Undo changes':
|
||||
# 'Issue: Usage/Installation':
|
||||
# 'Issue: Workaround available':
|
||||
'OpenAPI Generator CLI':
|
||||
- '\s*?\[cli\]\s*?'
|
||||
'OpenAPI Generator Gradle Plugin':
|
||||
- '\s*?\[gradle\]\s*?'
|
||||
'OpenAPI Generator Maven Plugin':
|
||||
- '\s*?\[maven\]\s*?'
|
||||
'OpenAPI Generator Online':
|
||||
- '\s*?\[online\]\s*?'
|
||||
'Schema: MySQL':
|
||||
- '\s*?\[mysql\]\s*?'
|
||||
- '\s*?-[gl] mysql\s*?'
|
||||
'Schema: GraphQL':
|
||||
- '\s*?\[graphql-schema\]\s*?'
|
||||
- '\s*?-[gl] graphql-schema\s*?'
|
||||
'Server: Ada':
|
||||
- '\s*?\[ada(-.*)?-server\]\s*?'
|
||||
- '\s*?-[gl] ada(-.*)?-server\s*?'
|
||||
'Server: C++':
|
||||
- '\s*?\[cpp(-.*)?-server\]\s*?'
|
||||
- '\s*?-[gl] cpp(-.*)?-server\s*?'
|
||||
'Server: C-Sharp':
|
||||
- '\s*?\[aspnetcore\]\s*?'
|
||||
- '\s*?-[gl] aspnetcore\s*?'
|
||||
- '\s*?\[csharp-nancyfx\]\s*?'
|
||||
- '\s*?-[gl] csharp-nancyfx\s*?'
|
||||
# 'Server: Ceylon': # TODO: REMOVE UNUSED LABEL
|
||||
'Server: Eiffel':
|
||||
- '\s*?\[eiffel(-.*)?-server\]\s*?'
|
||||
- '\s*?-[gl] eiffel(-.*)?-server\s*?'
|
||||
'Server: Elixir':
|
||||
- '\s*?\[elixir(-.*)?-server\]\s*?'
|
||||
- '\s*?-[gl] elixir(-.*)?-server\s*?'
|
||||
'Server: Erlang':
|
||||
- '\s*?\[erlang-server\]\s*?'
|
||||
- '\s*?-[gl] erlang-server\s*?'
|
||||
'Server: Go':
|
||||
- '\s*?\[go(-.*)?-server\]\s*?'
|
||||
- '\s*?-[gl] go(-.*)?-server\s*?'
|
||||
'Server: GraphQL':
|
||||
- '\s*?\[graphql(-.*)?-server\]\s*?'
|
||||
- '\s*?-[gl] graphql(-.*)?-server\s*?'
|
||||
'Server: Haskell':
|
||||
- '\s*?\[haskell]\s*?'
|
||||
- '\s*?-[gl] haskell(?!-)\b'
|
||||
'Server: Java':
|
||||
- '\s*?\[java-.*?\]\s*?'
|
||||
- '\s*?-[gl] java-.*?\s*?'
|
||||
- '\s*?-[gl] jaxrx-.*?\s*?'
|
||||
'Server: Kotlin':
|
||||
- '\s*?\[ktor]\s*?'
|
||||
- '\s*?\[kotlin-spring]\s*?'
|
||||
- '\s*?\[kotlin(-.*)?-server\]\s*?'
|
||||
- '\s*?-[gl] kotlin(-.*)?-server\s*?'
|
||||
- '\s*?-[gl] kotlin-spring\s*?'
|
||||
'Server: Nodejs':
|
||||
- '\s*?\[nodejs(-.*)?-server\]\s*?'
|
||||
- '\s*?-[gl] nodejs(-.*)?-server\s*?'
|
||||
'Server: PHP':
|
||||
- '\s*?\[php-.*?\]\s*?'
|
||||
- '\s*?-[gl] php-.*?\s*?'
|
||||
'Server: Perl':
|
||||
- '\s*?\[perl(-.*)?-server\]\s*?'
|
||||
- '\s*?-g perl(-.*)?-server\s*?'
|
||||
'Server: Python':
|
||||
- '\s*?\[python-.*?\]\s*?'
|
||||
- '\s*?-[gl] python-.*?\s*?'
|
||||
'Server: Ruby':
|
||||
- '\s*?\[ruby-.*?\]\s*?'
|
||||
- '\s*?-[gl] ruby-.*?\s*?'
|
||||
'Server: Rust':
|
||||
- '\s*?\[rust(-.*)?-server\]\s*?'
|
||||
- '\s*?-[gl] rust(-.*)?-server\s*?'
|
||||
'Server: Scala':
|
||||
- '\s*?\[scala(-.*)?-server\]\s*?'
|
||||
- '\s*?-[gl] scala(-.*)?-server\s*?'
|
||||
- '\s*?\[scalatra\]\s*?'
|
||||
- '\s*?-[gl] scalatra\s*?'
|
||||
- '\s*?\[scala-finch\]\s*?'
|
||||
- '\s*?-[gl] scala-finch\s*?'
|
||||
'Server: Spring':
|
||||
- '\s*?\[spring\]\s*?'
|
||||
- '\s*?-[g] spring\s*?'
|
||||
# 'Swagger-Parser':
|
||||
'WIP':
|
||||
- '\s*?\[wip\]\s*?'
|
||||
- '\s*?\[WIP\]\s*?'
|
||||
- '\bWIP:.*?'
|
||||
'help wanted':
|
||||
- '\s*?\[help wanted\]\s*?'
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -146,8 +146,6 @@ samples/client/petstore/csharp/SwaggerClient/bin/Debug/
|
||||
samples/client/petstore/csharp/SwaggerClient/packages
|
||||
samples/client/petstore/csharp/SwaggerClient/TestResult.xml
|
||||
samples/client/petstore/csharp/SwaggerClientWithPropertyChanged/IO.Swagger.userprefs
|
||||
samples/client/petstore/csharp-refactor/OpenAPIClient/TestResult.xml
|
||||
samples/client/petstore/csharp-refactor/OpenAPIClient/nuget.exe
|
||||
|
||||
# Python
|
||||
*.pyc
|
||||
@@ -180,7 +178,6 @@ samples/client/petstore/kotlin/src/main/kotlin/test/
|
||||
samples/client/petstore/kotlin-threetenbp/build
|
||||
samples/client/petstore/kotlin-string/build
|
||||
samples/server/petstore/kotlin-server/ktor/build
|
||||
samples/openapi3/client/petstore/kotlin/build
|
||||
\?
|
||||
|
||||
# haskell
|
||||
@@ -205,8 +202,6 @@ samples/client/petstore/groovy/build
|
||||
# erlang
|
||||
samples/client/petstore/erlang-client/_build/
|
||||
samples/client/petstore/erlang-client/rebar.lock
|
||||
samples/client/petstore/erlang-proper/_build/
|
||||
samples/client/petstore/erlang-proper/rebar.lock
|
||||
samples/server/petstore/erlang-server/_build/
|
||||
samples/server/petstore/erlang-server/rebar.lock
|
||||
|
||||
|
||||
@@ -97,7 +97,7 @@ before_install:
|
||||
- cat /etc/hosts
|
||||
# show java version
|
||||
- java -version
|
||||
- if [ "$TRAVIS_BRANCH" = "4.0.0-beta" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
||||
- if [ "$TRAVIS_BRANCH" = "master" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
||||
openssl aes-256-cbc -K $encrypted_6e2c8bba47c6_key -iv $encrypted_6e2c8bba47c6_iv -in sec.gpg.enc -out sec.gpg -d ;
|
||||
gpg --keyserver keyserver.ubuntu.com --recv-key $SIGNING_KEY ;
|
||||
gpg --check-trustdb ;
|
||||
@@ -130,7 +130,7 @@ script:
|
||||
after_success:
|
||||
# push to maven repo
|
||||
- if [ $SONATYPE_USERNAME ] && [ -z $TRAVIS_TAG ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
|
||||
if [ "$TRAVIS_BRANCH" = "4.0.0-beta" ]; then
|
||||
if [ "$TRAVIS_BRANCH" = "master" ]; then
|
||||
mvn clean deploy -DskipTests=true -B -U -P release --settings CI/settings.xml;
|
||||
echo "Finished mvn clean deploy for $TRAVIS_BRANCH";
|
||||
pushd .;
|
||||
@@ -149,9 +149,9 @@ after_success:
|
||||
fi;
|
||||
fi;
|
||||
## docker: build and push openapi-generator-online to DockerHub
|
||||
- if [ $DOCKER_HUB_USERNAME ]; then echo "$DOCKER_HUB_PASSWORD" | docker login --username=$DOCKER_HUB_USERNAME --password-stdin && docker build -t $DOCKER_GENERATOR_IMAGE_NAME ./modules/openapi-generator-online && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_GENERATOR_IMAGE_NAME:latest $DOCKER_GENERATOR_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "4.0.0-beta" ]; then docker push $DOCKER_GENERATOR_IMAGE_NAME && echo "Pushed to $DOCKER_GENERATOR_IMAGE_NAME"; fi; fi
|
||||
- if [ $DOCKER_HUB_USERNAME ]; then echo "$DOCKER_HUB_PASSWORD" | docker login --username=$DOCKER_HUB_USERNAME --password-stdin && docker build -t $DOCKER_GENERATOR_IMAGE_NAME ./modules/openapi-generator-online && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_GENERATOR_IMAGE_NAME:latest $DOCKER_GENERATOR_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_GENERATOR_IMAGE_NAME && echo "Pushed to $DOCKER_GENERATOR_IMAGE_NAME"; fi; fi
|
||||
## docker: build cli image and push to Docker Hub
|
||||
- if [ $DOCKER_HUB_USERNAME ]; then echo "$DOCKER_HUB_PASSWORD" | docker login --username=$DOCKER_HUB_USERNAME --password-stdin && cp docker-entrypoint.sh ./modules/openapi-generator-cli && docker build -t $DOCKER_CODEGEN_CLI_IMAGE_NAME ./modules/openapi-generator-cli && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest $DOCKER_CODEGEN_CLI_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "4.0.0-beta" ]; then docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME && echo "Pushed to $DOCKER_CODEGEN_CLI_IMAGE_NAME"; fi; fi
|
||||
- if [ $DOCKER_HUB_USERNAME ]; then echo "$DOCKER_HUB_PASSWORD" | docker login --username=$DOCKER_HUB_USERNAME --password-stdin && cp docker-entrypoint.sh ./modules/openapi-generator-cli && docker build -t $DOCKER_CODEGEN_CLI_IMAGE_NAME ./modules/openapi-generator-cli && if [ ! -z "$TRAVIS_TAG" ]; then docker tag $DOCKER_CODEGEN_CLI_IMAGE_NAME:latest $DOCKER_CODEGEN_CLI_IMAGE_NAME:$TRAVIS_TAG; fi && if [ ! -z "$TRAVIS_TAG" ] || [ "$TRAVIS_BRANCH" = "master" ]; then docker push $DOCKER_CODEGEN_CLI_IMAGE_NAME && echo "Pushed to $DOCKER_CODEGEN_CLI_IMAGE_NAME"; fi; fi
|
||||
|
||||
env:
|
||||
- DOCKER_GENERATOR_IMAGE_NAME=openapitools/openapi-generator-online DOCKER_CODEGEN_CLI_IMAGE_NAME=openapitools/openapi-generator-cli NODE_ENV=test CC=gcc-5 CXX=g++-5
|
||||
|
||||
@@ -15,7 +15,7 @@ elif [ "$NODE_INDEX" = "2" ]; then
|
||||
java -version
|
||||
#export GO_POST_PROCESS_FILE="/usr/local/bin/gofmt -w"
|
||||
# not formatting the code as different go versions may format the code a bit different
|
||||
#./bin/utils/ensure-up-to-date
|
||||
./bin/utils/ensure-up-to-date
|
||||
else
|
||||
echo "Running node $NODE_INDEX to test 'samples.circleci.jdk7' defined in pom.xml ..."
|
||||
sudo update-java-alternatives -s java-1.7.0-openjdk-amd64
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
OpenAPI Petstore
|
||||
|
||||
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
|
||||
OpenAPI spec version: 1.0.0
|
||||
|
||||
-->
|
||||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{19F1DEBC-DE5E-4517-8062-F000CD499087}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Org.OpenAPITools.Test</RootNamespace>
|
||||
<AssemblyName>Org.OpenAPITools.Test</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\packages')">..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\Newtonsoft.Json.12.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="JsonSubTypes">
|
||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\JsonSubTypes.1.5.1\lib\net45\JsonSubTypes.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\packages')">..\packages\JsonSubTypes.1.5.1\lib\net45\JsonSubTypes.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\JsonSubTypes.1.5.1\lib\net45\JsonSubTypes.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\JsonSubTypes.1.5.1\lib\net45\JsonSubTypes.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="RestSharp">
|
||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\RestSharp.106.5.4\lib\net452\RestSharp.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\packages')">..\packages\RestSharp.106.5.4\lib\net452\RestSharp.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\RestSharp.106.5.4\lib\net452\RestSharp.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\RestSharp.106.5.4\lib\net452\RestSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="nunit.framework">
|
||||
<HintPath Condition="Exists('$(SolutionDir)\packages')">$(SolutionDir)\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\packages')">..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\packages')">..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
|
||||
<HintPath Condition="Exists('..\..\vendor')">..\..\vendor\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="**\*.cs" Exclude="obj\**" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MsBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Org.OpenAPITools\Org.OpenAPITools.csproj">
|
||||
<Project>{321C8C3F-0156-40C1-AE42-D59761FB9B6C}</Project>
|
||||
<Name>Org.OpenAPITools</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="linux-logo.png" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package org.openapitools.client.model;
|
||||
|
||||
import org.apache.commons.lang3.builder.EqualsBuilder;
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Model tests for ArrayOfArrayOfNumberOnly
|
||||
*/
|
||||
public class ArrayOfArrayOfNumberOnlyTest {
|
||||
private final ArrayOfArrayOfNumberOnly model = new ArrayOfArrayOfNumberOnly();
|
||||
|
||||
/**
|
||||
* Model tests for ArrayOfArrayOfNumberOnly
|
||||
*/
|
||||
@Test
|
||||
public void test() {
|
||||
// TODO: test ArrayOfArrayOfNumberOnly
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'arrayArrayNumber'
|
||||
*/
|
||||
@Test
|
||||
public void arrayArrayNumberTest() {
|
||||
BigDecimal b1 = new BigDecimal("12.3");
|
||||
BigDecimal b2 = new BigDecimal("5.6");
|
||||
List<BigDecimal> arrayArrayNumber = new ArrayList<BigDecimal>();
|
||||
arrayArrayNumber.add(b1);
|
||||
arrayArrayNumber.add(b2);
|
||||
model.getArrayArrayNumber().add(arrayArrayNumber);
|
||||
|
||||
// create another instance for comparison
|
||||
BigDecimal b3 = new BigDecimal("12.3");
|
||||
BigDecimal b4 = new BigDecimal("5.6");
|
||||
ArrayOfArrayOfNumberOnly model2 = new ArrayOfArrayOfNumberOnly();
|
||||
List<BigDecimal> arrayArrayNumber2 = new ArrayList<BigDecimal>();
|
||||
arrayArrayNumber2.add(b1);
|
||||
arrayArrayNumber2.add(b2);
|
||||
model2.getArrayArrayNumber().add(arrayArrayNumber2);
|
||||
|
||||
Assert.assertTrue(model2.equals(model));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,103 +0,0 @@
|
||||
/*
|
||||
* OpenAPI Petstore
|
||||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
package org.openapitools.client.model;
|
||||
|
||||
import com.google.gson.TypeAdapter;
|
||||
import com.google.gson.annotations.JsonAdapter;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.openapitools.client.model.Category;
|
||||
import org.openapitools.client.model.Tag;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
/**
|
||||
* Model tests for Pet
|
||||
*/
|
||||
public class PetTest {
|
||||
private final Pet model = new Pet();
|
||||
|
||||
/**
|
||||
* Model tests for Pet
|
||||
*/
|
||||
@Test
|
||||
public void testPet() {
|
||||
// test Pet
|
||||
model.setId(1029L);
|
||||
model.setName("Dog");
|
||||
|
||||
Pet model2 = new Pet();
|
||||
model2.setId(1029L);
|
||||
model2.setName("Dog");
|
||||
|
||||
Assert.assertTrue(model.equals(model2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'id'
|
||||
*/
|
||||
@Test
|
||||
public void idTest() {
|
||||
// TODO: test id
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'category'
|
||||
*/
|
||||
@Test
|
||||
public void categoryTest() {
|
||||
// TODO: test category
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'name'
|
||||
*/
|
||||
@Test
|
||||
public void nameTest() {
|
||||
// TODO: test name
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'photoUrls'
|
||||
*/
|
||||
@Test
|
||||
public void photoUrlsTest() {
|
||||
// TODO: test photoUrls
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'tags'
|
||||
*/
|
||||
@Test
|
||||
public void tagsTest() {
|
||||
// TODO: test tags
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the property 'status'
|
||||
*/
|
||||
@Test
|
||||
public void statusTest() {
|
||||
// TODO: test status
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
:notebook_with_decorative_cover: The eBook [A Beginner's Guide to Code Generation for REST APIs](https://gumroad.com/l/swagger_codegen_beginner) is a good starting point for beginners :notebook_with_decorative_cover:
|
||||
|
||||
:warning: If the OpenAPI spec, templates or any input (e.g. options, environment variables) is obtained from an untrusted source or environment, please make sure you've reviewed these inputs before using OpenAPI Generator to generate the API client, server stub or documentation to avoid potential security issues (e.g. [code injection](https://en.wikipedia.org/wiki/Code_injection)) :warning:
|
||||
:warning: If the OpenAPI spec, templates or any input (e.g. options, envirionment variables) is obtained from an untrusted source or environment, please make sure you've reviewed these inputs before using OpenAPI Generator to generate the API client, server stub or documentation to avoid potential security issues (e.g. [code injection](https://en.wikipedia.org/wiki/Code_injection)) :warning:
|
||||
|
||||
:bangbang: Both "OpenAPI Tools" (https://OpenAPITools.org - the parent organization of OpenAPI Generator) and "OpenAPI Generator" are not affiliated with OpenAPI Initiative (OAI) :bangbang:
|
||||
|
||||
@@ -425,6 +425,7 @@ SYNOPSIS
|
||||
[--import-mappings <import mappings>...]
|
||||
[--instantiation-types <instantiation types>...]
|
||||
[--invoker-package <invoker package>]
|
||||
[(-l <language> | --lang <language>)]
|
||||
[--language-specific-primitives <language specific primitives>...]
|
||||
[--library <library>] [--log-to-stderr]
|
||||
[--model-name-prefix <model name prefix>]
|
||||
@@ -500,19 +501,16 @@ When code is generated from this project, it shall be considered **AS IS** and o
|
||||
Here are some companies/projects (alphabetical order) using OpenAPI Generator in production. To add your company/project to the list, please visit [README.md](README.md) and click on the icon to edit the page.
|
||||
|
||||
- [Angular.Schule](https://angular.schule/)
|
||||
- [ASKUL](https://www.askul.co.jp)
|
||||
- [b<>com](https://b-com.com/en)
|
||||
- [Bithost GmbH](https://www.bithost.ch)
|
||||
- [Boxever](https://www.boxever.com/)
|
||||
- [GMO Pepabo](https://pepabo.com/en/)
|
||||
- [JustStar](https://www.juststarinfo.com)
|
||||
- [Klarna](https://www.klarna.com/)
|
||||
- [Metaswitch](https://www.metaswitch.com/)
|
||||
- [Myworkout](https://myworkout.com)
|
||||
- [Raiffeisen Schweiz Genossenschaft](https://www.raiffeisen.ch)
|
||||
- [RepreZen API Studio](https://www.reprezen.com/swagger-openapi-code-generation-api-first-microservices-enterprise-development)
|
||||
- [REST United](https://restunited.com)
|
||||
- [Stingray](http://www.stingray.com)
|
||||
- [Suva](https://www.suva.ch/)
|
||||
- [Telstra](https://dev.telstra.com)
|
||||
- [TUI InfoTec GmbH](http://www.tui-infotec.com/)
|
||||
|
||||
@@ -23,9 +23,6 @@ install:
|
||||
- git clone https://github.com/wing328/swagger-samples
|
||||
- ps: Start-Process -FilePath 'C:\maven\apache-maven-3.2.5\bin\mvn' -ArgumentList 'jetty:run' -WorkingDirectory "$env:appveyor_build_folder\swagger-samples\java\java-jersey-jaxrs-ci"
|
||||
build_script:
|
||||
# build C# API client (refactor)
|
||||
- nuget restore samples\client\petstore\csharp-refactor\OpenAPIClient\Org.OpenAPITools.sln
|
||||
- msbuild samples\client\petstore\csharp-refactor\OpenAPIClient\Org.OpenAPITools.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||
# build C# API client
|
||||
- nuget restore samples\client\petstore\csharp\OpenAPIClient\Org.OpenAPITools.sln
|
||||
- msbuild samples\client\petstore\csharp\OpenAPIClient\Org.OpenAPITools.sln /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||
@@ -40,8 +37,6 @@ build_script:
|
||||
test_script:
|
||||
# restore test-related files
|
||||
- copy /b/v/y CI\samples.ci\client\petstore\csharp\OpenAPIClient\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj samples\client\petstore\csharp\OpenAPIClient\src\Org.OpenAPITools.Test\Org.OpenAPITools.Test.csproj
|
||||
# test c# API client (refactor)
|
||||
- nunit-console samples\client\petstore\csharp-refactor\OpenAPIClient\src\Org.OpenAPITools.Test\bin\Debug\Org.OpenAPITools.Test.dll --result=myresults.xml;format=AppVeyor
|
||||
# test c# API client
|
||||
- nunit-console samples\client\petstore\csharp\OpenAPIClient\src\Org.OpenAPITools.Test\bin\Debug\Org.OpenAPITools.Test.dll --result=myresults.xml;format=AppVeyor
|
||||
# test c# API client (with PropertyChanged)
|
||||
|
||||
@@ -27,11 +27,11 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/csharp-refactor/ -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g csharp-refactor -o samples/client/petstore/csharp-refactor/OpenAPIClient --additional-properties packageGuid={321C8C3F-0156-40C1-AE42-D59761FB9B6C},useCompareNetObjects=true $@"
|
||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore-with-fake-endpoints-models-for-testing.yaml -g csharp-refactor -o samples/client/petstore/csharp-refactor/OpenAPIClient --additional-properties packageGuid={321C8C3F-0156-40C1-AE42-D59761FB9B6C} $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
# restore csproj file
|
||||
echo "restore csproject file: CI/samples/client/petstore/csharp-refactor/OpenAPIClient/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj"
|
||||
cp ./CI/samples.ci/client/petstore/csharp-refactor/OpenAPIClient/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj ./samples/client/petstore/csharp-refactor/OpenAPIClient/src/Org.OpenAPITools.Test/
|
||||
#echo "restore csproject file: CI/samples/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj"
|
||||
#cp ./CI/samples.ci/client/petstore/csharp/OpenAPIClient/src/Org.OpenAPITools.Test/Org.OpenAPITools.Test.csproj ./samples/client/petstore/csharp-refactor/OpenAPIClient/src/Org.OpenAPITools.Test/
|
||||
|
||||
|
||||
@@ -28,11 +28,11 @@ fi
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
|
||||
# Generate client
|
||||
ags="$@ generate -t modules/openapi-generator/src/main/resources/dart-jaguar -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart-jaguar -o samples/client/petstore/dart-jaguar/openapi -DhideGenerationTimestamp=true -DpubName=openapi"
|
||||
ags="$@ generate -t modules/openapi-generator/src/main/resources/dart-jaguar -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -l dart-jaguar -o samples/client/petstore/dart-jaguar/openapi -DhideGenerationTimestamp=true -DpubName=openapi"
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
# Generate non-browserClient and put it to the flutter sample app
|
||||
ags="$@ generate -t modules/openapi-generator/src/main/resources/dart-jaguar -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dart-jaguar -o samples/client/petstore/dart-jaguar/flutter_petstore/openapi -DhideGenerationTimestamp=true -DpubName=openapi"
|
||||
ags="$@ generate -t modules/openapi-generator/src/main/resources/dart-jaguar -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -l dart-jaguar -o samples/client/petstore/dart-jaguar/flutter_petstore/openapi -DhideGenerationTimestamp=true -DpubName=openapi"
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
# There is a proposal to allow importing different libraries depending on the environment:
|
||||
|
||||
32
bin/dukescript-petstore.sh
Normal file
32
bin/dukescript-petstore.sh
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/dukescript -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g dukescript -o samples/client/petstore/dukescript $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -44,6 +44,4 @@ cp CI/samples.ci/client/petstore/java/test-manual/common/ConfigurationTest.java
|
||||
cp CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/auth/ApiKeyAuthTest.java samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/auth/ApiKeyAuthTest.java
|
||||
cp CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/auth/HttpBasicAuthTest.java samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/auth/HttpBasicAuthTest.java
|
||||
cp CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/model/EnumValueTest.java samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/model/EnumValueTest.java
|
||||
cp CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/model/PetTest.java samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/model/PetTest.java
|
||||
cp CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/model/ArrayOfArrayOfNumberOnly.java samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/model/ArrayOfArrayOfNumberOnlyTest.java
|
||||
cp CI/samples.ci/client/petstore/java/test-manual/okhttp-gson/JSONTest.java samples/client/petstore/java/okhttp-gson/src/test/java/org/openapitools/client/JSONTest.java
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=$(ls -ld "$SCRIPT")
|
||||
link=$(expr "$ls" : '.*-> \(.*\)$')
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=$(dirname "$SCRIPT")/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=$(dirname "$SCRIPT")/..
|
||||
APP_DIR=$(cd "${APP_DIR}"; pwd)
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn clean package
|
||||
fi
|
||||
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="$@ generate -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -t modules/openapi-generator/src/main/resources/kotlin-client -g kotlin --artifact-id kotlin-petstore-client -D dateLibrary=java8 -o samples/openapi3/client/petstore/kotlin $@"
|
||||
|
||||
echo "Cleaning previously generated files if any from samples/openapi3/client/petstore/kotlin"
|
||||
rm -rf samples/openapi3/client/petstore/kotlin
|
||||
|
||||
echo "Generating Kotling client..."
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
@@ -28,6 +28,6 @@ fi
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
# complex module name used for testing
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/perl -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g perl -o samples/client/petstore/perl -DhideGenerationTimestamp=true $@"
|
||||
ags="generate -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g perl -o samples/client/petstore/perl -DhideGenerationTimestamp=true $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
@@ -28,7 +28,7 @@ fi
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
# complex module name used for testing
|
||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -g perl -o samples/client/petstore-security-test/perl $@"
|
||||
ags="generate -i modules/openapi-generator/src/test/resources/2_0/petstore-security-test.yaml -l perl -o samples/client/petstore-security-test/perl $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
|
||||
@@ -27,6 +27,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/swift3 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift3-deprecated -c ./bin/swift3-petstore-objcCompatible.json -o samples/client/petstore/swift3/objcCompatible $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/swift3 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift3 -c ./bin/swift3-petstore-objcCompatible.json -o samples/client/petstore/swift3/objcCompatible $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
@@ -27,6 +27,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/swift3 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift3-deprecated -c ./bin/swift3-petstore-promisekit.json -o samples/client/petstore/swift3/promisekit $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/swift3 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift3 -c ./bin/swift3-petstore-promisekit.json -o samples/client/petstore/swift3/promisekit $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
@@ -27,6 +27,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/swift3 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift3-deprecated -c ./bin/swift3-petstore-rxswift.json -o samples/client/petstore/swift3/rxswift $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/swift3 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift3 -c ./bin/swift3-petstore-rxswift.json -o samples/client/petstore/swift3/rxswift $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
@@ -27,6 +27,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/swift3 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift3-deprecated -c ./bin/swift3-petstore-unwraprequired.json -o samples/client/petstore/swift3/unwraprequired $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/swift3 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift3 -c ./bin/swift3-petstore-unwraprequired.json -o samples/client/petstore/swift3/unwraprequired $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
@@ -27,6 +27,6 @@ fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/swift3 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift3-deprecated -c ./bin/swift3-petstore.json -o samples/client/petstore/swift3/default $@"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/swift3 -i modules/openapi-generator/src/test/resources/2_0/swift/petstore-with-fake-endpoints-models-for-testing.yaml -g swift3 -c ./bin/swift3-petstore.json -o samples/client/petstore/swift3/default $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
|
||||
@@ -5,8 +5,8 @@ If Not Exist %executable% (
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -g dart-jaguar -o samples\client\petstore\dart-jaguar\swagger -DhideGenerationTimestamp=true -DbrowserClient=false
|
||||
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -l dart-jaguar -o samples\client\petstore\dart-jaguar\swagger -DhideGenerationTimestamp=true -DbrowserClient=false
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -g dart-jaguar -o samples\client\petstore\dart-jaguar\flutter_petstore\swagger -DhideGenerationTimestamp=true
|
||||
set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -l dart-jaguar -o samples\client\petstore\dart-jaguar\flutter_petstore\swagger -DhideGenerationTimestamp=true
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
10
bin/windows/dukescript-petstore.bat
Normal file
10
bin/windows/dukescript-petstore.bat
Normal file
@@ -0,0 +1,10 @@
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g dukescript -o samples\client\petstore\dukescript
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
@@ -5,6 +5,6 @@ If Not Exist %executable% (
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -g swift3-deprecated -c bin\swift3-petstore-promisekit.json -o samples\client\petstore\swift3\promisekit
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -g swift3 -c bin\swift3-petstore-promisekit.json -o samples\client\petstore\swift3\promisekit
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
@@ -5,6 +5,6 @@ If Not Exist %executable% (
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -g swift3-deprecated -c bin\swift3-petstore-rxswift.json -o samples\client\petstore\swift3\rxswift
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -g swift3 -c bin\swift3-petstore-rxswift.json -o samples\client\petstore\swift3\rxswift
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
@@ -5,6 +5,6 @@ If Not Exist %executable% (
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -g swift3-deprecated -o samples\client\petstore\swift3\default
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore-with-fake-endpoints-models-for-testing.yaml -g swift3 -o samples\client\petstore\swift3\default
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
@@ -5,6 +5,6 @@ If Not Exist %executable% (
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-angular -c bin\typescript-angular-v6-petstore-not-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v6-not-provided-in-root\builds\with-npm -D providedInRoot=false --additional-properties ngVersion=6.0.0
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -c bin\typescript-angular-v6-petstore-not-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v6-not-provided-in-root\builds\with-npm -D providedInRoot=false --additional-properties ngVersion=6.0.0
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
@@ -5,6 +5,6 @@ If Not Exist %executable% (
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-angular -o samples\client\petstore\typescript-angular-v6-not-provided-in-root\builds\default -D providedInRoot=false --additional-properties ngVersion=6.0.0
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -o samples\client\petstore\typescript-angular-v6-not-provided-in-root\builds\default -D providedInRoot=false --additional-properties ngVersion=6.0.0
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
@@ -4,6 +4,6 @@ If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-angular -c bin/typescript-angular-v6-petstore-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v6-provided-in-root\builds\with-npm --additional-properties ngVersion=6.0.0
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -c bin/typescript-angular-v6-petstore-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v6-provided-in-root\builds\with-npm --additional-properties ngVersion=6.0.0
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
@@ -4,6 +4,6 @@ If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-angular -o samples\client\petstore\typescript-angular-v6-provided-in-root\builds\default --additional-properties ngVersion=6.0.0
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -o samples\client\petstore\typescript-angular-v6-provided-in-root\builds\default --additional-properties ngVersion=6.0.0
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
@@ -5,6 +5,6 @@ If Not Exist %executable% (
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-angular -c bin\typescript-angular-v7-petstore-not-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v7-not-provided-in-root\builds\with-npm -D providedInRoot=false --additional-properties ngVersion=7.0.0
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -c bin\typescript-angular-v7-petstore-not-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v7-not-provided-in-root\builds\with-npm -D providedInRoot=false --additional-properties ngVersion=7.0.0
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
@@ -5,6 +5,6 @@ If Not Exist %executable% (
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-angular -o samples\client\petstore\typescript-angular-v7-not-provided-in-root\builds\default -D providedInRoot=false --additional-properties ngVersion=7.0.0
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -o samples\client\petstore\typescript-angular-v7-not-provided-in-root\builds\default -D providedInRoot=false --additional-properties ngVersion=7.0.0
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
@@ -4,6 +4,6 @@ If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-angular -c bin/typescript-angular-v7-petstore-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v7-provided-in-root\builds\with-npm --additional-properties ngVersion=7.0.0
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -c bin/typescript-angular-v7-petstore-provided-in-root-with-npm.json -o samples\client\petstore\typescript-angular-v7-provided-in-root\builds\with-npm --additional-properties ngVersion=7.0.0
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
@@ -4,6 +4,6 @@ If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g typescript-angular -o samples\client\petstore\typescript-angular-v7-provided-in-root\builds\default --additional-properties ngVersion=7.0.0
|
||||
set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -l typescript-angular -o samples\client\petstore\typescript-angular-v7-provided-in-root\builds\default --additional-properties ngVersion=7.0.0
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
|
||||
@@ -69,7 +69,4 @@ CONFIG OPTIONS for csharp
|
||||
validatable
|
||||
Generates self-validatable models. (Default: true)
|
||||
|
||||
useCompareNetObjects
|
||||
Use KellermanSoftware.CompareNetObjects for deep recursive object comparison. WARNING: this option incurs potential performance impact. (Default: false)
|
||||
|
||||
Back to the [generators list](README.md)
|
||||
|
||||
@@ -146,9 +146,6 @@ CONFIG OPTIONS for java
|
||||
feignVersion
|
||||
Version of OpenFeign: '10.x', '9.x' (default) (Default: false)
|
||||
|
||||
useReflectionEqualsHashCode
|
||||
Use org.apache.commons.lang3.builder for equals and hashCode in the models. WARNING: This will fail under a security manager, unless the appropriate permissions are set up correctly and also there's potential performance impact. (Default: false)
|
||||
|
||||
library
|
||||
library template (sub-template) to use (Default: okhttp-gson)
|
||||
jersey1 - HTTP client: Jersey client 1.19.4. JSON processing: Jackson 2.8.9. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.
|
||||
|
||||
@@ -40,4 +40,7 @@ CONFIG OPTIONS for php-slim
|
||||
artifactVersion
|
||||
The version to use in the composer package version field. e.g. 1.2.3
|
||||
|
||||
phpcsStandard
|
||||
PHP CodeSniffer <standard> option. Accepts name or path of the coding standard to use. (Default: PSR12)
|
||||
|
||||
Back to the [generators list](README.md)
|
||||
|
||||
@@ -11,17 +11,6 @@ Another approach to find breaking changes is to look at issue and pull requests
|
||||
* link:https://github.com/OpenAPITools/openapi-generator/labels/Breaking%20change%20%28with%20fallback%29[Breaking change (with fallback)]
|
||||
* link:https://github.com/OpenAPITools/openapi-generator/labels/Breaking%20change%20%28without%20fallback%29[Breaking change (without fallback)]
|
||||
|
||||
=== From 3.x to 4.0.0
|
||||
|
||||
Version `4.0.0` is a major release, which contains some breaking changes without fallback.
|
||||
|
||||
==== The `-l` (`--lang`) option has been deleted
|
||||
|
||||
The option is replaced with `-g` (`--generator-name`).
|
||||
|
||||
* `-g` allows the same values as `-l`
|
||||
* See `langs` command for the list of generator name
|
||||
|
||||
=== From 3.1.x to 3.2.0
|
||||
|
||||
Version `3.2.0` is a minor version of OpenAPI-Generator, in comparison to `3.1.x` it contains some breaking changes, but with the possibility to fallback to the old behavior.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>4.0.0-beta</version>
|
||||
<version>4.0.0-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -72,7 +72,7 @@ public class OpenAPIGenerator {
|
||||
System.exit(1);
|
||||
}
|
||||
} catch (ParseArgumentsUnexpectedException e) {
|
||||
System.err.printf(Locale.ROOT,"[error] %s%n%nSee 'openapi-generator help' for usage.%n", e.getMessage());
|
||||
System.err.printf(Locale.ROOT,"[error] %s%n%nSee 'openapi-generator-cli help' for usage.%n", e.getMessage());
|
||||
System.exit(1);
|
||||
} catch (ParseOptionMissingException | ParseOptionMissingValueException e) {
|
||||
System.err.printf(Locale.ROOT,"[error] %s%n", e.getMessage());
|
||||
|
||||
@@ -37,6 +37,10 @@ public class ConfigHelp implements Runnable {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(Generate.class);
|
||||
|
||||
@Option(name = {"-l", "--lang"}, title = "language",
|
||||
description = "language to get config help for")
|
||||
private String lang;
|
||||
|
||||
@Option(name = {"-g", "--generator-name"}, title = "generator name",
|
||||
description = "generator to get config help for")
|
||||
private String generatorName;
|
||||
@@ -53,9 +57,16 @@ public class ConfigHelp implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
// TODO: After 3.0.0 release (maybe for 3.1.0): Fully deprecate lang.
|
||||
if (isEmpty(generatorName)) {
|
||||
System.err.println("[error] A generator name (--generator-name / -g) is required.");
|
||||
System.exit(1);
|
||||
if (isNotEmpty(lang)) {
|
||||
LOGGER.warn("The '--lang' and '-l' are deprecated and may reference language names only in the next major release (4.0). Please use --generator-name /-g instead.");
|
||||
generatorName = lang;
|
||||
} else {
|
||||
System.err.println("[error] A generator name (--generator-name / -g) is required.");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -49,6 +49,10 @@ public class Generate implements Runnable {
|
||||
@Option(name = {"-v", "--verbose"}, description = "verbose mode")
|
||||
private Boolean verbose;
|
||||
|
||||
@Option(name = {"-l", "--lang"}, title = "language",
|
||||
description = "client language to generate (maybe class name in classpath, required)")
|
||||
private String lang;
|
||||
|
||||
@Option(name = {"-g", "--generator-name"}, title = "generator name",
|
||||
description = "generator to use (see langs command for list)")
|
||||
private String generatorName;
|
||||
@@ -208,9 +212,6 @@ public class Generate implements Runnable {
|
||||
@Option(name = {"--enable-post-process-file"}, title = "enable post-process file", description = CodegenConstants.ENABLE_POST_PROCESS_FILE)
|
||||
private Boolean enablePostProcessFile;
|
||||
|
||||
@Option(name = {"--generate-alias-as-model"}, title = "generate alias (array, map) as model", description = CodegenConstants.GENERATE_ALIAS_AS_MODEL_DESC)
|
||||
private Boolean generateAliasAsModel;
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (logToStderr != null) {
|
||||
@@ -254,8 +255,12 @@ public class Generate implements Runnable {
|
||||
configurator.setInputSpec(spec);
|
||||
}
|
||||
|
||||
// TODO: After 3.0.0 release (maybe for 3.1.0): Fully deprecate lang.
|
||||
if (isNotEmpty(generatorName)) {
|
||||
configurator.setGeneratorName(generatorName);
|
||||
} else if (isNotEmpty(lang)) {
|
||||
LOGGER.warn("The '--lang' and '-l' are deprecated and may reference language names only in the next major release (4.0). Please use --generator-name /-g instead.");
|
||||
configurator.setGeneratorName(lang);
|
||||
} else {
|
||||
System.err.println("[error] A generator name (--generator-name / -g) is required.");
|
||||
System.exit(1);
|
||||
@@ -337,10 +342,6 @@ public class Generate implements Runnable {
|
||||
configurator.setEnablePostProcessFile(enablePostProcessFile);
|
||||
}
|
||||
|
||||
if (generateAliasAsModel != null) {
|
||||
configurator.setGenerateAliasAsModel(generateAliasAsModel);
|
||||
}
|
||||
|
||||
applySystemPropertiesKvpList(systemProperties, configurator);
|
||||
applyInstantiationTypesKvpList(instantiationTypes, configurator);
|
||||
applyImportMappingsKvpList(importMappings, configurator);
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.gradle.kotlin.dsl.property
|
||||
import org.openapitools.codegen.CodegenConstants
|
||||
import org.openapitools.codegen.DefaultGenerator
|
||||
import org.openapitools.codegen.config.CodegenConfigurator
|
||||
import org.openapitools.codegen.config.GeneratorProperties
|
||||
|
||||
|
||||
/**
|
||||
@@ -353,36 +352,36 @@ open class GenerateTask : DefaultTask() {
|
||||
try {
|
||||
if (systemProperties.isPresent) {
|
||||
systemProperties.get().forEach { (key, value) ->
|
||||
// GeneratorProperties.setProperty returns the original value for a key, or null.
|
||||
// System.setProperty returns the original value for a key, or null.
|
||||
// Cache the original value or null…we will late put the properties back in their original state.
|
||||
originalEnvironmentVariables[key] = GeneratorProperties.setProperty(key, value)
|
||||
originalEnvironmentVariables[key] = System.setProperty(key, value)
|
||||
configurator.addSystemProperty(key, value)
|
||||
}
|
||||
}
|
||||
|
||||
if (supportingFilesConstrainedTo.isPresent && supportingFilesConstrainedTo.get().isNotEmpty()) {
|
||||
GeneratorProperties.setProperty(CodegenConstants.SUPPORTING_FILES, supportingFilesConstrainedTo.get().joinToString(","))
|
||||
System.setProperty(CodegenConstants.SUPPORTING_FILES, supportingFilesConstrainedTo.get().joinToString(","))
|
||||
} else {
|
||||
GeneratorProperties.clearProperty(CodegenConstants.SUPPORTING_FILES)
|
||||
System.clearProperty(CodegenConstants.SUPPORTING_FILES)
|
||||
}
|
||||
|
||||
if (modelFilesConstrainedTo.isPresent && modelFilesConstrainedTo.get().isNotEmpty()) {
|
||||
GeneratorProperties.setProperty(CodegenConstants.MODELS, modelFilesConstrainedTo.get().joinToString(","))
|
||||
System.setProperty(CodegenConstants.MODELS, modelFilesConstrainedTo.get().joinToString(","))
|
||||
} else {
|
||||
GeneratorProperties.clearProperty(CodegenConstants.MODELS)
|
||||
System.clearProperty(CodegenConstants.MODELS)
|
||||
}
|
||||
|
||||
if (apiFilesConstrainedTo.isPresent && apiFilesConstrainedTo.get().isNotEmpty()) {
|
||||
GeneratorProperties.setProperty(CodegenConstants.APIS, apiFilesConstrainedTo.get().joinToString(","))
|
||||
System.setProperty(CodegenConstants.APIS, apiFilesConstrainedTo.get().joinToString(","))
|
||||
} else {
|
||||
GeneratorProperties.clearProperty(CodegenConstants.APIS)
|
||||
System.clearProperty(CodegenConstants.APIS)
|
||||
}
|
||||
|
||||
GeneratorProperties.setProperty(CodegenConstants.API_DOCS, generateApiDocumentation.get().toString())
|
||||
GeneratorProperties.setProperty(CodegenConstants.MODEL_DOCS, generateModelDocumentation.get().toString())
|
||||
GeneratorProperties.setProperty(CodegenConstants.MODEL_TESTS, generateModelTests.get().toString())
|
||||
GeneratorProperties.setProperty(CodegenConstants.API_TESTS, generateApiTests.get().toString())
|
||||
GeneratorProperties.setProperty(CodegenConstants.WITH_XML, withXml.get().toString())
|
||||
System.setProperty(CodegenConstants.API_DOCS, generateApiDocumentation.get().toString())
|
||||
System.setProperty(CodegenConstants.MODEL_DOCS, generateModelDocumentation.get().toString())
|
||||
System.setProperty(CodegenConstants.MODEL_TESTS, generateModelTests.get().toString())
|
||||
System.setProperty(CodegenConstants.API_TESTS, generateApiTests.get().toString())
|
||||
System.setProperty(CodegenConstants.WITH_XML, withXml.get().toString())
|
||||
|
||||
// now override with any specified parameters
|
||||
verbose.ifNotEmpty { value ->
|
||||
@@ -543,7 +542,13 @@ open class GenerateTask : DefaultTask() {
|
||||
}
|
||||
} finally {
|
||||
// Reset all modified system properties back to their original state
|
||||
GeneratorProperties.reset()
|
||||
originalEnvironmentVariables.forEach {
|
||||
when {
|
||||
it.value == null -> System.clearProperty(it.key)
|
||||
else -> System.setProperty(it.key, it.value)
|
||||
}
|
||||
}
|
||||
originalEnvironmentVariables.clear()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
openApiGeneratorVersion=4.0.0-beta
|
||||
openApiGeneratorVersion=4.0.0-SNAPSHOT
|
||||
|
||||
# BEGIN placeholders
|
||||
# these are just placeholders to allow contributors to build directly
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>4.0.0-beta</version>
|
||||
<version>4.0.0-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -28,7 +28,6 @@ import org.gradle.kotlin.dsl.property
|
||||
import org.openapitools.codegen.CodegenConstants
|
||||
import org.openapitools.codegen.DefaultGenerator
|
||||
import org.openapitools.codegen.config.CodegenConfigurator
|
||||
import org.openapitools.codegen.config.GeneratorProperties
|
||||
|
||||
|
||||
/**
|
||||
@@ -324,6 +323,8 @@ open class GenerateTask : DefaultTask() {
|
||||
@get:Internal
|
||||
val configOptions = project.objects.property<Map<String, String>>()
|
||||
|
||||
private val originalEnvironmentVariables = mutableMapOf<String, String?>()
|
||||
|
||||
private fun <T : Any?> Property<T>.ifNotEmpty(block: Property<T>.(T) -> Unit) {
|
||||
if (isPresent) {
|
||||
val item: T? = get()
|
||||
@@ -351,33 +352,36 @@ open class GenerateTask : DefaultTask() {
|
||||
try {
|
||||
if (systemProperties.isPresent) {
|
||||
systemProperties.get().forEach { (key, value) ->
|
||||
// System.setProperty returns the original value for a key, or null.
|
||||
// Cache the original value or null…we will late put the properties back in their original state.
|
||||
originalEnvironmentVariables[key] = System.setProperty(key, value)
|
||||
configurator.addSystemProperty(key, value)
|
||||
}
|
||||
}
|
||||
|
||||
if (supportingFilesConstrainedTo.isPresent && supportingFilesConstrainedTo.get().isNotEmpty()) {
|
||||
GeneratorProperties.setProperty(CodegenConstants.SUPPORTING_FILES, supportingFilesConstrainedTo.get().joinToString(","))
|
||||
System.setProperty(CodegenConstants.SUPPORTING_FILES, supportingFilesConstrainedTo.get().joinToString(","))
|
||||
} else {
|
||||
GeneratorProperties.clearProperty(CodegenConstants.SUPPORTING_FILES)
|
||||
System.clearProperty(CodegenConstants.SUPPORTING_FILES)
|
||||
}
|
||||
|
||||
if (modelFilesConstrainedTo.isPresent && modelFilesConstrainedTo.get().isNotEmpty()) {
|
||||
GeneratorProperties.setProperty(CodegenConstants.MODELS, modelFilesConstrainedTo.get().joinToString(","))
|
||||
System.setProperty(CodegenConstants.MODELS, modelFilesConstrainedTo.get().joinToString(","))
|
||||
} else {
|
||||
GeneratorProperties.clearProperty(CodegenConstants.MODELS)
|
||||
System.clearProperty(CodegenConstants.MODELS)
|
||||
}
|
||||
|
||||
if (apiFilesConstrainedTo.isPresent && apiFilesConstrainedTo.get().isNotEmpty()) {
|
||||
GeneratorProperties.setProperty(CodegenConstants.APIS, apiFilesConstrainedTo.get().joinToString(","))
|
||||
System.setProperty(CodegenConstants.APIS, apiFilesConstrainedTo.get().joinToString(","))
|
||||
} else {
|
||||
GeneratorProperties.clearProperty(CodegenConstants.APIS)
|
||||
System.clearProperty(CodegenConstants.APIS)
|
||||
}
|
||||
|
||||
GeneratorProperties.setProperty(CodegenConstants.API_DOCS, generateApiDocumentation.get().toString())
|
||||
GeneratorProperties.setProperty(CodegenConstants.MODEL_DOCS, generateModelDocumentation.get().toString())
|
||||
GeneratorProperties.setProperty(CodegenConstants.MODEL_TESTS, generateModelTests.get().toString())
|
||||
GeneratorProperties.setProperty(CodegenConstants.API_TESTS, generateApiTests.get().toString())
|
||||
GeneratorProperties.setProperty(CodegenConstants.WITH_XML, withXml.get().toString())
|
||||
System.setProperty(CodegenConstants.API_DOCS, generateApiDocumentation.get().toString())
|
||||
System.setProperty(CodegenConstants.MODEL_DOCS, generateModelDocumentation.get().toString())
|
||||
System.setProperty(CodegenConstants.MODEL_TESTS, generateModelTests.get().toString())
|
||||
System.setProperty(CodegenConstants.API_TESTS, generateApiTests.get().toString())
|
||||
System.setProperty(CodegenConstants.WITH_XML, withXml.get().toString())
|
||||
|
||||
// now override with any specified parameters
|
||||
verbose.ifNotEmpty { value ->
|
||||
@@ -537,7 +541,14 @@ open class GenerateTask : DefaultTask() {
|
||||
throw GradleException("Code generation failed.", e)
|
||||
}
|
||||
} finally {
|
||||
GeneratorProperties.reset()
|
||||
// Reset all modified system properties back to their original state
|
||||
originalEnvironmentVariables.forEach {
|
||||
when {
|
||||
it.value == null -> System.clearProperty(it.key)
|
||||
else -> System.setProperty(it.key, it.value)
|
||||
}
|
||||
}
|
||||
originalEnvironmentVariables.clear()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>4.0.0-beta</version>
|
||||
<version>4.0.0-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
@@ -23,7 +23,7 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-core</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<version>3.2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
@@ -34,12 +34,12 @@
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-compat</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<version>3.2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>maven-plugin-api</artifactId>
|
||||
<version>3.3.1</version>
|
||||
<version>3.2.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.maven.plugin-tools</groupId>
|
||||
|
||||
@@ -51,7 +51,6 @@ import org.openapitools.codegen.CodegenConfig;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.DefaultGenerator;
|
||||
import org.openapitools.codegen.config.CodegenConfigurator;
|
||||
import org.openapitools.codegen.config.GeneratorProperties;
|
||||
import org.sonatype.plexus.build.incremental.BuildContext;
|
||||
import org.sonatype.plexus.build.incremental.DefaultBuildContext;
|
||||
import org.slf4j.Logger;
|
||||
@@ -500,28 +499,28 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
|
||||
// Set generation options
|
||||
if (null != generateApis && generateApis) {
|
||||
GeneratorProperties.setProperty(CodegenConstants.APIS, "");
|
||||
System.setProperty(CodegenConstants.APIS, "");
|
||||
} else {
|
||||
GeneratorProperties.clearProperty(CodegenConstants.APIS);
|
||||
System.clearProperty(CodegenConstants.APIS);
|
||||
}
|
||||
|
||||
if (null != generateModels && generateModels) {
|
||||
GeneratorProperties.setProperty(CodegenConstants.MODELS, modelsToGenerate);
|
||||
System.setProperty(CodegenConstants.MODELS, modelsToGenerate);
|
||||
} else {
|
||||
GeneratorProperties.clearProperty(CodegenConstants.MODELS);
|
||||
System.clearProperty(CodegenConstants.MODELS);
|
||||
}
|
||||
|
||||
if (null != generateSupportingFiles && generateSupportingFiles) {
|
||||
GeneratorProperties.setProperty(CodegenConstants.SUPPORTING_FILES, supportingFilesToGenerate);
|
||||
System.setProperty(CodegenConstants.SUPPORTING_FILES, supportingFilesToGenerate);
|
||||
} else {
|
||||
GeneratorProperties.clearProperty(CodegenConstants.SUPPORTING_FILES);
|
||||
System.clearProperty(CodegenConstants.SUPPORTING_FILES);
|
||||
}
|
||||
|
||||
GeneratorProperties.setProperty(CodegenConstants.MODEL_TESTS, generateModelTests.toString());
|
||||
GeneratorProperties.setProperty(CodegenConstants.MODEL_DOCS, generateModelDocumentation.toString());
|
||||
GeneratorProperties.setProperty(CodegenConstants.API_TESTS, generateApiTests.toString());
|
||||
GeneratorProperties.setProperty(CodegenConstants.API_DOCS, generateApiDocumentation.toString());
|
||||
GeneratorProperties.setProperty(CodegenConstants.WITH_XML, withXml.toString());
|
||||
System.setProperty(CodegenConstants.MODEL_TESTS, generateModelTests.toString());
|
||||
System.setProperty(CodegenConstants.MODEL_DOCS, generateModelDocumentation.toString());
|
||||
System.setProperty(CodegenConstants.API_TESTS, generateApiTests.toString());
|
||||
System.setProperty(CodegenConstants.API_DOCS, generateApiDocumentation.toString());
|
||||
System.setProperty(CodegenConstants.WITH_XML, withXml.toString());
|
||||
|
||||
if (configOptions != null) {
|
||||
// Retained for backwards-compataibility with configOptions -> instantiation-types
|
||||
@@ -594,13 +593,13 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
if (environmentVariables != null) {
|
||||
|
||||
for (String key : environmentVariables.keySet()) {
|
||||
originalEnvironmentVariables.put(key, GeneratorProperties.getProperty(key));
|
||||
originalEnvironmentVariables.put(key, System.getProperty(key));
|
||||
String value = environmentVariables.get(key);
|
||||
if (value == null) {
|
||||
// don't put null values
|
||||
value = "";
|
||||
}
|
||||
GeneratorProperties.setProperty(key, value);
|
||||
System.setProperty(key, value);
|
||||
configurator.addSystemProperty(key, value);
|
||||
}
|
||||
}
|
||||
@@ -681,9 +680,9 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
// when running the plugin multiple consecutive times with different configurations.
|
||||
for (Map.Entry<String, String> entry : originalEnvironmentVariables.entrySet()) {
|
||||
if (entry.getValue() == null) {
|
||||
GeneratorProperties.clearProperty(entry.getKey());
|
||||
System.clearProperty(entry.getKey());
|
||||
} else {
|
||||
GeneratorProperties.setProperty(entry.getKey(), entry.getValue());
|
||||
System.setProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>4.0.0-beta</version>
|
||||
<version>4.0.0-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<artifactId>openapi-generator-online</artifactId>
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
package org.openapitools.codegen.online.api;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.openapitools.codegen.online.model.ResponseCode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.web.servlet.MockMvc;
|
||||
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.text.MatchesPattern.matchesPattern;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
|
||||
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;
|
||||
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@WebMvcTest(GenApiController.class)
|
||||
public class GenApiControllerTest {
|
||||
|
||||
private static final String OPENAPI_URL = "http://petstore.swagger.io/v2/swagger.json";
|
||||
private static final String UUID_REGEX = "[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-4[a-fA-F0-9]{3}-[89aAbB][a-fA-F0-9]{3}-[a-fA-F0-9]{12}";
|
||||
|
||||
@Autowired
|
||||
private MockMvc mockMvc;
|
||||
|
||||
|
||||
@Test
|
||||
public void clientLanguages() throws Exception {
|
||||
getLanguages("clients", "java");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serverFrameworks() throws Exception {
|
||||
getLanguages("servers", "spring");
|
||||
}
|
||||
|
||||
|
||||
public void getLanguages(String type, String expected) throws Exception {
|
||||
mockMvc.perform(get("/api/gen/" + type))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
||||
.andExpect(jsonPath("$.[*]").value(hasItem(expected)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clientOptions() throws Exception {
|
||||
getOptions("clients", "java");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clientOptionsUnknown() throws Exception {
|
||||
mockMvc.perform(get("/api/gen/clients/unknown"))
|
||||
.andExpect(status().isNotFound());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serverOptions() throws Exception {
|
||||
getOptions("servers", "spring");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void serverOptionsUnknown() throws Exception {
|
||||
mockMvc.perform(get("/api/gen/servers/unknown"))
|
||||
.andExpect(status().isNotFound());
|
||||
}
|
||||
|
||||
private void getOptions(String type, String name) throws Exception {
|
||||
mockMvc.perform(get("/api/gen/" + type + "/" + name))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
||||
.andExpect(jsonPath("$.sortParamsByRequiredFlag.opt").value("sortParamsByRequiredFlag"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generateClient() throws Exception {
|
||||
generateAndDownload("clients", "java");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generateServer() throws Exception {
|
||||
generateAndDownload("servers", "spring");
|
||||
}
|
||||
|
||||
private void generateAndDownload(String type, String name) throws Exception {
|
||||
String result = mockMvc.perform(post("http://test.com:1234/api/gen/" + type + "/" + name)
|
||||
.contentType(MediaType.APPLICATION_JSON_UTF8)
|
||||
.content("{\"openAPIUrl\": \"" + OPENAPI_URL + "\"}"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
||||
.andExpect(jsonPath("$.code").value(matchesPattern(UUID_REGEX)))
|
||||
.andExpect(jsonPath("$.link").value(matchesPattern("http\\:\\/\\/test.com\\:1234\\/api\\/gen\\/download\\/" + UUID_REGEX)))
|
||||
.andReturn().getResponse().getContentAsString();
|
||||
|
||||
String code = new ObjectMapper().readValue(result, ResponseCode.class).getCode();
|
||||
|
||||
mockMvc.perform(get("http://test.com:1234/api/gen/download/" + code))
|
||||
.andExpect(content().contentType("application/zip"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(header().string(HttpHeaders.CONTENT_LENGTH, not(0)));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void generateWIthForwardedHeaders() throws Exception {
|
||||
String result = mockMvc.perform(post("http://test.com:1234/api/gen/clients/java")
|
||||
.contentType(MediaType.APPLICATION_JSON_UTF8)
|
||||
.header("X-Forwarded-Proto", "https")
|
||||
.header("X-Forwarded-Host", "forwarded.com")
|
||||
.header("X-Forwarded-Port", "5678")
|
||||
.content("{\"openAPIUrl\": \"" + OPENAPI_URL + "\"}"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8))
|
||||
.andExpect(jsonPath("$.code").value(matchesPattern(UUID_REGEX)))
|
||||
.andExpect(jsonPath("$.link").value(matchesPattern("https\\:\\/\\/forwarded.com\\:5678\\/api\\/gen\\/download\\/" + UUID_REGEX)))
|
||||
.andReturn().getResponse().getContentAsString();
|
||||
|
||||
String code = new ObjectMapper().readValue(result, ResponseCode.class).getCode();
|
||||
|
||||
mockMvc.perform(get("http://test.com:1234/api/gen/download/" + code))
|
||||
.andExpect(content().contentType("application/zip"))
|
||||
.andExpect(status().isOk())
|
||||
.andExpect(header().string(HttpHeaders.CONTENT_LENGTH, not(0)));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>4.0.0-beta</version>
|
||||
<version>4.0.0-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
@@ -204,7 +204,7 @@
|
||||
<version>${swagger-core-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>${swagger-parser-groupid}</groupId>
|
||||
<groupId>io.swagger.parser.v3</groupId>
|
||||
<artifactId>swagger-parser</artifactId>
|
||||
<version>${swagger-parser-version}</version>
|
||||
</dependency>
|
||||
|
||||
@@ -81,8 +81,6 @@ public interface CodegenConfig {
|
||||
|
||||
String escapeTextWhileAllowingNewLines(String text);
|
||||
|
||||
String encodePath(String text);
|
||||
|
||||
String escapeUnsafeCharacters(String input);
|
||||
|
||||
String escapeReservedWord(String name);
|
||||
@@ -173,8 +171,6 @@ public interface CodegenConfig {
|
||||
|
||||
void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation co, Map<String, List<CodegenOperation>> operations);
|
||||
|
||||
Map<String, Object> updateAllModels(Map<String, Object> objs);
|
||||
|
||||
Map<String, Object> postProcessAllModels(Map<String, Object> objs);
|
||||
|
||||
Map<String, Object> postProcessModels(Map<String, Object> objs);
|
||||
@@ -264,11 +260,11 @@ public interface CodegenConfig {
|
||||
|
||||
boolean isEnablePostProcessFile();
|
||||
|
||||
void setEnablePostProcessFile(boolean isEnablePostProcessFile);
|
||||
public void setEnablePostProcessFile(boolean isEnablePostProcessFile);
|
||||
|
||||
// set OpenAPI and schemas
|
||||
void setGlobalOpenAPI(OpenAPI openAPI);
|
||||
public void setGlobalOpenAPI(OpenAPI openAPI);
|
||||
|
||||
void setGlobalSchemas(OpenAPI openAPI);
|
||||
public void setGlobalSchemas(OpenAPI openAPI);
|
||||
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ public class CodegenConfigLoader {
|
||||
|
||||
// else try to load directly
|
||||
try {
|
||||
return (CodegenConfig) Class.forName(name).getDeclaredConstructor().newInstance();
|
||||
return (CodegenConfig) Class.forName(name).newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new GeneratorNotFoundException("Can't load config class with name '".concat(name) + "'\nAvailable:\n" + availableConfigs.toString(), e);
|
||||
}
|
||||
|
||||
@@ -283,10 +283,4 @@ public class CodegenConstants {
|
||||
public static final String ENABLE_POST_PROCESS_FILE_DESC = "Enable post-processing file using environment variables.";
|
||||
|
||||
public static final String OPEN_API_SPEC_NAME = "openAPISpecName";
|
||||
|
||||
public static final String GENERATE_ALIAS_AS_MODEL = "generateAliasAsModel";
|
||||
public static final String GENERATE_ALIAS_AS_MODEL_DESC = "Generate alias to map, array as models";
|
||||
|
||||
public static final String USE_COMPARE_NET_OBJECTS = "useCompareNetObjects";
|
||||
public static final String USE_COMPARE_NET_OBJECTS_DESC = "Use KellermanSoftware.CompareNetObjects for deep recursive object comparison. WARNING: this option incurs potential performance impact.";
|
||||
}
|
||||
@@ -22,13 +22,11 @@ import io.swagger.v3.oas.models.ExternalDocumentation;
|
||||
import java.util.*;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
|
||||
@JsonIgnoreProperties({"parentModel", "interfaceModels"})
|
||||
public class CodegenModel {
|
||||
public String parent, parentSchema;
|
||||
public List<String> interfaces;
|
||||
public List<String> allParents;
|
||||
|
||||
// References to parent and interface CodegenModels. Only set when code generator supports inheritance.
|
||||
public CodegenModel parentModel;
|
||||
@@ -48,18 +46,18 @@ public class CodegenModel {
|
||||
public String arrayModelType;
|
||||
public boolean isAlias; // Is this effectively an alias of another simple type
|
||||
public boolean isString, isInteger;
|
||||
public List<CodegenProperty> vars = new ArrayList<CodegenProperty>(); // all properties (without parent's properties)
|
||||
public List<CodegenProperty> allVars = new ArrayList<CodegenProperty>(); // all properties (with parent's properties)
|
||||
public List<CodegenProperty> vars = new ArrayList<CodegenProperty>();
|
||||
public List<CodegenProperty> requiredVars = new ArrayList<CodegenProperty>(); // a list of required properties
|
||||
public List<CodegenProperty> optionalVars = new ArrayList<CodegenProperty>(); // a list of optional properties
|
||||
public List<CodegenProperty> readOnlyVars = new ArrayList<CodegenProperty>(); // a list of read-only properties
|
||||
public List<CodegenProperty> readWriteVars = new ArrayList<CodegenProperty>(); // a list of properties for read, write
|
||||
public List<CodegenProperty> allVars = new ArrayList<CodegenProperty>();
|
||||
public List<CodegenProperty> parentVars = new ArrayList<CodegenProperty>();
|
||||
public Map<String, Object> allowableValues;
|
||||
|
||||
// Sorted sets of required parameters.
|
||||
public Set<String> mandatory = new TreeSet<String>(); // without parent's required properties
|
||||
public Set<String> allMandatory = new TreeSet<String>(); // with parent's required properties
|
||||
public Set<String> mandatory = new TreeSet<String>();
|
||||
public Set<String> allMandatory;
|
||||
|
||||
public Set<String> imports = new TreeSet<String>();
|
||||
public boolean hasVars, emptyVars, hasMoreModels, hasEnums, isEnum, hasRequired, hasOptional, isArrayModel, hasChildren, isMapModel;
|
||||
@@ -71,59 +69,16 @@ public class CodegenModel {
|
||||
//The type of the value from additional properties. Used in map like objects.
|
||||
public String additionalPropertiesType;
|
||||
|
||||
{
|
||||
// By default these are the same collections. Where the code generator supports inheritance, composed models
|
||||
// store the complete closure of owned and inherited properties in allVars and allMandatory.
|
||||
allVars = vars;
|
||||
allMandatory = mandatory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this)
|
||||
.append("parent", parent)
|
||||
.append("parentSchema", parentSchema)
|
||||
.append("interfaces", interfaces)
|
||||
.append("parentModel", parentModel)
|
||||
.append("interfaceModels", interfaceModels)
|
||||
.append("children", children)
|
||||
.append("name", name)
|
||||
.append("classname", classname)
|
||||
.append("title", title)
|
||||
.append("description", description)
|
||||
.append("classVarName", classVarName)
|
||||
.append("modelJson", modelJson)
|
||||
.append("dataType", dataType)
|
||||
.append("xmlPrefix", xmlPrefix)
|
||||
.append("xmlNamespace", xmlNamespace)
|
||||
.append("xmlName", xmlName)
|
||||
.append("classFilename", classFilename)
|
||||
.append("unescapedDescription", unescapedDescription)
|
||||
.append("discriminator", discriminator)
|
||||
.append("defaultValue", defaultValue)
|
||||
.append("arrayModelType", arrayModelType)
|
||||
.append("isAlias", isAlias)
|
||||
.append("isString", isString)
|
||||
.append("isInteger", isInteger)
|
||||
.append("vars", vars)
|
||||
.append("requiredVars", requiredVars)
|
||||
.append("optionalVars", optionalVars)
|
||||
.append("readOnlyVars", readOnlyVars)
|
||||
.append("readWriteVars", readWriteVars)
|
||||
.append("allVars", allVars)
|
||||
.append("parentVars", parentVars)
|
||||
.append("allowableValues", allowableValues)
|
||||
.append("mandatory", mandatory)
|
||||
.append("allMandatory", allMandatory)
|
||||
.append("imports", imports)
|
||||
.append("hasVars", hasVars)
|
||||
.append("emptyVars", emptyVars)
|
||||
.append("hasMoreModels", hasMoreModels)
|
||||
.append("hasEnums", hasEnums)
|
||||
.append("isEnum", isEnum)
|
||||
.append("hasRequired", hasRequired)
|
||||
.append("hasOptional", hasOptional)
|
||||
.append("isArrayModel", isArrayModel)
|
||||
.append("hasChildren", hasChildren)
|
||||
.append("isMapModel", isMapModel)
|
||||
.append("hasOnlyReadOnly", hasOnlyReadOnly)
|
||||
.append("externalDocumentation", externalDocumentation)
|
||||
.append("vendorExtensions", vendorExtensions)
|
||||
.append("additionalPropertiesType", additionalPropertiesType)
|
||||
.toString();
|
||||
return String.format(Locale.ROOT, "%s(%s)", name, classname);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -139,8 +94,6 @@ public class CodegenModel {
|
||||
return false;
|
||||
if (interfaces != null ? !interfaces.equals(that.interfaces) : that.interfaces != null)
|
||||
return false;
|
||||
if (allParents != null ? !allParents.equals(that.allParents) : that.allParents != null)
|
||||
return false;
|
||||
if (parentModel != null ? !parentModel.equals(that.parentModel) : that.parentModel != null)
|
||||
return false;
|
||||
if (interfaceModels != null ? !interfaceModels.equals(that.interfaceModels) : that.interfaceModels != null)
|
||||
@@ -216,7 +169,6 @@ public class CodegenModel {
|
||||
int result = parent != null ? parent.hashCode() : 0;
|
||||
result = 31 * result + (parentSchema != null ? parentSchema.hashCode() : 0);
|
||||
result = 31 * result + (interfaces != null ? interfaces.hashCode() : 0);
|
||||
result = 31 * result + (allParents != null ? allParents.hashCode() : 0);
|
||||
result = 31 * result + (parentModel != null ? parentModel.hashCode() : 0);
|
||||
result = 31 * result + (interfaceModels != null ? interfaceModels.hashCode() : 0);
|
||||
result = 31 * result + (name != null ? name.hashCode() : 0);
|
||||
@@ -274,18 +226,10 @@ public class CodegenModel {
|
||||
return interfaces;
|
||||
}
|
||||
|
||||
public List<String> getAllParents() {
|
||||
return allParents;
|
||||
}
|
||||
|
||||
public void setInterfaces(List<String> interfaces) {
|
||||
this.interfaces = interfaces;
|
||||
}
|
||||
|
||||
public void setAllParents(List<String> allParents) {
|
||||
this.allParents = allParents;
|
||||
}
|
||||
|
||||
public CodegenModel getParentModel() {
|
||||
return parentModel;
|
||||
}
|
||||
@@ -616,18 +560,4 @@ public class CodegenModel {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove self reference import
|
||||
*/
|
||||
public void removeSelfReferenceImport() {
|
||||
for (CodegenProperty cp : allVars) {
|
||||
// detect self import
|
||||
if (cp.dataType.equalsIgnoreCase(this.classname) ||
|
||||
(cp.isContainer && cp.items.dataType.equalsIgnoreCase(this.classname))) {
|
||||
this.imports.remove(this.classname); // remove self import
|
||||
cp.isSelfReference = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,14 +17,37 @@
|
||||
|
||||
package org.openapitools.codegen;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public final class CodegenModelFactory {
|
||||
|
||||
private static final Map<CodegenModelType, Class<?>> typeMapping = new HashMap<CodegenModelType, Class<?>>();
|
||||
|
||||
/**
|
||||
* Configure a different implementation class.
|
||||
*
|
||||
* @param type the type that shall be replaced
|
||||
* @param implementation the implementation class must extend the default class and must provide a public no-arg constructor
|
||||
*/
|
||||
public static void setTypeMapping(CodegenModelType type, Class<?> implementation) {
|
||||
if (!type.getDefaultImplementation().isAssignableFrom(implementation)) {
|
||||
throw new IllegalArgumentException(implementation.getSimpleName() + " doesn't extend " + type.getDefaultImplementation().getSimpleName());
|
||||
}
|
||||
try {
|
||||
implementation.newInstance();
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException(e);
|
||||
}
|
||||
typeMapping.put(type, implementation);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static <T> T newInstance(CodegenModelType type) {
|
||||
Class<?> classType = typeMapping.get(type);
|
||||
try {
|
||||
return (T) type.getDefaultImplementation().getDeclaredConstructor().newInstance();
|
||||
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
|
||||
return (T) (classType != null ? classType : type.getDefaultImplementation()).newInstance();
|
||||
} catch (IllegalAccessException | InstantiationException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class CodegenProperty implements Cloneable {
|
||||
public boolean exclusiveMaximum;
|
||||
public boolean hasMore, required, secondaryParam;
|
||||
public boolean hasMoreNonReadOnly; // for model constructor, true if next property is not readonly
|
||||
public boolean isPrimitiveType, isModel, isContainer;
|
||||
public boolean isPrimitiveType, isModel, isContainer, isNotContainer;
|
||||
public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isByteArray, isBinary, isFile,
|
||||
isBoolean, isDate, isDateTime, isUuid, isEmail, isFreeFormObject;
|
||||
public boolean isListContainer, isMapContainer;
|
||||
@@ -61,7 +61,6 @@ public class CodegenProperty implements Cloneable {
|
||||
public boolean isReadOnly;
|
||||
public boolean isWriteOnly;
|
||||
public boolean isNullable;
|
||||
public boolean isSelfReference;
|
||||
public List<String> _enum;
|
||||
public Map<String, Object> allowableValues;
|
||||
public CodegenProperty items;
|
||||
@@ -435,12 +434,12 @@ public class CodegenProperty implements Cloneable {
|
||||
result = prime * result + ((hasMoreNonReadOnly ? 13 : 31));
|
||||
result = prime * result + ((isContainer ? 13 : 31));
|
||||
result = prime * result + (isEnum ? 1231 : 1237);
|
||||
result = prime * result + ((isNotContainer ? 13 : 31));
|
||||
result = prime * result + ((isPrimitiveType ? 13 : 31));
|
||||
result = prime * result + ((isModel ? 13 : 31));
|
||||
result = prime * result + ((isReadOnly ? 13 : 31));
|
||||
result = prime * result + ((isWriteOnly ? 13 : 31));
|
||||
result = prime * result + ((isNullable ? 13 : 31));
|
||||
result = prime * result + ((isSelfReference ? 13 : 31));
|
||||
result = prime * result + ((items == null) ? 0 : items.hashCode());
|
||||
result = prime * result + ((mostInnerItems == null) ? 0 : mostInnerItems.hashCode());
|
||||
result = prime * result + ((jsonSchema == null) ? 0 : jsonSchema.hashCode());
|
||||
@@ -587,6 +586,9 @@ public class CodegenProperty implements Cloneable {
|
||||
if (this.isContainer != other.isContainer) {
|
||||
return false;
|
||||
}
|
||||
if (this.isNotContainer != other.isNotContainer) {
|
||||
return false;
|
||||
}
|
||||
if (this.isEnum != other.isEnum) {
|
||||
return false;
|
||||
}
|
||||
@@ -599,9 +601,6 @@ public class CodegenProperty implements Cloneable {
|
||||
if (this.isNullable != other.isNullable) {
|
||||
return false;
|
||||
}
|
||||
if (this.isSelfReference != other.isSelfReference ) {
|
||||
return false;
|
||||
}
|
||||
if (this._enum != other._enum && (this._enum == null || !this._enum.equals(other._enum))) {
|
||||
return false;
|
||||
}
|
||||
@@ -773,6 +772,7 @@ public class CodegenProperty implements Cloneable {
|
||||
", isPrimitiveType=" + isPrimitiveType +
|
||||
", isModel=" + isModel +
|
||||
", isContainer=" + isContainer +
|
||||
", isNotContainer=" + isNotContainer +
|
||||
", isString=" + isString +
|
||||
", isNumeric=" + isNumeric +
|
||||
", isInteger=" + isInteger +
|
||||
@@ -795,7 +795,6 @@ public class CodegenProperty implements Cloneable {
|
||||
", isReadOnly=" + isReadOnly +
|
||||
", isWriteOnly=" + isWriteOnly +
|
||||
", isNullable=" + isNullable +
|
||||
", isSelfReference=" + isSelfReference +
|
||||
", _enum=" + _enum +
|
||||
", allowableValues=" + allowableValues +
|
||||
", items=" + items +
|
||||
|
||||
@@ -53,7 +53,6 @@ import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.openapitools.codegen.CodegenDiscriminator.MappedModel;
|
||||
import org.openapitools.codegen.config.GeneratorProperties;
|
||||
import org.openapitools.codegen.examples.ExampleGenerator;
|
||||
import org.openapitools.codegen.serializer.SerializerUtils;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
@@ -116,7 +115,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
protected List<CliOption> cliOptions = new ArrayList<CliOption>();
|
||||
protected boolean skipOverwrite;
|
||||
protected boolean removeOperationIdPrefix;
|
||||
protected boolean supportsMultipleInheritance;
|
||||
protected boolean supportsInheritance;
|
||||
protected boolean supportsMixins;
|
||||
protected Map<String, String> supportedLibraries = new LinkedHashMap<String, String>();
|
||||
@@ -209,91 +207,58 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
this.setEnablePostProcessFile(Boolean.valueOf(additionalProperties
|
||||
.get(CodegenConstants.ENABLE_POST_PROCESS_FILE).toString()));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(CodegenConstants.GENERATE_ALIAS_AS_MODEL)) {
|
||||
ModelUtils.setGenerateAliasAsModel(Boolean.valueOf(additionalProperties
|
||||
.get(CodegenConstants.GENERATE_ALIAS_AS_MODEL).toString()));
|
||||
}
|
||||
}
|
||||
|
||||
// override with any special post-processing for all models
|
||||
@SuppressWarnings({"static-method", "unchecked"})
|
||||
public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
|
||||
return objs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loop through all models to update different flags (e.g. isSelfReference), children models, etc
|
||||
*
|
||||
* @param objs Map of models
|
||||
* @return maps of models with various updates
|
||||
*/
|
||||
public Map<String, Object> updateAllModels(Map<String, Object> objs) {
|
||||
// Index all CodegenModels by model name.
|
||||
Map<String, CodegenModel> allModels = new HashMap<String, CodegenModel>();
|
||||
for (Entry<String, Object> entry : objs.entrySet()) {
|
||||
String modelName = toModelName(entry.getKey());
|
||||
Map<String, Object> inner = (Map<String, Object>) entry.getValue();
|
||||
List<Map<String, Object>> models = (List<Map<String, Object>>) inner.get("models");
|
||||
for (Map<String, Object> mo : models) {
|
||||
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||
allModels.put(modelName, cm);
|
||||
if (supportsInheritance) {
|
||||
// Index all CodegenModels by model name.
|
||||
Map<String, CodegenModel> allModels = new HashMap<String, CodegenModel>();
|
||||
for (Entry<String, Object> entry : objs.entrySet()) {
|
||||
String modelName = toModelName(entry.getKey());
|
||||
Map<String, Object> inner = (Map<String, Object>) entry.getValue();
|
||||
List<Map<String, Object>> models = (List<Map<String, Object>>) inner.get("models");
|
||||
for (Map<String, Object> mo : models) {
|
||||
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||
allModels.put(modelName, cm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fix up all parent and interface CodegenModel references.
|
||||
for (CodegenModel cm : allModels.values()) {
|
||||
if (cm.getParent() != null) {
|
||||
cm.setParentModel(allModels.get(cm.getParent()));
|
||||
// Fix up all parent and interface CodegenModel references.
|
||||
for (CodegenModel cm : allModels.values()) {
|
||||
if (cm.getParent() != null) {
|
||||
cm.setParentModel(allModels.get(cm.getParent()));
|
||||
}
|
||||
if (cm.getInterfaces() != null && !cm.getInterfaces().isEmpty()) {
|
||||
cm.setInterfaceModels(new ArrayList<CodegenModel>(cm.getInterfaces().size()));
|
||||
for (String intf : cm.getInterfaces()) {
|
||||
CodegenModel intfModel = allModels.get(intf);
|
||||
if (intfModel != null) {
|
||||
cm.getInterfaceModels().add(intfModel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cm.getInterfaces() != null && !cm.getInterfaces().isEmpty()) {
|
||||
cm.setInterfaceModels(new ArrayList<CodegenModel>(cm.getInterfaces().size()));
|
||||
for (String intf : cm.getInterfaces()) {
|
||||
CodegenModel intfModel = allModels.get(intf);
|
||||
if (intfModel != null) {
|
||||
cm.getInterfaceModels().add(intfModel);
|
||||
// Let parent know about all its children
|
||||
for (String name : allModels.keySet()) {
|
||||
CodegenModel cm = allModels.get(name);
|
||||
CodegenModel parent = allModels.get(cm.getParent());
|
||||
// if a discriminator exists on the parent, don't add this child to the inheritance hierarchy
|
||||
// TODO Determine what to do if the parent discriminator name == the grandparent discriminator name
|
||||
while (parent != null) {
|
||||
if (parent.getChildren() == null) {
|
||||
parent.setChildren(new ArrayList<CodegenModel>());
|
||||
}
|
||||
parent.getChildren().add(cm);
|
||||
parent.hasChildren = true;
|
||||
if (parent.getDiscriminator() == null) {
|
||||
parent = allModels.get(parent.getParent());
|
||||
} else {
|
||||
parent = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Let parent know about all its children
|
||||
for (String name : allModels.keySet()) {
|
||||
CodegenModel cm = allModels.get(name);
|
||||
CodegenModel parent = allModels.get(cm.getParent());
|
||||
// if a discriminator exists on the parent, don't add this child to the inheritance hierarchy
|
||||
// TODO Determine what to do if the parent discriminator name == the grandparent discriminator name
|
||||
while (parent != null) {
|
||||
if (parent.getChildren() == null) {
|
||||
parent.setChildren(new ArrayList<CodegenModel>());
|
||||
}
|
||||
parent.getChildren().add(cm);
|
||||
parent.hasChildren = true;
|
||||
if (parent.getDiscriminator() == null) {
|
||||
parent = allModels.get(parent.getParent());
|
||||
} else {
|
||||
parent = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// loop through properties of each model to detect self-reference
|
||||
for (Map.Entry<String, Object> entry : objs.entrySet()) {
|
||||
Map<String, Object> inner = (Map<String, Object>) entry.getValue();
|
||||
List<Map<String, Object>> models = (List<Map<String, Object>>) inner.get("models");
|
||||
for (Map<String, Object> mo : models) {
|
||||
CodegenModel cm = (CodegenModel) mo.get("model");
|
||||
for (CodegenProperty cp : cm.allVars) {
|
||||
// detect self import
|
||||
if (cp.dataType.equalsIgnoreCase(cm.classname) ||
|
||||
(cp.isContainer && cp.items.dataType.equalsIgnoreCase(cm.classname))) {
|
||||
cm.imports.remove(cm.classname); // remove self import
|
||||
cp.isSelfReference = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
@@ -349,30 +314,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
updateCodegenPropertyEnum(var);
|
||||
}
|
||||
|
||||
for (CodegenProperty var : cm.allVars) {
|
||||
updateCodegenPropertyEnum(var);
|
||||
}
|
||||
|
||||
for (CodegenProperty var : cm.requiredVars) {
|
||||
updateCodegenPropertyEnum(var);
|
||||
}
|
||||
|
||||
for (CodegenProperty var : cm.optionalVars) {
|
||||
updateCodegenPropertyEnum(var);
|
||||
}
|
||||
|
||||
for (CodegenProperty var : cm.parentVars) {
|
||||
updateCodegenPropertyEnum(var);
|
||||
}
|
||||
|
||||
for (CodegenProperty var : cm.readOnlyVars) {
|
||||
updateCodegenPropertyEnum(var);
|
||||
}
|
||||
|
||||
for (CodegenProperty var : cm.readWriteVars) {
|
||||
updateCodegenPropertyEnum(var);
|
||||
}
|
||||
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
@@ -562,12 +503,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
.replace("\"", "\\\""));
|
||||
}
|
||||
|
||||
// override with any special encoding and escaping logic
|
||||
@SuppressWarnings("static-method")
|
||||
public String encodePath(String input) {
|
||||
return escapeText(input);
|
||||
}
|
||||
|
||||
/**
|
||||
* override with any special text escaping logic to handle unsafe
|
||||
* characters so as to avoid code injection
|
||||
@@ -1382,53 +1317,64 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
ComposedSchema cs = (ComposedSchema) schema;
|
||||
List<Schema> schemas = ModelUtils.getInterfaces(cs);
|
||||
if (cs.getAllOf() != null) {
|
||||
List<String> names = new ArrayList<>();
|
||||
for (Schema s : schemas) {
|
||||
names.add(getSingleSchemaType(s));
|
||||
for (Schema s : cs.getAllOf()) {
|
||||
if (s != null) {
|
||||
//schema = s;
|
||||
}
|
||||
//LOGGER.info("ALL OF SCHEMA: {}", s);
|
||||
}
|
||||
|
||||
if (names.size() == 0) {
|
||||
LOGGER.error("allOf has no member defined: {}. Default to ERROR_ALLOF_SCHEMA", cs);
|
||||
return "ERROR_ALLOF_SCHEMA";
|
||||
} else if (names.size() == 1) {
|
||||
return names.get(0);
|
||||
} else {
|
||||
LOGGER.warn("allOf with multiple schemas defined. Using only the first one: {}. To fully utilize allOf, please use $ref instead of inline schema definition", names.get(0));
|
||||
return names.get(0);
|
||||
}
|
||||
LOGGER.info("Composed schema not yet supported: {}", cs);
|
||||
// get the model (allOf)
|
||||
return getAlias("UNKNOWN_COMPOSED_SCHMEA");
|
||||
} else if (cs.getAnyOf() != null) { // anyOf
|
||||
List<String> names = new ArrayList<>();
|
||||
List<String> names = new ArrayList<String>();
|
||||
for (Schema s : schemas) {
|
||||
names.add(getSingleSchemaType(s));
|
||||
if (StringUtils.isNotBlank(s.get$ref())) { // reference to another definition/schema
|
||||
String schemaName = ModelUtils.getSimpleRef(s.get$ref());
|
||||
if (StringUtils.isNotEmpty(schemaName)) {
|
||||
names.add(getAlias(schemaName));
|
||||
} else {
|
||||
LOGGER.warn("Error obtaining the datatype from ref:" + schema.get$ref() + ". Default to 'object'");
|
||||
return "object";
|
||||
}
|
||||
} else {
|
||||
// primitive type or model
|
||||
names.add(getAlias(getPrimitiveType(s)));
|
||||
}
|
||||
return "anyOf<" + String.join(",", names) + ">";
|
||||
}
|
||||
return "anyOf<" + String.join(",", names) + ">";
|
||||
} else if (cs.getOneOf() != null) { // oneOf
|
||||
List<String> names = new ArrayList<>();
|
||||
List<String> names = new ArrayList<String>();
|
||||
for (Schema s : schemas) {
|
||||
names.add(getSingleSchemaType(s));
|
||||
if (StringUtils.isNotBlank(s.get$ref())) { // reference to another definition/schema
|
||||
String schemaName = ModelUtils.getSimpleRef(s.get$ref());
|
||||
if (StringUtils.isNotEmpty(schemaName)) {
|
||||
names.add(getAlias(schemaName));
|
||||
} else {
|
||||
LOGGER.warn("Error obtaining the datatype from ref:" + schema.get$ref() + ". Default to 'object'");
|
||||
return "object";
|
||||
}
|
||||
} else {
|
||||
// primitive type or model
|
||||
names.add(getAlias(getPrimitiveType(s)));
|
||||
}
|
||||
return "oneOf<" + String.join(",", names) + ">";
|
||||
}
|
||||
return "oneOf<" + String.join(",", names) + ">";
|
||||
}
|
||||
}
|
||||
|
||||
return getSingleSchemaType(schema);
|
||||
|
||||
}
|
||||
|
||||
private String getSingleSchemaType(Schema schema) {
|
||||
Schema unaliasSchema = ModelUtils.unaliasSchema(globalSchemas, schema);
|
||||
|
||||
if (StringUtils.isNotBlank(unaliasSchema.get$ref())) { // reference to another definition/schema
|
||||
if (StringUtils.isNotBlank(schema.get$ref())) { // reference to another definition/schema
|
||||
// get the schema/model name from $ref
|
||||
String schemaName = ModelUtils.getSimpleRef(unaliasSchema.get$ref());
|
||||
String schemaName = ModelUtils.getSimpleRef(schema.get$ref());
|
||||
if (StringUtils.isNotEmpty(schemaName)) {
|
||||
return getAlias(schemaName);
|
||||
} else {
|
||||
LOGGER.warn("Error obtaining the datatype from ref:" + unaliasSchema.get$ref() + ". Default to 'object'");
|
||||
LOGGER.warn("Error obtaining the datatype from ref:" + schema.get$ref() + ". Default to 'object'");
|
||||
return "object";
|
||||
}
|
||||
} else { // primitive type or model
|
||||
return getAlias(getPrimitiveType(unaliasSchema));
|
||||
return getAlias(getPrimitiveType(schema));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1672,7 +1618,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
|
||||
// parent model
|
||||
final String parentName = ModelUtils.getParentName(composed, allDefinitions);
|
||||
final List<String> allParents = ModelUtils.getAllParentsName(composed, allDefinitions);
|
||||
final Schema parent = StringUtils.isBlank(parentName) || allDefinitions == null ? null : allDefinitions.get(parentName);
|
||||
final boolean hasParent = StringUtils.isNotBlank(parentName);
|
||||
|
||||
@@ -1721,16 +1666,19 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
m.interfaces.add(modelName);
|
||||
addImport(m, modelName);
|
||||
if (allDefinitions != null && refSchema != null) {
|
||||
if (allParents.contains(modelName) && supportsMultipleInheritance) {
|
||||
// multiple inheritance
|
||||
addProperties(allProperties, allRequired, refSchema, allDefinitions);
|
||||
} else if (parentName != null && parentName.equals(modelName) && supportsInheritance) {
|
||||
// single inheritance
|
||||
addProperties(allProperties, allRequired, refSchema, allDefinitions);
|
||||
} else {
|
||||
// composition
|
||||
if (hasParent || supportsInheritance) {
|
||||
if (supportsInheritance || parentName.equals(modelName)) {
|
||||
// inheritance
|
||||
addProperties(allProperties, allRequired, refSchema, allDefinitions);
|
||||
} else {
|
||||
// composition
|
||||
//LOGGER.debug("Parent {} not set to model name {}", parentName, modelName);
|
||||
addProperties(properties, required, refSchema, allDefinitions);
|
||||
}
|
||||
} else if (!supportsMixins && !supportsInheritance) {
|
||||
addProperties(properties, required, refSchema, allDefinitions);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (composed.getAnyOf() != null) {
|
||||
@@ -1748,16 +1696,13 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (parent != null) {
|
||||
m.parentSchema = parentName;
|
||||
m.parent = toModelName(parentName);
|
||||
|
||||
if (supportsMultipleInheritance) {
|
||||
m.allParents = new ArrayList<String>();
|
||||
for (String pname : allParents) {
|
||||
String pModelName = toModelName(pname);
|
||||
m.allParents.add(pModelName);
|
||||
addImport(m, pModelName);
|
||||
addImport(m, m.parent);
|
||||
if (allDefinitions != null && !allDefinitions.isEmpty()) {
|
||||
if (hasParent || supportsInheritance) {
|
||||
addProperties(allProperties, allRequired, parent, allDefinitions);
|
||||
} else {
|
||||
addProperties(properties, required, parent, allDefinitions);
|
||||
}
|
||||
} else { // single inheritance
|
||||
addImport(m, m.parent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1768,14 +1713,15 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// component is the child schema
|
||||
addProperties(properties, required, component, allDefinitions);
|
||||
|
||||
// includes child's properties (all, required) in allProperties, allRequired
|
||||
addProperties(allProperties, allRequired, component, allDefinitions);
|
||||
if (hasParent || supportsInheritance) {
|
||||
addProperties(allProperties, allRequired, component, allDefinitions);
|
||||
}
|
||||
}
|
||||
break; // at most one child only
|
||||
break; // at most one schema not using $ref
|
||||
}
|
||||
}
|
||||
|
||||
addVars(m, unaliasPropertySchema(allDefinitions, properties), required, unaliasPropertySchema(allDefinitions, allProperties), allRequired);
|
||||
addVars(m, unaliasPropertySchema(allDefinitions, properties), required, allProperties, allRequired);
|
||||
|
||||
// end of code block for composed schema
|
||||
} else {
|
||||
@@ -1799,8 +1745,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
m.isString = Boolean.TRUE;
|
||||
}
|
||||
|
||||
// passing null to allProperties and allRequired as there's no parent
|
||||
addVars(m, unaliasPropertySchema(allDefinitions, schema.getProperties()), schema.getRequired(), null, null);
|
||||
addVars(m, unaliasPropertySchema(allDefinitions, schema.getProperties()), schema.getRequired());
|
||||
}
|
||||
|
||||
// remove duplicated properties
|
||||
@@ -1822,7 +1767,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return null;
|
||||
}
|
||||
CodegenDiscriminator discriminator = new CodegenDiscriminator();
|
||||
discriminator.setPropertyName(toVarName(schema.getDiscriminator().getPropertyName()));
|
||||
discriminator.setPropertyName(schema.getDiscriminator().getPropertyName());
|
||||
discriminator.setMapping(schema.getDiscriminator().getMapping());
|
||||
if (schema.getDiscriminator().getMapping() != null && !schema.getDiscriminator().getMapping().isEmpty()) {
|
||||
for (Entry<String, String> e : schema.getDiscriminator().getMapping().entrySet()) {
|
||||
@@ -1852,19 +1797,9 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
addParentContainer(codegenModel, codegenModel.name, schema);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add schema's properties to "properties" and "required" list
|
||||
*
|
||||
* @param properties all properties
|
||||
* @param required required property only
|
||||
* @param schema schema in which the properties will be added to the lists
|
||||
* @param allSchemas all schemas
|
||||
*/
|
||||
protected void addProperties(Map<String, Schema> properties, List<String> required, Schema
|
||||
schema, Map<String, Schema> allSchemas) {
|
||||
if (schema instanceof ComposedSchema) {
|
||||
throw new RuntimeException("Please report the issue: Cannot process Composed Schema in addProperties: " + schema);
|
||||
/*
|
||||
ComposedSchema composedSchema = (ComposedSchema) schema;
|
||||
if (composedSchema.getAllOf() == null) {
|
||||
return;
|
||||
@@ -1874,11 +1809,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
addProperties(properties, required, component, allSchemas);
|
||||
}
|
||||
return;
|
||||
*/
|
||||
}
|
||||
|
||||
Schema unaliasSchema = ModelUtils.unaliasSchema(globalSchemas, schema);
|
||||
|
||||
if (StringUtils.isNotBlank(schema.get$ref())) {
|
||||
Schema interfaceSchema = allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref()));
|
||||
addProperties(properties, required, interfaceSchema, allSchemas);
|
||||
@@ -2115,8 +2047,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
allowableValues.put("values", _enum);
|
||||
property.allowableValues = allowableValues;
|
||||
}
|
||||
} else if (ModelUtils.isFreeFormObject(p)){
|
||||
property.isFreeFormObject = true;
|
||||
}
|
||||
|
||||
property.dataType = getTypeDeclaration(p);
|
||||
@@ -2330,13 +2260,11 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (property.defaultValue != null) {
|
||||
property.defaultValue = property.defaultValue.replace(", " + property.items.baseType, ", " + toEnumName(property.items));
|
||||
}
|
||||
|
||||
updateCodegenPropertyEnum(property);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setNonArrayMapProperty(CodegenProperty property, String type) {
|
||||
property.isContainer = false;
|
||||
property.isNotContainer = true;
|
||||
if (languageSpecificPrimitives().contains(type)) {
|
||||
property.isPrimitiveType = true;
|
||||
} else {
|
||||
@@ -2910,7 +2838,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
codegenParameter.jsonSchema = Json.pretty(parameter);
|
||||
|
||||
if (GeneratorProperties.getProperty("debugParser") != null) {
|
||||
if (System.getProperty("debugParser") != null) {
|
||||
LOGGER.info("working on Parameter " + parameter.getName());
|
||||
LOGGER.info("JSON schema: " + codegenParameter.jsonSchema);
|
||||
}
|
||||
@@ -2920,7 +2848,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
if (parameter.getSchema() != null) {
|
||||
Schema parameterSchema = ModelUtils.unaliasSchema(globalSchemas, parameter.getSchema());
|
||||
Schema parameterSchema = parameter.getSchema();
|
||||
if (parameterSchema == null) {
|
||||
LOGGER.warn("warning! Schema not found for parameter \"" + parameter.getName() + "\", using String");
|
||||
parameterSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to missing type definition.");
|
||||
@@ -2994,6 +2922,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
// set boolean flag (e.g. isString)
|
||||
setParameterBooleanFlagWithCodegenProperty(codegenParameter, codegenProperty);
|
||||
|
||||
|
||||
String parameterDataType = this.getParameterDataType(parameter, parameterSchema);
|
||||
if (parameterDataType != null) {
|
||||
codegenParameter.dataType = parameterDataType;
|
||||
@@ -3496,69 +3425,49 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return properties;
|
||||
}
|
||||
|
||||
private void addVars(CodegenModel model, Map<String, Schema> properties, List<String> required) {
|
||||
addVars(model, properties, required, null, null);
|
||||
}
|
||||
|
||||
private void addVars(CodegenModel m, Map<String, Schema> properties, List<String> required,
|
||||
Map<String, Schema> allProperties, List<String> allRequired) {
|
||||
|
||||
m.hasRequired = false;
|
||||
if (properties != null && !properties.isEmpty()) {
|
||||
m.hasVars = true;
|
||||
m.hasEnums = false; // TODO need to fix as its false in both cases
|
||||
m.hasEnums = false;
|
||||
|
||||
Set<String> mandatory = required == null ? Collections.<String>emptySet()
|
||||
: new TreeSet<String>(required);
|
||||
|
||||
// update "vars" without parent's properties (all, required)
|
||||
addVars(m, m.vars, properties, mandatory);
|
||||
m.allMandatory = m.mandatory = mandatory;
|
||||
} else {
|
||||
m.emptyVars = true;
|
||||
m.hasVars = false;
|
||||
m.hasEnums = false; // TODO need to fix as its false in both cases
|
||||
m.hasEnums = false;
|
||||
}
|
||||
|
||||
if (allProperties != null) {
|
||||
Set<String> allMandatory = allRequired == null ? Collections.<String>emptySet()
|
||||
: new TreeSet<String>(allRequired);
|
||||
// update "vars" with parent's properties (all, required)
|
||||
addVars(m, m.allVars, allProperties, allMandatory);
|
||||
m.allMandatory = allMandatory;
|
||||
} else { // without parent, allVars and vars are the same
|
||||
m.allVars = m.vars;
|
||||
m.allMandatory = m.mandatory;
|
||||
}
|
||||
|
||||
// loop through list to update property name with toVarName
|
||||
Set<String> renamedMandatory = new TreeSet<String>();
|
||||
Iterator<String> mandatoryIterator = m.mandatory.iterator();
|
||||
while (mandatoryIterator.hasNext()) {
|
||||
renamedMandatory.add(toVarName(mandatoryIterator.next()));
|
||||
}
|
||||
m.mandatory = renamedMandatory;
|
||||
|
||||
Set<String> renamedAllMandatory = new TreeSet<String>();
|
||||
Iterator<String> allMandatoryIterator = m.allMandatory.iterator();
|
||||
while (allMandatoryIterator.hasNext()) {
|
||||
renamedAllMandatory.add(toVarName(allMandatoryIterator.next()));
|
||||
}
|
||||
m.allMandatory = renamedAllMandatory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add variables (properties) to codegen model (list of properties, various flags, etc)
|
||||
*
|
||||
* @param m Codegen model
|
||||
* @param vars list of codegen properties (e.g. vars, allVars) to be updated with the new properties
|
||||
* @param properties a map of properties (schema)
|
||||
* @param mandatory a set of required properties' name
|
||||
*/
|
||||
private void addVars(CodegenModel m, List<CodegenProperty> vars, Map<String, Schema> properties, Set<String> mandatory) {
|
||||
for (Map.Entry<String, Schema> entry : properties.entrySet()) {
|
||||
private void addVars(CodegenModel
|
||||
m, List<CodegenProperty> vars, Map<String, Schema> properties, Set<String> mandatory) {
|
||||
// convert set to list so that we can access the next entry in the loop
|
||||
List<Map.Entry<String, Schema>> propertyList = new ArrayList<Map.Entry<String, Schema>>(properties.entrySet());
|
||||
final int totalCount = propertyList.size();
|
||||
for (int i = 0; i < totalCount; i++) {
|
||||
Map.Entry<String, Schema> entry = propertyList.get(i);
|
||||
|
||||
final String key = entry.getKey();
|
||||
final Schema prop = entry.getValue();
|
||||
|
||||
if (prop == null) {
|
||||
LOGGER.warn("Please report the issue. There shouldn't be null property for " + key);
|
||||
LOGGER.warn("null property for " + key);
|
||||
} else {
|
||||
final CodegenProperty cp = fromProperty(key, prop);
|
||||
cp.required = mandatory.contains(key);
|
||||
@@ -3575,7 +3484,14 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
m.hasOnlyReadOnly = false;
|
||||
}
|
||||
|
||||
// TODO revise the logic to include map
|
||||
if (i + 1 != totalCount) {
|
||||
cp.hasMore = true;
|
||||
// check the next entry to see if it's read only
|
||||
if (!Boolean.TRUE.equals(propertyList.get(i + 1).getValue().getReadOnly())) {
|
||||
cp.hasMoreNonReadOnly = true; // next entry is not ready only
|
||||
}
|
||||
}
|
||||
|
||||
if (cp.isContainer) {
|
||||
addImport(m, typeMapping.get("array"));
|
||||
}
|
||||
@@ -3599,7 +3515,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
if (Boolean.TRUE.equals(cp.isReadOnly)) {
|
||||
m.readOnlyVars.add(cp);
|
||||
} else { // else add to readWriteVars (list of properties)
|
||||
// duplicated properties will be removed by removeAllDuplicatedProperty later
|
||||
// FIXME: readWriteVars can contain duplicated properties. Debug/breakpoint here while running C# generator (Dog and Cat models)
|
||||
m.readWriteVars.add(cp);
|
||||
}
|
||||
}
|
||||
@@ -4079,8 +3995,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
enumVars.add(enumVar);
|
||||
}
|
||||
// if "x-enum-varnames" defined, update varnames
|
||||
Map<String, Object> extensions = var.mostInnerItems != null ? var.mostInnerItems.getVendorExtensions() : var.getVendorExtensions();
|
||||
updateEnumVarsWithExtensions(enumVars, extensions);
|
||||
updateEnumVarsWithExtensions(enumVars, var.getVendorExtensions());
|
||||
allowableValues.put("enumVars", enumVars);
|
||||
|
||||
// handle default value for enum, e.g. available => StatusEnum.AVAILABLE
|
||||
@@ -4636,25 +4551,6 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
codegenProperty = codegenProperty.items;
|
||||
}
|
||||
|
||||
} else if (ModelUtils.isFreeFormObject(schema)) {
|
||||
// HTTP request body is free form object
|
||||
CodegenProperty codegenProperty = fromProperty("FREE_FORM_REQUEST_BODY", schema);
|
||||
if (codegenProperty != null) {
|
||||
if (StringUtils.isEmpty(bodyParameterName)) {
|
||||
codegenParameter.baseName = "body"; // default to body
|
||||
} else {
|
||||
codegenParameter.baseName = bodyParameterName;
|
||||
}
|
||||
codegenParameter.isPrimitiveType = true;
|
||||
codegenParameter.baseType = codegenProperty.baseType;
|
||||
codegenParameter.dataType = codegenProperty.dataType;
|
||||
codegenParameter.description = codegenProperty.description;
|
||||
codegenParameter.paramName = toParamName(codegenParameter.baseName);
|
||||
}
|
||||
setParameterBooleanFlagWithCodegenProperty(codegenParameter, codegenProperty);
|
||||
// set nullable
|
||||
setParameterNullable(codegenParameter, codegenProperty);
|
||||
|
||||
} else if (ModelUtils.isObjectSchema(schema) || ModelUtils.isComposedSchema(schema)) {
|
||||
CodegenModel codegenModel = null;
|
||||
if (StringUtils.isNotBlank(name)) {
|
||||
|
||||
@@ -37,7 +37,6 @@ import io.swagger.v3.oas.models.tags.Tag;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.config.GeneratorProperties;
|
||||
import org.openapitools.codegen.ignore.CodegenIgnoreProcessor;
|
||||
import org.openapitools.codegen.utils.ImplementationVersion;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
@@ -130,9 +129,9 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
private void configureGeneratorProperties() {
|
||||
// allows generating only models by specifying a CSV of models to generate, or empty for all
|
||||
// NOTE: Boolean.TRUE is required below rather than `true` because of JVM boxing constraints and type inference.
|
||||
generateApis = GeneratorProperties.getProperty(CodegenConstants.APIS) != null ? Boolean.TRUE : getGeneratorPropertyDefaultSwitch(CodegenConstants.APIS, null);
|
||||
generateModels = GeneratorProperties.getProperty(CodegenConstants.MODELS) != null ? Boolean.TRUE : getGeneratorPropertyDefaultSwitch(CodegenConstants.MODELS, null);
|
||||
generateSupportingFiles = GeneratorProperties.getProperty(CodegenConstants.SUPPORTING_FILES) != null ? Boolean.TRUE : getGeneratorPropertyDefaultSwitch(CodegenConstants.SUPPORTING_FILES, null);
|
||||
generateApis = System.getProperty(CodegenConstants.APIS) != null ? Boolean.TRUE : getGeneratorPropertyDefaultSwitch(CodegenConstants.APIS, null);
|
||||
generateModels = System.getProperty(CodegenConstants.MODELS) != null ? Boolean.TRUE : getGeneratorPropertyDefaultSwitch(CodegenConstants.MODELS, null);
|
||||
generateSupportingFiles = System.getProperty(CodegenConstants.SUPPORTING_FILES) != null ? Boolean.TRUE : getGeneratorPropertyDefaultSwitch(CodegenConstants.SUPPORTING_FILES, null);
|
||||
|
||||
if (generateApis == null && generateModels == null && generateSupportingFiles == null) {
|
||||
// no specifics are set, generate everything
|
||||
@@ -150,10 +149,10 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
}
|
||||
// model/api tests and documentation options rely on parent generate options (api or model) and no other options.
|
||||
// They default to true in all scenarios and can only be marked false explicitly
|
||||
generateModelTests = GeneratorProperties.getProperty(CodegenConstants.MODEL_TESTS) != null ? Boolean.valueOf(GeneratorProperties.getProperty(CodegenConstants.MODEL_TESTS)) : getGeneratorPropertyDefaultSwitch(CodegenConstants.MODEL_TESTS, true);
|
||||
generateModelDocumentation = GeneratorProperties.getProperty(CodegenConstants.MODEL_DOCS) != null ? Boolean.valueOf(GeneratorProperties.getProperty(CodegenConstants.MODEL_DOCS)) : getGeneratorPropertyDefaultSwitch(CodegenConstants.MODEL_DOCS, true);
|
||||
generateApiTests = GeneratorProperties.getProperty(CodegenConstants.API_TESTS) != null ? Boolean.valueOf(GeneratorProperties.getProperty(CodegenConstants.API_TESTS)) : getGeneratorPropertyDefaultSwitch(CodegenConstants.API_TESTS, true);
|
||||
generateApiDocumentation = GeneratorProperties.getProperty(CodegenConstants.API_DOCS) != null ? Boolean.valueOf(GeneratorProperties.getProperty(CodegenConstants.API_DOCS)) : getGeneratorPropertyDefaultSwitch(CodegenConstants.API_DOCS, true);
|
||||
generateModelTests = System.getProperty(CodegenConstants.MODEL_TESTS) != null ? Boolean.valueOf(System.getProperty(CodegenConstants.MODEL_TESTS)) : getGeneratorPropertyDefaultSwitch(CodegenConstants.MODEL_TESTS, true);
|
||||
generateModelDocumentation = System.getProperty(CodegenConstants.MODEL_DOCS) != null ? Boolean.valueOf(System.getProperty(CodegenConstants.MODEL_DOCS)) : getGeneratorPropertyDefaultSwitch(CodegenConstants.MODEL_DOCS, true);
|
||||
generateApiTests = System.getProperty(CodegenConstants.API_TESTS) != null ? Boolean.valueOf(System.getProperty(CodegenConstants.API_TESTS)) : getGeneratorPropertyDefaultSwitch(CodegenConstants.API_TESTS, true);
|
||||
generateApiDocumentation = System.getProperty(CodegenConstants.API_DOCS) != null ? Boolean.valueOf(System.getProperty(CodegenConstants.API_DOCS)) : getGeneratorPropertyDefaultSwitch(CodegenConstants.API_DOCS, true);
|
||||
|
||||
|
||||
// Additional properties added for tests to exclude references in project related files
|
||||
@@ -170,9 +169,9 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
config.additionalProperties().put(CodegenConstants.EXCLUDE_TESTS, true);
|
||||
}
|
||||
|
||||
if (GeneratorProperties.getProperty("debugOpenAPI") != null) {
|
||||
if (System.getProperty("debugOpenAPI") != null) {
|
||||
Json.prettyPrint(openAPI);
|
||||
} else if (GeneratorProperties.getProperty("debugSwagger") != null) {
|
||||
} else if (System.getProperty("debugSwagger") != null) {
|
||||
// This exists for backward compatibility
|
||||
// We fall to this block only if debugOpenAPI is null. No need to dump this twice.
|
||||
LOGGER.info("Please use system property 'debugOpenAPI' instead of 'debugSwagger'.");
|
||||
@@ -331,7 +330,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
return;
|
||||
}
|
||||
|
||||
String modelNames = GeneratorProperties.getProperty("models");
|
||||
String modelNames = System.getProperty("models");
|
||||
Set<String> modelsToGenerate = null;
|
||||
if (modelNames != null && !modelNames.isEmpty()) {
|
||||
modelsToGenerate = new HashSet<String>(Arrays.asList(modelNames.split(",")));
|
||||
@@ -404,8 +403,8 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
} */
|
||||
});
|
||||
|
||||
Boolean skipFormModel = GeneratorProperties.getProperty(CodegenConstants.SKIP_FORM_MODEL) != null ?
|
||||
Boolean.valueOf(GeneratorProperties.getProperty(CodegenConstants.SKIP_FORM_MODEL)) :
|
||||
Boolean skipFormModel = System.getProperty(CodegenConstants.SKIP_FORM_MODEL) != null ?
|
||||
Boolean.valueOf(System.getProperty(CodegenConstants.SKIP_FORM_MODEL)) :
|
||||
getGeneratorPropertyDefaultSwitch(CodegenConstants.SKIP_FORM_MODEL, false);
|
||||
|
||||
// process models only
|
||||
@@ -430,17 +429,18 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
|
||||
Schema schema = schemas.get(name);
|
||||
|
||||
if (ModelUtils.isFreeFormObject(schema)) { // check to see if it'a a free-form object
|
||||
LOGGER.info("Model " + name + " not generated since it's a free-form object");
|
||||
continue;
|
||||
} else if (ModelUtils.isMapSchema(schema)) { // check to see if it's a "map" model
|
||||
if (!ModelUtils.isGenerateAliasAsModel() && (schema.getProperties() == null || schema.getProperties().isEmpty())) {
|
||||
// check to see if it's a "map" model
|
||||
if (ModelUtils.isMapSchema(schema)) {
|
||||
if (schema.getProperties() == null || schema.getProperties().isEmpty()) {
|
||||
// schema without property, i.e. alias to map
|
||||
LOGGER.info("Model " + name + " not generated since it's an alias to map (without property)");
|
||||
continue;
|
||||
}
|
||||
} else if (ModelUtils.isArraySchema(schema)) { // check to see if it's an "array" model
|
||||
if (!ModelUtils.isGenerateAliasAsModel() && (schema.getProperties() == null || schema.getProperties().isEmpty())) {
|
||||
}
|
||||
|
||||
// check to see if it's an "array" model
|
||||
if (ModelUtils.isArraySchema(schema)) {
|
||||
if (schema.getProperties() == null || schema.getProperties().isEmpty()) {
|
||||
// schema without property, i.e. alias to array
|
||||
LOGGER.info("Model " + name + " not generated since it's an alias to array (without property)");
|
||||
continue;
|
||||
@@ -458,9 +458,6 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
}
|
||||
}
|
||||
|
||||
// loop through all models to update children models, isSelfReference, isCircularReference, etc
|
||||
allProcessedModels = config.updateAllModels(allProcessedModels);
|
||||
|
||||
// post process all processed models
|
||||
allProcessedModels = config.postProcessAllModels(allProcessedModels);
|
||||
|
||||
@@ -474,7 +471,6 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
continue;
|
||||
}
|
||||
|
||||
// TODO revise below as we've already performed unaliasing so that the isAlias check may be removed
|
||||
Map<String, Object> modelTemplate = (Map<String, Object>) ((List<Object>) models.get("models")).get(0);
|
||||
// Special handling of aliases only applies to Java
|
||||
if (modelTemplate != null && modelTemplate.containsKey("model")) {
|
||||
@@ -501,7 +497,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
throw new RuntimeException("Could not generate model '" + modelName + "'", e);
|
||||
}
|
||||
}
|
||||
if (GeneratorProperties.getProperty("debugModels") != null) {
|
||||
if (System.getProperty("debugModels") != null) {
|
||||
LOGGER.info("############ Model info ############");
|
||||
Json.prettyPrint(allModels);
|
||||
}
|
||||
@@ -514,7 +510,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
}
|
||||
Map<String, List<CodegenOperation>> paths = processPaths(this.openAPI.getPaths());
|
||||
Set<String> apisToGenerate = null;
|
||||
String apiNames = GeneratorProperties.getProperty("apis");
|
||||
String apiNames = System.getProperty("apis");
|
||||
if (apiNames != null && !apiNames.isEmpty()) {
|
||||
apisToGenerate = new HashSet<String>(Arrays.asList(apiNames.split(",")));
|
||||
}
|
||||
@@ -537,9 +533,9 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
}
|
||||
});
|
||||
Map<String, Object> operation = processOperations(config, tag, ops, allModels);
|
||||
URL url = URLPathUtils.getServerURL(openAPI);
|
||||
|
||||
operation.put("basePath", basePath);
|
||||
operation.put("basePathWithoutHost", config.encodePath(url.getPath()).replaceAll("/$", ""));
|
||||
operation.put("basePathWithoutHost", basePathWithoutHost);
|
||||
operation.put("contextPath", contextPath);
|
||||
operation.put("baseName", tag);
|
||||
operation.put("apiPackage", config.apiPackage());
|
||||
@@ -568,7 +564,8 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
@SuppressWarnings("unchecked")
|
||||
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");
|
||||
for (CodegenOperation op : operations) {
|
||||
if (isGroupParameters && !op.vendorExtensions.containsKey("x-group-parameters")) {
|
||||
op.httpMethod = op.httpMethod.toLowerCase(Locale.ROOT);
|
||||
if (!op.vendorExtensions.containsKey("x-group-parameters")) {
|
||||
op.vendorExtensions.put("x-group-parameters", Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
@@ -654,7 +651,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
throw new RuntimeException("Could not generate api file for '" + tag + "'", e);
|
||||
}
|
||||
}
|
||||
if (GeneratorProperties.getProperty("debugOperations") != null) {
|
||||
if (System.getProperty("debugOperations") != null) {
|
||||
LOGGER.info("############ Operation info ############");
|
||||
Json.prettyPrint(allOperations);
|
||||
}
|
||||
@@ -666,7 +663,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
return;
|
||||
}
|
||||
Set<String> supportingFilesToGenerate = null;
|
||||
String supportingFiles = GeneratorProperties.getProperty(CodegenConstants.SUPPORTING_FILES);
|
||||
String supportingFiles = System.getProperty(CodegenConstants.SUPPORTING_FILES);
|
||||
if (supportingFiles != null && !supportingFiles.isEmpty()) {
|
||||
supportingFilesToGenerate = new HashSet<String>(Arrays.asList(supportingFiles.split(",")));
|
||||
}
|
||||
@@ -859,7 +856,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
|
||||
config.postProcessSupportingFileData(bundle);
|
||||
|
||||
if (GeneratorProperties.getProperty("debugSupportingFiles") != null) {
|
||||
if (System.getProperty("debugSupportingFiles") != null) {
|
||||
LOGGER.info("############ Supporting file info ############");
|
||||
Json.prettyPrint(bundle);
|
||||
}
|
||||
@@ -877,13 +874,13 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
throw new RuntimeException("missing config!");
|
||||
}
|
||||
|
||||
configureGeneratorProperties();
|
||||
configureOpenAPIInfo();
|
||||
|
||||
// resolve inline models
|
||||
InlineModelResolver inlineModelResolver = new InlineModelResolver();
|
||||
inlineModelResolver.flatten(openAPI);
|
||||
|
||||
configureGeneratorProperties();
|
||||
configureOpenAPIInfo();
|
||||
|
||||
List<File> files = new ArrayList<File>();
|
||||
// models
|
||||
List<String> filteredSchemas = ModelUtils.getSchemasUsedOnlyInFormParam(openAPI);
|
||||
@@ -897,10 +894,6 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
Map<String, Object> bundle = buildSupportFileBundle(allOperations, allModels);
|
||||
generateSupportingFiles(files, bundle);
|
||||
config.processOpenAPI(openAPI);
|
||||
|
||||
// reset GeneratorProperties, so that the running thread can be reused for another generator-run
|
||||
GeneratorProperties.reset();
|
||||
|
||||
return files;
|
||||
}
|
||||
|
||||
@@ -950,7 +943,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
return;
|
||||
}
|
||||
|
||||
if (GeneratorProperties.getProperty("debugOperations") != null) {
|
||||
if (System.getProperty("debugOperations") != null) {
|
||||
LOGGER.info("processOperation: resourcePath= " + resourcePath + "\t;" + httpMethod + " " + operation + "\n");
|
||||
}
|
||||
|
||||
@@ -1136,8 +1129,6 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
mo.put("importPath", config.toModelImport(cm.classname));
|
||||
models.add(mo);
|
||||
|
||||
cm.removeSelfReferenceImport();
|
||||
|
||||
allImports.addAll(cm.imports);
|
||||
}
|
||||
objs.put("models", models);
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
|
||||
package org.openapitools.codegen;
|
||||
|
||||
import io.swagger.v3.oas.models.Components;
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
@@ -28,6 +27,7 @@ import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.PathItem;
|
||||
import io.swagger.v3.oas.models.parameters.Parameter;
|
||||
import io.swagger.v3.oas.models.parameters.RequestBody;
|
||||
import io.swagger.v3.oas.models.Paths;
|
||||
import io.swagger.v3.core.util.Json;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
@@ -42,15 +42,16 @@ import io.swagger.v3.oas.models.media.XML;
|
||||
|
||||
public class InlineModelResolver {
|
||||
private OpenAPI openapi;
|
||||
private Map<String, Schema> addedModels = new HashMap<String, Schema>();
|
||||
private Map<String, String> generatedSignature = new HashMap<String, String>();
|
||||
private boolean skipMatches;
|
||||
static Logger LOGGER = LoggerFactory.getLogger(InlineModelResolver.class);
|
||||
Map<String, Schema> addedModels = new HashMap<String, Schema>();
|
||||
Map<String, String> generatedSignature = new HashMap<String, String>();
|
||||
|
||||
void flatten(OpenAPI openapi) {
|
||||
public void flatten(OpenAPI openapi) {
|
||||
this.openapi = openapi;
|
||||
|
||||
if (openapi.getComponents() == null) {
|
||||
openapi.setComponents(new Components());
|
||||
return; // There's nothing here
|
||||
}
|
||||
|
||||
if (openapi.getComponents().getSchemas() == null) {
|
||||
@@ -340,7 +341,10 @@ public class InlineModelResolver {
|
||||
}
|
||||
}
|
||||
|
||||
private String matchGenerated(Schema model) {
|
||||
public String matchGenerated(Schema model) {
|
||||
if (this.skipMatches) {
|
||||
return null;
|
||||
}
|
||||
String json = Json.pretty(model);
|
||||
if (generatedSignature.containsKey(json)) {
|
||||
return generatedSignature.get(json);
|
||||
@@ -348,11 +352,11 @@ public class InlineModelResolver {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void addGenerated(String name, Schema model) {
|
||||
public void addGenerated(String name, Schema model) {
|
||||
generatedSignature.put(Json.pretty(model), name);
|
||||
}
|
||||
|
||||
private String uniqueName(String key) {
|
||||
public String uniqueName(String key) {
|
||||
if (key == null) {
|
||||
key = "NULL_UNIQUE_NAME";
|
||||
LOGGER.warn("null key found. Default to NULL_UNIQUE_NAME");
|
||||
@@ -376,7 +380,7 @@ public class InlineModelResolver {
|
||||
return key;
|
||||
}
|
||||
|
||||
private void flattenProperties(Map<String, Schema> properties, String path) {
|
||||
public void flattenProperties(Map<String, Schema> properties, String path) {
|
||||
if (properties == null) {
|
||||
return;
|
||||
}
|
||||
@@ -461,7 +465,28 @@ public class InlineModelResolver {
|
||||
}
|
||||
}
|
||||
|
||||
private Schema modelFromProperty(ObjectSchema object, String path) {
|
||||
@SuppressWarnings("static-method")
|
||||
public Schema modelFromProperty(ArraySchema object, @SuppressWarnings("unused") String path) {
|
||||
String description = object.getDescription();
|
||||
String example = null;
|
||||
Object obj = object.getExample();
|
||||
|
||||
if (obj != null) {
|
||||
example = obj.toString();
|
||||
}
|
||||
Schema inner = object.getItems();
|
||||
if (inner instanceof ObjectSchema) {
|
||||
ArraySchema model = new ArraySchema();
|
||||
model.setDescription(description);
|
||||
model.setExample(example);
|
||||
model.setItems(object.getItems());
|
||||
model.setName(object.getName());
|
||||
return model;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Schema modelFromProperty(ObjectSchema object, String path) {
|
||||
String description = object.getDescription();
|
||||
String example = null;
|
||||
Object obj = object.getExample();
|
||||
@@ -483,6 +508,22 @@ public class InlineModelResolver {
|
||||
return model;
|
||||
}
|
||||
|
||||
@SuppressWarnings("static-method")
|
||||
public Schema modelFromProperty(MapSchema object, @SuppressWarnings("unused") String path) {
|
||||
String description = object.getDescription();
|
||||
String example = null;
|
||||
Object obj = object.getExample();
|
||||
if (obj != null) {
|
||||
example = obj.toString();
|
||||
}
|
||||
ArraySchema model = new ArraySchema();
|
||||
model.setDescription(description);
|
||||
model.setName(object.getName());
|
||||
model.setExample(example);
|
||||
model.setItems(ModelUtils.getAdditionalProperties(object));
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a Schema
|
||||
*
|
||||
@@ -490,7 +531,7 @@ public class InlineModelResolver {
|
||||
* @param property Schema
|
||||
* @return {@link Schema} A constructed OpenAPI property
|
||||
*/
|
||||
private Schema makeSchema(String ref, Schema property) {
|
||||
public Schema makeSchema(String ref, Schema property) {
|
||||
Schema newProperty = new Schema().$ref(ref);
|
||||
this.copyVendorExtensions(property, newProperty);
|
||||
return newProperty;
|
||||
@@ -503,7 +544,7 @@ public class InlineModelResolver {
|
||||
* @param target target property
|
||||
*/
|
||||
|
||||
private void copyVendorExtensions(Schema source, Schema target) {
|
||||
public void copyVendorExtensions(Schema source, Schema target) {
|
||||
Map<String, Object> vendorExtensions = source.getExtensions();
|
||||
if (vendorExtensions == null) {
|
||||
return;
|
||||
@@ -512,4 +553,12 @@ public class InlineModelResolver {
|
||||
target.addExtension(extName, vendorExtensions.get(extName));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSkipMatches() {
|
||||
return skipMatches;
|
||||
}
|
||||
|
||||
public void setSkipMatches(boolean skipMatches) {
|
||||
this.skipMatches = skipMatches;
|
||||
}
|
||||
}
|
||||
@@ -220,15 +220,6 @@ public class CodegenConfigurator implements Serializable {
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isGenerateAliasAsModel() {
|
||||
return ModelUtils.isGenerateAliasAsModel();
|
||||
}
|
||||
|
||||
public CodegenConfigurator setGenerateAliasAsModel(boolean generateAliasAsModel) {
|
||||
ModelUtils.setGenerateAliasAsModel(generateAliasAsModel);
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getModelNameSuffix() {
|
||||
return modelNameSuffix;
|
||||
}
|
||||
@@ -638,15 +629,15 @@ public class CodegenConfigurator implements Serializable {
|
||||
"\n - [debugOperations] prints operations passed to the template engine" +
|
||||
"\n - [debugSupportingFiles] prints additional data passed to the template engine");
|
||||
|
||||
GeneratorProperties.setProperty("debugOpenAPI", "");
|
||||
GeneratorProperties.setProperty("debugModels", "");
|
||||
GeneratorProperties.setProperty("debugOperations", "");
|
||||
GeneratorProperties.setProperty("debugSupportingFiles", "");
|
||||
System.setProperty("debugOpenAPI", "");
|
||||
System.setProperty("debugModels", "");
|
||||
System.setProperty("debugOperations", "");
|
||||
System.setProperty("debugSupportingFiles", "");
|
||||
}
|
||||
|
||||
private void setSystemProperties() {
|
||||
for (Map.Entry<String, String> entry : systemProperties.entrySet()) {
|
||||
GeneratorProperties.setProperty(entry.getKey(), entry.getValue());
|
||||
System.setProperty(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.config;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* GeneratorProperties encapsulates SystemProperties, since the codegen mechanism heavily relies on a stable,
|
||||
* non-changing System Property Basis. Using plain System.(get|set|clear)Property raises Race-Conditions in combination
|
||||
* with Code, that uses System.setProperties (e.g. maven-surefire-plugin).
|
||||
*
|
||||
* @author gndrm
|
||||
* @since 2018
|
||||
*/
|
||||
public class GeneratorProperties {
|
||||
|
||||
private static ThreadLocal<Properties> properties = new InheritableThreadLocal<Properties>() {
|
||||
@Override
|
||||
protected Properties initialValue() {
|
||||
return (Properties) System.getProperties().clone();
|
||||
};
|
||||
};
|
||||
|
||||
public static String getProperty(String key, String defaultValue) {
|
||||
return properties.get().getProperty(key, defaultValue);
|
||||
}
|
||||
|
||||
public static String getProperty(String key) {
|
||||
return properties.get().getProperty(key);
|
||||
}
|
||||
|
||||
public static void setProperty(String key, String value) {
|
||||
properties.get().setProperty(key, value);
|
||||
}
|
||||
|
||||
public static void clearProperty(String key) {
|
||||
properties.get().remove(key);
|
||||
}
|
||||
|
||||
public static void reset() {
|
||||
properties.remove();
|
||||
}
|
||||
}
|
||||
@@ -75,12 +75,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
protected Set<String> collectionTypes;
|
||||
protected Set<String> mapTypes;
|
||||
|
||||
// true if support nullable type
|
||||
protected boolean supportNullable = Boolean.FALSE;
|
||||
|
||||
// nullable type
|
||||
protected Set<String> nullableType = new HashSet<String>();
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractCSharpCodegen.class);
|
||||
|
||||
public AbstractCSharpCodegen() {
|
||||
@@ -136,26 +130,19 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
"String",
|
||||
"string",
|
||||
"bool?",
|
||||
"bool",
|
||||
"double?",
|
||||
"double",
|
||||
"decimal?",
|
||||
"decimal",
|
||||
"int?",
|
||||
"int",
|
||||
"long?",
|
||||
"long",
|
||||
"float?",
|
||||
"float",
|
||||
"byte[]",
|
||||
"ICollection",
|
||||
"Collection",
|
||||
"List",
|
||||
"Dictionary",
|
||||
"DateTime?",
|
||||
"DateTime",
|
||||
"DateTimeOffset?",
|
||||
"DataTimeOffset",
|
||||
"String",
|
||||
"Boolean",
|
||||
"Double",
|
||||
"Int32",
|
||||
@@ -170,7 +157,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
instantiationTypes.put("list", "List");
|
||||
instantiationTypes.put("map", "Dictionary");
|
||||
|
||||
|
||||
// Nullable types here assume C# 2 support is not part of base
|
||||
typeMapping = new HashMap<String, String>();
|
||||
typeMapping.put("string", "string");
|
||||
@@ -190,11 +176,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
typeMapping.put("map", "Dictionary");
|
||||
typeMapping.put("object", "Object");
|
||||
typeMapping.put("UUID", "Guid?");
|
||||
|
||||
// nullable type
|
||||
nullableType = new HashSet<String>(
|
||||
Arrays.asList("decimal", "bool", "int", "float", "long", "double", "DateTime", "Guid")
|
||||
);
|
||||
}
|
||||
|
||||
public void setReturnICollection(boolean returnICollection) {
|
||||
@@ -228,7 +209,8 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
this.useDateTimeOffsetFlag = flag;
|
||||
if (flag) {
|
||||
typeMapping.put("DateTime", "DateTimeOffset?");
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
typeMapping.put("DateTime", "DateTime?");
|
||||
}
|
||||
}
|
||||
@@ -439,8 +421,8 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Object> entry : models.entrySet()) {
|
||||
String openAPIName = entry.getKey();
|
||||
CodegenModel model = ModelUtils.getModelByName(openAPIName, models);
|
||||
String swaggerName = entry.getKey();
|
||||
CodegenModel model = ModelUtils.getModelByName(swaggerName, models);
|
||||
if (model != null) {
|
||||
for (CodegenProperty var : model.allVars) {
|
||||
if (enumRefs.containsKey(var.dataType)) {
|
||||
@@ -501,7 +483,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LOGGER.warn("Expected to retrieve model %s by name, but no model was found. Check your -Dmodels inclusions.", openAPIName);
|
||||
LOGGER.warn("Expected to retrieve model %s by name, but no model was found. Check your -Dmodels inclusions.", swaggerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -591,30 +573,28 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
}
|
||||
}
|
||||
|
||||
if (!isSupportNullable()) {
|
||||
for (CodegenParameter parameter : operation.allParams) {
|
||||
CodegenModel model = null;
|
||||
for (Object modelHashMap : allModels) {
|
||||
CodegenModel codegenModel = ((HashMap<String, CodegenModel>) modelHashMap).get("model");
|
||||
if (codegenModel.getClassname().equals(parameter.dataType)) {
|
||||
model = codegenModel;
|
||||
break;
|
||||
}
|
||||
for (CodegenParameter parameter: operation.allParams) {
|
||||
CodegenModel model = null;
|
||||
for(Object modelHashMap: allModels) {
|
||||
CodegenModel codegenModel = ((HashMap<String, CodegenModel>) modelHashMap).get("model");
|
||||
if (codegenModel.getClassname().equals(parameter.dataType)) {
|
||||
model = codegenModel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (model == null) {
|
||||
// Primitive data types all come already marked
|
||||
parameter.isNullable = true;
|
||||
if (model == null) {
|
||||
// Primitive data types all come already marked
|
||||
parameter.isNullable = true;
|
||||
} else {
|
||||
// Effectively mark enum models as enums and non-nullable
|
||||
if (model.isEnum) {
|
||||
parameter.isEnum = true;
|
||||
parameter.allowableValues = model.allowableValues;
|
||||
parameter.isPrimitiveType = true;
|
||||
parameter.isNullable = false;
|
||||
} else {
|
||||
// Effectively mark enum models as enums and non-nullable
|
||||
if (model.isEnum) {
|
||||
parameter.isEnum = true;
|
||||
parameter.allowableValues = model.allowableValues;
|
||||
parameter.isPrimitiveType = true;
|
||||
parameter.isNullable = false;
|
||||
} else {
|
||||
parameter.isNullable = true;
|
||||
}
|
||||
parameter.isNullable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -812,14 +792,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
return reservedWords.contains(word);
|
||||
}
|
||||
|
||||
public String getNullableType(Schema p, String type) {
|
||||
if (languageSpecificPrimitives.contains(type)) {
|
||||
return type;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchemaType(Schema p) {
|
||||
String openAPIType = super.getSchemaType(p);
|
||||
@@ -832,9 +804,8 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
|
||||
if (typeMapping.containsKey(openAPIType)) {
|
||||
type = typeMapping.get(openAPIType);
|
||||
String languageType = getNullableType(p, type);
|
||||
if (languageType != null) {
|
||||
return languageType;
|
||||
if (languageSpecificPrimitives.contains(type)) {
|
||||
return type;
|
||||
}
|
||||
} else {
|
||||
type = openAPIType;
|
||||
@@ -979,14 +950,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
this.interfacePrefix = interfacePrefix;
|
||||
}
|
||||
|
||||
public boolean isSupportNullable() {
|
||||
return supportNullable;
|
||||
}
|
||||
|
||||
public void setSupportNullable(final boolean supportNullable) {
|
||||
this.supportNullable = supportNullable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toEnumValue(String value, String datatype) {
|
||||
// C# only supports enums as literals for int, int?, long, long?, byte, and byte?. All else must be treated as strings.
|
||||
@@ -1048,9 +1011,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
|
||||
@Override
|
||||
public boolean isDataTypeString(String dataType) {
|
||||
// also treat double/decimal/float as "string" in enum so that the values (e.g. 2.8) get double-quoted
|
||||
return "String".equalsIgnoreCase(dataType) ||
|
||||
"double?".equals(dataType) || "decimal?".equals(dataType) || "float?".equals(dataType) ||
|
||||
"double".equals(dataType) || "decimal".equals(dataType) || "float".equals(dataType);
|
||||
return "String".equalsIgnoreCase(dataType) || "double?".equals(dataType) || "decimal?".equals(dataType) || "float?".equals(dataType);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -43,7 +43,15 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.escape;
|
||||
@@ -534,22 +542,17 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return (outputFolder + "/" + sourceFolder + "/" + apiPackage()).replace('.', File.separatorChar);
|
||||
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', '/');
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiTestFileFolder() {
|
||||
return (outputFolder + "/" + testFolder + "/" + apiPackage()).replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelTestFileFolder() {
|
||||
return (outputFolder + "/" + testFolder + "/" + modelPackage()).replace('.', File.separatorChar);
|
||||
return outputFolder + "/" + testFolder + "/" + apiPackage().replace('.', '/');
|
||||
}
|
||||
|
||||
@Override
|
||||
public String modelFileFolder() {
|
||||
return (outputFolder + "/" + sourceFolder + "/" + modelPackage()).replace('.', File.separatorChar);
|
||||
return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', '/');
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -577,11 +580,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
return toApiName(name) + "Test";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toModelTestFilename(String name) {
|
||||
return toModelName(name) + "Test";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
if (name.length() == 0) {
|
||||
@@ -1038,7 +1036,6 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
continue;
|
||||
}
|
||||
for (Operation operation : path.readOperations()) {
|
||||
LOGGER.info("Processing operation " + operation.getOperationId());
|
||||
if (hasBodyParameter(openAPI, operation) || hasFormParameter(openAPI, operation)) {
|
||||
String defaultContentType = hasFormParameter(openAPI, operation) ? "application/x-www-form-urlencoded" : "application/json";
|
||||
List<String> consumes = new ArrayList<String>(getConsumesInfo(openAPI, operation));
|
||||
@@ -1055,9 +1052,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
|
||||
protected static String getAccept(OpenAPI openAPI, Operation operation) {
|
||||
String accepts = null;
|
||||
String defaultContentType = "application/json";
|
||||
Set<String> producesInfo = getProducesInfo(openAPI, operation);
|
||||
if (producesInfo != null && !producesInfo.isEmpty()) {
|
||||
ArrayList<String> produces = new ArrayList<String>(producesInfo);
|
||||
ArrayList<String> produces = new ArrayList<String>(getProducesInfo(openAPI, operation));
|
||||
if (produces != null && !produces.isEmpty()) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String produce : produces) {
|
||||
if (defaultContentType.equalsIgnoreCase(produce)) {
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.media.StringSchema;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.CliOption;
|
||||
@@ -353,17 +352,9 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
|
||||
if (ModelUtils.isArraySchema(p)) {
|
||||
ArraySchema ap = (ArraySchema) p;
|
||||
Schema inner = ap.getItems();
|
||||
if (inner == null) {
|
||||
LOGGER.warn(ap.getName() + "(array property) does not have a proper inner type defined.Default to string");
|
||||
inner = new StringSchema().description("TODO default missing array inner type to string");
|
||||
}
|
||||
return getTypeDeclaration(inner) + "[]";
|
||||
} else if (ModelUtils.isMapSchema(p)) {
|
||||
Schema inner = ModelUtils.getAdditionalProperties(p);
|
||||
if (inner == null) {
|
||||
LOGGER.warn(p.getName() + "(map property) does not have a proper inner type defined. Default to string");
|
||||
inner = new StringSchema().description("TODO default missing map inner type to string");
|
||||
}
|
||||
return getSchemaType(p) + "[string," + getTypeDeclaration(inner) + "]";
|
||||
} else if (StringUtils.isNotBlank(p.get$ref())) { // model
|
||||
String type = super.getTypeDeclaration(p);
|
||||
|
||||
@@ -54,9 +54,6 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp
|
||||
|
||||
supportsInheritance = true;
|
||||
|
||||
// to support multiple inheritance e.g. export interface ModelC extends ModelA, ModelB
|
||||
//supportsMultipleInheritance = true;
|
||||
|
||||
// NOTE: TypeScript uses camel cased reserved words, while models are title cased. We don't want lowercase comparisons.
|
||||
reservedWords.addAll(Arrays.asList(
|
||||
// local variable names used in API methods (endpoints)
|
||||
|
||||
@@ -83,9 +83,6 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
// By default, generated code is considered public
|
||||
protected boolean nonPublicApi = Boolean.FALSE;
|
||||
|
||||
// use KellermanSoftware.CompareNetObjects for deep recursive object comparision
|
||||
protected boolean useCompareNetObjects = Boolean.FALSE;
|
||||
|
||||
public CSharpClientCodegen() {
|
||||
super();
|
||||
supportsInheritance = true;
|
||||
@@ -199,10 +196,6 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
CodegenConstants.VALIDATABLE_DESC,
|
||||
this.validatable);
|
||||
|
||||
addSwitch(CodegenConstants.USE_COMPARE_NET_OBJECTS,
|
||||
CodegenConstants.USE_COMPARE_NET_OBJECTS_DESC,
|
||||
this.useCompareNetObjects);
|
||||
|
||||
regexModifiers = new HashMap<Character, String>();
|
||||
regexModifiers.put('i', "IgnoreCase");
|
||||
regexModifiers.put('m', "Multiline");
|
||||
@@ -776,6 +769,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setPackageName(String packageName) {
|
||||
this.packageName = packageName;
|
||||
}
|
||||
@@ -804,10 +798,6 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
|
||||
this.generatePropertyChanged = generatePropertyChanged;
|
||||
}
|
||||
|
||||
public void setUseCompareNetObjects(final Boolean useCompareNetObjects) {
|
||||
this.useCompareNetObjects = useCompareNetObjects;
|
||||
}
|
||||
|
||||
public boolean isNonPublicApi() {
|
||||
return nonPublicApi;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import static org.apache.commons.lang3.StringUtils.isEmpty;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.samskivert.mustache.Mustache;
|
||||
|
||||
import io.swagger.v3.oas.models.media.ArraySchema;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
|
||||
import org.openapitools.codegen.CliOption;
|
||||
@@ -33,7 +32,6 @@ import org.openapitools.codegen.CodegenParameter;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.utils.ModelUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -51,7 +49,7 @@ import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
public class CSharpRefactorClientCodegen extends AbstractCSharpCodegen {
|
||||
@SuppressWarnings({"hiding"})
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class);
|
||||
private static final String NET45 = "v4.5.2";
|
||||
private static final String NET45 = "v4.5";
|
||||
private static final String NET40 = "v4.0";
|
||||
private static final String NET35 = "v3.5";
|
||||
// TODO: v5.0 is PCL, not netstandard version 1.3, and not a specific .NET Framework. This needs to be updated,
|
||||
@@ -86,39 +84,19 @@ public class CSharpRefactorClientCodegen extends AbstractCSharpCodegen {
|
||||
// By default, generated code is considered public
|
||||
protected boolean nonPublicApi = Boolean.FALSE;
|
||||
|
||||
|
||||
public CSharpRefactorClientCodegen() {
|
||||
super();
|
||||
|
||||
// mapped non-nullable type without ?
|
||||
typeMapping = new HashMap<String, String>();
|
||||
typeMapping.put("string", "string");
|
||||
typeMapping.put("binary", "byte[]");
|
||||
typeMapping.put("ByteArray", "byte[]");
|
||||
typeMapping.put("boolean", "bool");
|
||||
typeMapping.put("integer", "int");
|
||||
typeMapping.put("float", "float");
|
||||
typeMapping.put("long", "long");
|
||||
typeMapping.put("double", "double");
|
||||
typeMapping.put("number", "decimal");
|
||||
typeMapping.put("DateTime", "DateTime");
|
||||
typeMapping.put("date", "DateTime");
|
||||
typeMapping.put("file", "System.IO.Stream");
|
||||
typeMapping.put("array", "List");
|
||||
typeMapping.put("list", "List");
|
||||
typeMapping.put("map", "Dictionary");
|
||||
typeMapping.put("object", "Object");
|
||||
typeMapping.put("UUID", "Guid");
|
||||
|
||||
setSupportNullable(Boolean.TRUE);
|
||||
hideGenerationTimestamp = Boolean.TRUE;
|
||||
supportsInheritance = true;
|
||||
modelTemplateFiles.put("model.mustache", ".cs");
|
||||
apiTemplateFiles.put("api.mustache", ".cs");
|
||||
|
||||
modelDocTemplateFiles.put("model_doc.mustache", ".md");
|
||||
apiDocTemplateFiles.put("api_doc.mustache", ".md");
|
||||
|
||||
embeddedTemplateDir = templateDir = "csharp-refactor";
|
||||
|
||||
hideGenerationTimestamp = Boolean.TRUE;
|
||||
|
||||
cliOptions.clear();
|
||||
|
||||
// CLI options
|
||||
@@ -149,7 +127,7 @@ public class CSharpRefactorClientCodegen extends AbstractCSharpCodegen {
|
||||
frameworks = new ImmutableMap.Builder<String, String>()
|
||||
.put(NET35, ".NET Framework 3.5 compatible")
|
||||
.put(NET40, ".NET Framework 4.0 compatible")
|
||||
.put(NET45, ".NET Framework 4.5.2+ compatible")
|
||||
.put(NET45, ".NET Framework 4.5+ compatible")
|
||||
.put(NETSTANDARD, ".NET Standard 1.3 compatible")
|
||||
.put(UWP, "Universal Windows Platform (IMPORTANT: this will be decommissioned and replaced by v5.0)")
|
||||
.build();
|
||||
@@ -245,6 +223,7 @@ public class CSharpRefactorClientCodegen extends AbstractCSharpCodegen {
|
||||
setModelPropertyNaming((String) additionalProperties.get(CodegenConstants.MODEL_PROPERTY_NAMING));
|
||||
}
|
||||
|
||||
|
||||
if (isEmpty(apiPackage)) {
|
||||
setApiPackage("Api");
|
||||
}
|
||||
@@ -316,10 +295,8 @@ public class CSharpRefactorClientCodegen extends AbstractCSharpCodegen {
|
||||
|
||||
setTargetFrameworkNuget("net40");
|
||||
setSupportsAsync(Boolean.FALSE);
|
||||
} else { // 4.5+
|
||||
} else {
|
||||
additionalProperties.put(MCS_NET_VERSION_KEY, "4.5.2-api");
|
||||
// some libs need 452 isntead of 45 in the config
|
||||
additionalProperties.put("isNet452", true);
|
||||
setTargetFrameworkNuget("net45");
|
||||
setSupportsAsync(Boolean.TRUE);
|
||||
}
|
||||
@@ -630,10 +607,6 @@ public class CSharpRefactorClientCodegen extends AbstractCSharpCodegen {
|
||||
public void postProcessParameter(CodegenParameter parameter) {
|
||||
postProcessPattern(parameter.pattern, parameter.vendorExtensions);
|
||||
super.postProcessParameter(parameter);
|
||||
|
||||
if (!parameter.required && nullableType.contains(parameter.dataType)) { //optional
|
||||
parameter.dataType = parameter.dataType + "?";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -877,17 +850,4 @@ public class CSharpRefactorClientCodegen extends AbstractCSharpCodegen {
|
||||
// To avoid unexpected behaviors when options are passed programmatically such as { "supportsAsync": "" }
|
||||
return super.processCompiler(compiler).emptyStringIsFalse(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNullableType(Schema p, String type) {
|
||||
if (languageSpecificPrimitives.contains(type)) {
|
||||
if (isSupportNullable() && ModelUtils.isNullable(p) && nullableType.contains(type)) {
|
||||
return type + "?";
|
||||
} else {
|
||||
return type;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import org.openapitools.codegen.*;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class DukeScriptClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
protected String sourceFolder = "src";
|
||||
protected String apiVersion = "1.0.0";
|
||||
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.CLIENT;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "dukescript";
|
||||
}
|
||||
|
||||
public String getHelp() {
|
||||
return "Generates a DukeScript @Model client library (beta).";
|
||||
}
|
||||
|
||||
public DukeScriptClientCodegen() {
|
||||
super();
|
||||
outputFolder = "generated-code/dukescript";
|
||||
modelTemplateFiles.put(
|
||||
"model.mustache",
|
||||
"VMD.java");
|
||||
apiTemplateFiles.put(
|
||||
"api.mustache",
|
||||
"Connector.java");
|
||||
templateDir = "dukescript";
|
||||
apiPackage = "org.openapitools.client.api";
|
||||
modelPackage = "org.openapitools.client.model";
|
||||
additionalProperties.put("apiVersion", apiVersion);
|
||||
typeMapping.put("string", "String");
|
||||
typeMapping.put("integer", "int");
|
||||
typeMapping.put("long", "long");
|
||||
typeMapping.put("short", "short");
|
||||
typeMapping.put("short", "short");
|
||||
typeMapping.put("Boolean", "boolean");
|
||||
typeMapping.put("boolean", "boolean");
|
||||
typeMapping.put("Date", "long");
|
||||
typeMapping.put("DateTime", "long");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
return "_" + name; // add an underscore to the name
|
||||
}
|
||||
|
||||
public String modelFileFolder() {
|
||||
return outputFolder + "/" + sourceFolder + "/" + modelPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
return outputFolder + "/" + sourceFolder + "/" + apiPackage().replace('.', File.separatorChar);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSchemaType(Schema p) {
|
||||
String openAPIType = super.getSchemaType(p);
|
||||
String type = null;
|
||||
if (typeMapping.containsKey(openAPIType)) {
|
||||
type = typeMapping.get(openAPIType);
|
||||
if (languageSpecificPrimitives.contains(type)) {
|
||||
return type;
|
||||
}
|
||||
} else {
|
||||
type = openAPIType;
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
return input.replace("*/", "*_/").replace("/*", "/_*");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeQuotationMark(String input) {
|
||||
// remove " to avoid code injection
|
||||
return input.replace("\"", "");
|
||||
}
|
||||
|
||||
}
|
||||
@@ -447,7 +447,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
if (ElmVersion.ELM_018.equals(elmVersion)) {
|
||||
String path = op.path;
|
||||
for (CodegenParameter param : op.pathParams) {
|
||||
final String var = paramToString("params", param, false, null);
|
||||
final String var = paramToString(param, false, null);
|
||||
path = path.replace("{" + param.paramName + "}", "\" ++ " + var + " ++ \"");
|
||||
hasDateTime = hasDateTime || param.isDateTime;
|
||||
hasDate = hasDate || param.isDate;
|
||||
@@ -457,7 +457,7 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
final List<String> paths = Arrays.asList(op.path.substring(1).split("/"));
|
||||
String path = paths.stream().map(str -> str.charAt(0) == '{' ? str : "\"" + str + "\"").collect(Collectors.joining(", "));
|
||||
for (CodegenParameter param : op.pathParams) {
|
||||
String str = paramToString("params", param, false, null);
|
||||
String str = paramToString(param, false, null);
|
||||
path = path.replace("{" + param.paramName + "}", str);
|
||||
hasDateTime = hasDateTime || param.isDateTime;
|
||||
hasDate = hasDate || param.isDate;
|
||||
@@ -465,15 +465,10 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
op.path = path;
|
||||
|
||||
final String query = op.queryParams.stream()
|
||||
.map(param -> paramToString("params", param, true, "Url.string \"" + param.baseName + "\""))
|
||||
.map(param -> paramToString(param, true, "Url.string \"" + param.paramName + "\""))
|
||||
.collect(Collectors.joining(", "));
|
||||
op.vendorExtensions.put("query", query);
|
||||
|
||||
final String headers = op.headerParams.stream()
|
||||
.map(param -> paramToString("headers", param, true, "Http.header \"" + param.baseName + "\""))
|
||||
.collect(Collectors.joining(", "));
|
||||
op.vendorExtensions.put("headers", headers);
|
||||
// TODO cookies
|
||||
// TODO headers
|
||||
// TODO forms
|
||||
}
|
||||
|
||||
@@ -568,8 +563,8 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
return "(Just " + value + ")";
|
||||
}
|
||||
|
||||
private String paramToString(final String prefix, final CodegenParameter param, final boolean useMaybe, final String maybeMapResult) {
|
||||
final String paramName = (ElmVersion.ELM_018.equals(elmVersion) ? "" : prefix + ".") + param.paramName;
|
||||
private String paramToString(final CodegenParameter param, final boolean useMaybe, final String maybeMapResult) {
|
||||
final String paramName = (ElmVersion.ELM_018.equals(elmVersion) ? "" : "params.") + param.paramName;
|
||||
if (!useMaybe) {
|
||||
param.required = true;
|
||||
}
|
||||
@@ -606,15 +601,11 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
String mapResult = "";
|
||||
if (maybeMapResult != null) {
|
||||
if (mapFn == "") {
|
||||
mapResult = maybeMapResult;
|
||||
} else {
|
||||
mapResult = maybeMapResult + (param.required ? " <|" : " <<");
|
||||
}
|
||||
mapResult = maybeMapResult + (param.required ? " <|" : " <<");
|
||||
}
|
||||
final String just = useMaybe ? "Just (" : "";
|
||||
final String justEnd = useMaybe ? ")" : "";
|
||||
return (param.required ? just : "Maybe.map (") + mapResult + " " + mapFn + (param.required ? " " : ") ") + paramName + (param.required ? justEnd : "");
|
||||
return (param.required ? just : "Maybe.map") + mapResult + " " + mapFn + " " + paramName + (param.required ? justEnd : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -64,7 +64,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
public static final String FEIGN_VERSION = "feignVersion";
|
||||
public static final String PARCELABLE_MODEL = "parcelableModel";
|
||||
public static final String USE_RUNTIME_EXCEPTION = "useRuntimeException";
|
||||
public static final String USE_REFLECTION_EQUALS_HASHCODE = "useReflectionEqualsHashCode";
|
||||
|
||||
public static final String PLAY_24 = "play24";
|
||||
public static final String PLAY_25 = "play25";
|
||||
@@ -89,9 +88,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
protected String gradleWrapperPackage = "gradle.wrapper";
|
||||
protected boolean useRxJava = false;
|
||||
protected boolean useRxJava2 = false;
|
||||
// backwards compatibility for openapi configs that specify neither rx1 nor rx2
|
||||
// (mustache does not allow for boolean operators so we need this extra field)
|
||||
protected boolean doNotUseRx = true;
|
||||
protected boolean doNotUseRx = true; // backwards compatibility for swagger configs that specify neither rx1 nor rx2 (mustache does not allow for boolean operators so we need this extra field)
|
||||
protected boolean usePlayWS = false;
|
||||
protected String playVersion = PLAY_25;
|
||||
protected String feignVersion = FEIGN_9;
|
||||
@@ -100,7 +97,7 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
protected boolean performBeanValidation = false;
|
||||
protected boolean useGzipFeature = false;
|
||||
protected boolean useRuntimeException = false;
|
||||
protected boolean useReflectionEqualsHashCode = false;
|
||||
|
||||
|
||||
public JavaClientCodegen() {
|
||||
super();
|
||||
@@ -111,8 +108,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
apiPackage = "org.openapitools.client.api";
|
||||
modelPackage = "org.openapitools.client.model";
|
||||
|
||||
modelTestTemplateFiles.put("model_test.mustache", ".java");
|
||||
|
||||
cliOptions.add(CliOption.newBoolean(USE_RX_JAVA, "Whether to use the RxJava adapter with the retrofit2 library."));
|
||||
cliOptions.add(CliOption.newBoolean(USE_RX_JAVA2, "Whether to use the RxJava2 adapter with the retrofit2 library."));
|
||||
cliOptions.add(CliOption.newBoolean(PARCELABLE_MODEL, "Whether to generate models for Android that implement Parcelable with the okhttp-gson library."));
|
||||
@@ -124,7 +119,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
cliOptions.add(CliOption.newBoolean(USE_GZIP_FEATURE, "Send gzip-encoded requests"));
|
||||
cliOptions.add(CliOption.newBoolean(USE_RUNTIME_EXCEPTION, "Use RuntimeException instead of Exception"));
|
||||
cliOptions.add(CliOption.newBoolean(FEIGN_VERSION, "Version of OpenFeign: '10.x', '9.x' (default)"));
|
||||
cliOptions.add(CliOption.newBoolean(USE_REFLECTION_EQUALS_HASHCODE, "Use org.apache.commons.lang3.builder for equals and hashCode in the models. WARNING: This will fail under a security manager, unless the appropriate permissions are set up correctly and also there's potential performance impact."));
|
||||
|
||||
supportedLibraries.put(JERSEY1, "HTTP client: Jersey client 1.19.4. JSON processing: Jackson 2.8.9. Enable Java6 support using '-DsupportJava6=true'. Enable gzip request encoding using '-DuseGzipFeature=true'.");
|
||||
supportedLibraries.put(FEIGN, "HTTP client: OpenFeign 9.4.0. JSON processing: Jackson 2.8.9. To enable OpenFeign 10.x, set the 'feignVersion' option to '10.x'");
|
||||
@@ -231,10 +225,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
this.setUseRuntimeException(convertPropertyToBooleanAndWriteBack(USE_RUNTIME_EXCEPTION));
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(USE_REFLECTION_EQUALS_HASHCODE)) {
|
||||
this.setUseReflectionEqualsHashCode(convertPropertyToBooleanAndWriteBack(USE_REFLECTION_EQUALS_HASHCODE));
|
||||
}
|
||||
|
||||
final String invokerFolder = (sourceFolder + '/' + invokerPackage).replace(".", "/");
|
||||
final String authFolder = (sourceFolder + '/' + invokerPackage + ".auth").replace(".", "/");
|
||||
final String apiFolder = (sourceFolder + '/' + apiPackage).replace(".", "/");
|
||||
@@ -642,10 +632,6 @@ public class JavaClientCodegen extends AbstractJavaCodegen
|
||||
this.useRuntimeException = useRuntimeException;
|
||||
}
|
||||
|
||||
public void setUseReflectionEqualsHashCode(boolean useReflectionEqualsHashCode) {
|
||||
this.useReflectionEqualsHashCode = useReflectionEqualsHashCode;
|
||||
}
|
||||
|
||||
final private static Pattern JSON_MIME_PATTERN = Pattern.compile("(?i)application\\/json(;.*)?");
|
||||
final private static Pattern JSON_VENDOR_MIME_PATTERN = Pattern.compile("(?i)application\\/vnd.(.*)+json(;.*)?");
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.config.GeneratorProperties;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -61,8 +60,8 @@ public class JavaInflectorServerCodegen extends AbstractJavaCodegen {
|
||||
apiDocTemplateFiles.remove("api_doc.mustache");
|
||||
|
||||
|
||||
apiPackage = GeneratorProperties.getProperty("swagger.codegen.inflector.apipackage", "org.openapitools.controllers");
|
||||
modelPackage = GeneratorProperties.getProperty("swagger.codegen.inflector.modelpackage", "org.openapitools.model");
|
||||
apiPackage = System.getProperty("swagger.codegen.inflector.apipackage", "org.openapitools.controllers");
|
||||
modelPackage = System.getProperty("swagger.codegen.inflector.modelpackage", "org.openapitools.model");
|
||||
|
||||
additionalProperties.put("title", title);
|
||||
// java inflector uses the jackson lib
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenProperty;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.config.GeneratorProperties;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -56,17 +55,17 @@ public class JavaUndertowServerCodegen extends AbstractJavaCodegen {
|
||||
modelDocTemplateFiles.remove("model_doc.mustache");
|
||||
apiDocTemplateFiles.remove("api_doc.mustache");
|
||||
|
||||
if(GeneratorProperties.getProperty("swagger.codegen.undertow.apipackage") != null && GeneratorProperties.getProperty("openapi.codegen.undertow.apipackage") == null) {
|
||||
if(System.getProperty("swagger.codegen.undertow.apipackage") != null && System.getProperty("openapi.codegen.undertow.apipackage") == null) {
|
||||
LOGGER.warn("System property 'swagger.codegen.undertow.apipackage' was renamed to 'swagger.codegen.undertow.apipackage'");
|
||||
apiPackage = GeneratorProperties.getProperty("swagger.codegen.undertow.apipackage", "org.openapitools.handler");
|
||||
apiPackage = System.getProperty("swagger.codegen.undertow.apipackage", "org.openapitools.handler");
|
||||
} else {
|
||||
apiPackage = GeneratorProperties.getProperty("openapi.codegen.undertow.apipackage", "org.openapitools.handler");
|
||||
apiPackage = System.getProperty("openapi.codegen.undertow.apipackage", "org.openapitools.handler");
|
||||
}
|
||||
if(GeneratorProperties.getProperty("swagger.codegen.undertow.modelpackage") != null && GeneratorProperties.getProperty("openapi.codegen.undertow.modelpackage") == null) {
|
||||
if(System.getProperty("swagger.codegen.undertow.modelpackage") != null && System.getProperty("openapi.codegen.undertow.modelpackage") == null) {
|
||||
LOGGER.warn("System property 'swagger.codegen.undertow.modelpackage' was renamed to 'openapi.codegen.undertow.modelpackage'");
|
||||
modelPackage = GeneratorProperties.getProperty("swagger.codegen.undertow.modelpackage", "org.openapitools.model");
|
||||
modelPackage = System.getProperty("swagger.codegen.undertow.modelpackage", "org.openapitools.model");
|
||||
} else {
|
||||
modelPackage = GeneratorProperties.getProperty("openapi.codegen.undertow.modelpackage", "org.openapitools.model");
|
||||
modelPackage = System.getProperty("openapi.codegen.undertow.modelpackage", "org.openapitools.model");
|
||||
}
|
||||
|
||||
additionalProperties.put("title", title);
|
||||
|
||||
@@ -1046,16 +1046,6 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
}
|
||||
}
|
||||
|
||||
for (CodegenProperty var : cm.allVars) {
|
||||
// Add JSDoc @type value for this property.
|
||||
String jsDocType = getJSDocType(cm, var);
|
||||
var.vendorExtensions.put("x-jsdoc-type", jsDocType);
|
||||
|
||||
if (Boolean.TRUE.equals(var.required)) {
|
||||
required.add(var);
|
||||
}
|
||||
}
|
||||
|
||||
if (supportsInheritance || supportsMixins) {
|
||||
for (CodegenProperty var : cm.allVars) {
|
||||
if (Boolean.TRUE.equals(var.required)) {
|
||||
|
||||
@@ -101,14 +101,6 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||
typeMapping.put("object", "Any");
|
||||
typeMapping.put("binary", "Array<kotlin.Byte>");
|
||||
|
||||
typeMapping.put("date", "java.time.LocalDate");
|
||||
typeMapping.put("date-time", "java.time.OffsetDateTime");
|
||||
typeMapping.put("Date", "java.time.LocalDate");
|
||||
typeMapping.put("DateTime", "java.time.OffsetDateTime");
|
||||
|
||||
importMapping.put("Date", "java.time.LocalDate");
|
||||
importMapping.put("DateTime", "java.time.OffsetDateTime");
|
||||
|
||||
languageSpecificPrimitives.addAll(Arrays.asList(
|
||||
"Any",
|
||||
"Byte",
|
||||
@@ -251,6 +243,14 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
typeMapping.put("date", "java.time.LocalDate");
|
||||
typeMapping.put("date-time", "java.time.OffsetDateTime");
|
||||
typeMapping.put("Date", "java.time.LocalDate");
|
||||
typeMapping.put("DateTime", "java.time.OffsetDateTime");
|
||||
|
||||
importMapping.put("Date", "java.time.LocalDate");
|
||||
importMapping.put("DateTime", "java.time.OffsetDateTime");
|
||||
|
||||
// optional jackson mappings for BigDecimal support
|
||||
importMapping.put("ToStringSerializer", "com.fasterxml.jackson.databind.ser.std.ToStringSerializer");
|
||||
importMapping.put("JsonSerialize", "com.fasterxml.jackson.databind.annotation.JsonSerialize");
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.openapitools.codegen.CodegenResponse;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.DefaultCodegen;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.config.GeneratorProperties;
|
||||
import org.openapitools.codegen.utils.URLPathUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -352,7 +351,7 @@ public class NodeJSServerCodegen extends DefaultCodegen implements CodegenConfig
|
||||
}
|
||||
writeOptional(outputFolder, new SupportingFile("package.mustache", "", "package.json"));
|
||||
writeOptional(outputFolder, new SupportingFile("README.mustache", "", "README.md"));
|
||||
if (GeneratorProperties.getProperty("noservice") == null) {
|
||||
if (System.getProperty("noservice") == null) {
|
||||
apiTemplateFiles.put(
|
||||
"service.mustache", // the template to use
|
||||
"Service.js"); // the extension for each file to write
|
||||
|
||||
@@ -53,9 +53,6 @@ public class PerlClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public PerlClientCodegen() {
|
||||
super();
|
||||
|
||||
// add multiple inheritance support (beta)
|
||||
supportsMultipleInheritance = true;
|
||||
|
||||
// clear import mapping (from default generator) as perl does not use it
|
||||
// at the moment
|
||||
importMapping.clear();
|
||||
|
||||
@@ -31,21 +31,15 @@ import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.net.URLEncoder;
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.Operation;
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
|
||||
public class PhpSlimServerCodegen extends AbstractPhpCodegen {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PhpSlimServerCodegen.class);
|
||||
|
||||
public static final String USER_CLASSNAME_KEY = "userClassname";
|
||||
public static final String PHPCS_STANDARD = "phpcsStandard";
|
||||
|
||||
protected String groupId = "org.openapitools";
|
||||
protected String artifactId = "openapi-server";
|
||||
protected String phpcsStandard = "PSR12";
|
||||
|
||||
public PhpSlimServerCodegen() {
|
||||
super();
|
||||
@@ -79,6 +73,9 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
cliOptions.add(new CliOption(PHPCS_STANDARD, "PHP CodeSniffer <standard> option. Accepts name or path of the coding standard to use.")
|
||||
.defaultValue("PSR12"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -118,20 +115,25 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
if (additionalProperties.containsKey(PHPCS_STANDARD)) {
|
||||
this.setPhpcsStandard((String) additionalProperties.get(PHPCS_STANDARD));
|
||||
} else {
|
||||
additionalProperties.put(PHPCS_STANDARD, phpcsStandard);
|
||||
}
|
||||
|
||||
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("composer.mustache", "", "composer.json"));
|
||||
supportingFiles.add(new SupportingFile("index.mustache", "", "index.php"));
|
||||
supportingFiles.add(new SupportingFile(".htaccess", "", ".htaccess"));
|
||||
supportingFiles.add(new SupportingFile("AbstractApiController.mustache", toSrcPath(invokerPackage, srcBasePath), toAbstractName("ApiController") + ".php"));
|
||||
supportingFiles.add(new SupportingFile("SlimRouter.mustache", toSrcPath(invokerPackage, srcBasePath), "SlimRouter.php"));
|
||||
supportingFiles.add(new SupportingFile("phpunit.xml.mustache", "", "phpunit.xml.dist"));
|
||||
supportingFiles.add(new SupportingFile("phpcs.xml.mustache", "", "phpcs.xml.dist"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
|
||||
Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
|
||||
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");
|
||||
addUserClassnameToOperations(operations);
|
||||
escapeMediaType(operationList);
|
||||
return objs;
|
||||
}
|
||||
@@ -158,85 +160,8 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
|
||||
return objs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiName(String name) {
|
||||
if (name.length() == 0) {
|
||||
return toAbstractName("DefaultApi");
|
||||
}
|
||||
return toAbstractName(initialCaps(name) + "Api");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toApiTestFilename(String name) {
|
||||
if (name.length() == 0) {
|
||||
return "DefaultApiTest";
|
||||
}
|
||||
return initialCaps(name) + "ApiTest";
|
||||
}
|
||||
|
||||
/**
|
||||
* Strips out abstract prefix and suffix from classname and puts it in "userClassname" property of operations object.
|
||||
*
|
||||
* @param operations codegen object with operations
|
||||
*/
|
||||
private void addUserClassnameToOperations(Map<String, Object> operations) {
|
||||
String classname = (String) operations.get("classname");
|
||||
classname = classname.replaceAll("^" + abstractNamePrefix, "");
|
||||
classname = classname.replaceAll(abstractNameSuffix + "$", "");
|
||||
operations.put(USER_CLASSNAME_KEY, classname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String encodePath(String input) {
|
||||
if (input == null) {
|
||||
return input;
|
||||
}
|
||||
|
||||
// from DefaultCodegen.java
|
||||
// remove \t, \n, \r
|
||||
// replace \ with \\
|
||||
// replace " with \"
|
||||
// outter unescape to retain the original multi-byte characters
|
||||
// finally escalate characters avoiding code injection
|
||||
input = super.escapeUnsafeCharacters(
|
||||
StringEscapeUtils.unescapeJava(
|
||||
StringEscapeUtils.escapeJava(input)
|
||||
.replace("\\/", "/"))
|
||||
.replaceAll("[\\t\\n\\r]", " ")
|
||||
.replace("\\", "\\\\"));
|
||||
// .replace("\"", "\\\""));
|
||||
|
||||
// from AbstractPhpCodegen.java
|
||||
// Trim the string to avoid leading and trailing spaces.
|
||||
input = input.trim();
|
||||
try {
|
||||
|
||||
input = URLEncoder.encode(input, "UTF-8")
|
||||
.replaceAll("\\+", "%20")
|
||||
.replaceAll("\\%2F", "/")
|
||||
.replaceAll("\\%7B", "{") // keep { part of complex placeholders
|
||||
.replaceAll("\\%7D", "}") // } part
|
||||
.replaceAll("\\%5B", "[") // [ part
|
||||
.replaceAll("\\%5D", "]") // ] part
|
||||
.replaceAll("\\%3A", ":") // : part
|
||||
.replaceAll("\\%2B", "+") // + part
|
||||
.replaceAll("\\%5C\\%5Cd", "\\\\d"); // \d part
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// continue
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CodegenOperation fromOperation(String path,
|
||||
String httpMethod,
|
||||
Operation operation,
|
||||
Map<String, Schema> schemas,
|
||||
OpenAPI openAPI) {
|
||||
CodegenOperation op = super.fromOperation(path, httpMethod, operation, schemas, openAPI);
|
||||
op.path = encodePath(path);
|
||||
return op;
|
||||
public void setPhpcsStandard(String phpcsStandard) {
|
||||
this.phpcsStandard = phpcsStandard;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -381,19 +381,6 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
return toApiName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String addRegularExpressionDelimiter(String pattern) {
|
||||
if (StringUtils.isEmpty(pattern)) {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
if (!pattern.matches("^/.*")) {
|
||||
// Perform a negative lookbehind on each `/` to ensure that it is escaped.
|
||||
return "/" + pattern.replaceAll("(?<!\\\\)\\/", "\\\\/") + "/";
|
||||
}
|
||||
|
||||
return pattern;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apiFileFolder() {
|
||||
@@ -648,11 +635,6 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toRegularExpression(String pattern) {
|
||||
return addRegularExpressionDelimiter(pattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setParameterExampleValue(CodegenParameter p) {
|
||||
String example;
|
||||
@@ -762,4 +744,5 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -68,8 +68,6 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
|
||||
public RubyClientCodegen() {
|
||||
super();
|
||||
|
||||
supportsInheritance = true;
|
||||
|
||||
// clear import mapping (from default generator) as ruby does not use it
|
||||
// at the moment
|
||||
importMapping.clear();
|
||||
@@ -114,7 +112,6 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
|
||||
itr.remove();
|
||||
}
|
||||
}
|
||||
|
||||
cliOptions.add(new CliOption(GEM_NAME, "gem name (convention: underscore_case).").
|
||||
defaultValue("openapi_client"));
|
||||
cliOptions.add(new CliOption(MODULE_NAME, "top module name (convention: CamelCase, usually corresponding" +
|
||||
|
||||
@@ -222,12 +222,12 @@ public class Swift3Codegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "swift3-deprecated";
|
||||
return "swift3";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a Swift 3.x client library. IMPORTANT NOTE: this generator (swfit 3.x) is no longer actively maintained so please use 'swift4' generator instead.";
|
||||
return "Generates a Swift 3.x client library.";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -82,7 +82,7 @@ public class SwiftClientCodegen extends DefaultCodegen implements CodegenConfig
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a Swift (2.x) client library. IMPORTANT NOTE: this generator (swfit 2.x) is no longer actively maintained so please use 'swift4' generator instead.";
|
||||
return "Generates a Swift (2.x) client library. IMPORTANT NOTE: this generator (swfit 2.x) is no longer actively maintained so please use 'swift3' or 'swift4' generator instead.";
|
||||
}
|
||||
|
||||
public SwiftClientCodegen() {
|
||||
|
||||
@@ -61,16 +61,6 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class ModelUtils {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ModelUtils.class);
|
||||
private static boolean generateAliasAsModel = false;
|
||||
|
||||
public static void setGenerateAliasAsModel(boolean value) {
|
||||
generateAliasAsModel = value;
|
||||
}
|
||||
|
||||
public static boolean isGenerateAliasAsModel() {
|
||||
return generateAliasAsModel;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Searches for the model by name in the map of models and returns it
|
||||
@@ -557,17 +547,20 @@ public class ModelUtils {
|
||||
if ("object".equals(schema.getType())) {
|
||||
// no properties
|
||||
if ((schema.getProperties() == null || schema.getProperties().isEmpty())) {
|
||||
Schema addlProps = getAdditionalProperties(schema);
|
||||
// additionalProperties not defined
|
||||
if (addlProps == null) {
|
||||
if (schema.getAdditionalProperties() == null) {
|
||||
return true;
|
||||
} else {
|
||||
if (addlProps instanceof ObjectSchema) {
|
||||
ObjectSchema objSchema = (ObjectSchema) addlProps;
|
||||
// additionalProperties defined as {}
|
||||
if (objSchema.getProperties() == null || objSchema.getProperties().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
// additionalProperties set to true
|
||||
if (schema.getAdditionalProperties() instanceof Boolean
|
||||
&& (Boolean) schema.getAdditionalProperties()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// additionalProperties is set to {}
|
||||
if (schema.getAdditionalProperties() instanceof Schema && schema.getAdditionalProperties() != null
|
||||
&& schema.getAdditionalProperties() instanceof ObjectSchema
|
||||
&& ((Schema) schema.getAdditionalProperties()).getProperties().isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -778,31 +771,21 @@ public class ModelUtils {
|
||||
} else if (ref.getEnum() != null && !ref.getEnum().isEmpty()) {
|
||||
// top-level enum class
|
||||
return schema;
|
||||
} else if (isFreeFormObject(ref)) {
|
||||
return schema;
|
||||
} else if (isArraySchema(ref)) {
|
||||
if (generateAliasAsModel) {
|
||||
return schema; // generate a model extending array
|
||||
} else {
|
||||
return unaliasSchema(allSchemas, allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())));
|
||||
}
|
||||
return unaliasSchema(allSchemas, allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())));
|
||||
} else if (isComposedSchema(ref)) {
|
||||
return schema;
|
||||
} else if (isMapSchema(ref)) {
|
||||
if (ref.getProperties() != null && !ref.getProperties().isEmpty()) // has at least one property
|
||||
if (ref.getProperties() != null && !ref.getProperties().isEmpty()) // has properties
|
||||
return schema; // treat it as model
|
||||
else {
|
||||
if (generateAliasAsModel) {
|
||||
return schema; // generate a model extending map
|
||||
} else {
|
||||
// treat it as a typical map
|
||||
return unaliasSchema(allSchemas, allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())));
|
||||
}
|
||||
}
|
||||
} else if (isObjectSchema(ref)) { // model
|
||||
if (ref.getProperties() != null && !ref.getProperties().isEmpty()) { // has at least one property
|
||||
return schema;
|
||||
} else { // free form object (type: object)
|
||||
// treat it as a typical map
|
||||
return unaliasSchema(allSchemas, allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())));
|
||||
}
|
||||
} else if (isObjectSchema(ref)) { // model
|
||||
return schema;
|
||||
} else {
|
||||
return unaliasSchema(allSchemas, allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())));
|
||||
}
|
||||
@@ -895,35 +878,6 @@ public class ModelUtils {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<String> getAllParentsName(ComposedSchema composedSchema, Map<String, Schema> allSchemas) {
|
||||
List<Schema> interfaces = getInterfaces(composedSchema);
|
||||
List<String> names = new ArrayList<String>();
|
||||
|
||||
if (interfaces != null && !interfaces.isEmpty()) {
|
||||
for (Schema schema : interfaces) {
|
||||
// get the actual schema
|
||||
if (StringUtils.isNotEmpty(schema.get$ref())) {
|
||||
String parentName = getSimpleRef(schema.get$ref());
|
||||
Schema s = allSchemas.get(parentName);
|
||||
if (s == null) {
|
||||
LOGGER.error("Failed to obtain schema from {}", parentName);
|
||||
names.add("UNKNOWN_PARENT_NAME");
|
||||
} else if (s.getDiscriminator() != null && StringUtils.isNotEmpty(s.getDiscriminator().getPropertyName())) {
|
||||
// discriminator.propertyName is used
|
||||
names.add(parentName);
|
||||
} else {
|
||||
LOGGER.debug("Not a parent since discriminator.propertyName is not set {}", s.get$ref());
|
||||
// not a parent since discriminator.propertyName is not set
|
||||
}
|
||||
} else {
|
||||
// not a ref, doing nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
public static boolean isNullable(Schema schema) {
|
||||
if (schema == null) {
|
||||
return false;
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
{{/isEnum}}
|
||||
{{/isPrimitiveType}}
|
||||
{{/isContainer}}
|
||||
{{^isContainer}}
|
||||
{{#isNotContainer}}
|
||||
{{^isPrimitiveType}}
|
||||
@Valid
|
||||
{{/isPrimitiveType}}
|
||||
{{/isContainer}}
|
||||
{{/isNotContainer}}
|
||||
{{>beanValidationCore}}
|
||||
@@ -6,7 +6,6 @@ version = '{{artifactVersion}}'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
@@ -16,7 +15,6 @@ buildscript {
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ version = '{{artifactVersion}}'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
|
||||
@@ -6,7 +6,6 @@ version = '{{artifactVersion}}'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
|
||||
@@ -6,7 +6,6 @@ version = '{{artifactVersion}}'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
|
||||
@@ -6,7 +6,6 @@ version = '{{artifactVersion}}'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
@@ -125,7 +124,6 @@ dependencies {
|
||||
compile 'com.google.code.gson:gson:2.8.1'
|
||||
compile 'io.gsonfire:gson-fire:1.8.0'
|
||||
compile group: 'org.apache.oltu.oauth2', name: 'org.apache.oltu.oauth2.client', version: '1.0.1'
|
||||
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.8.1'
|
||||
{{#joda}}
|
||||
compile 'joda-time:joda-time:2.9.9'
|
||||
{{/joda}}
|
||||
|
||||
@@ -13,7 +13,6 @@ lazy val root = (project in file(".")).
|
||||
"com.squareup.okhttp" % "okhttp" % "2.7.5",
|
||||
"com.squareup.okhttp" % "logging-interceptor" % "2.7.5",
|
||||
"com.google.code.gson" % "gson" % "2.8.1",
|
||||
"org.apache.commons" % "commons-lang3" % "3.8.1",
|
||||
{{#joda}}
|
||||
"joda-time" % "joda-time" % "2.9.9" % "compile",
|
||||
{{/joda}}
|
||||
|
||||
@@ -225,55 +225,50 @@
|
||||
<artifactId>org.apache.oltu.oauth2.client</artifactId>
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons-lang3-version}</version>
|
||||
</dependency>
|
||||
{{#joda}}
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>${jodatime-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>${jodatime-version}</version>
|
||||
</dependency>
|
||||
{{/joda}}
|
||||
{{#threetenbp}}
|
||||
<dependency>
|
||||
<groupId>org.threeten</groupId>
|
||||
<artifactId>threetenbp</artifactId>
|
||||
<version>${threetenbp-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.threeten</groupId>
|
||||
<artifactId>threetenbp</artifactId>
|
||||
<version>${threetenbp-version}</version>
|
||||
</dependency>
|
||||
{{/threetenbp}}
|
||||
{{#useBeanValidation}}
|
||||
<!-- Bean Validation API support -->
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
<version>1.1.0.Final</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Bean Validation API support -->
|
||||
<dependency>
|
||||
<groupId>javax.validation</groupId>
|
||||
<artifactId>validation-api</artifactId>
|
||||
<version>1.1.0.Final</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
{{/useBeanValidation}}
|
||||
{{#performBeanValidation}}
|
||||
<!-- Bean Validation Impl. used to perform BeanValidation -->
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>5.4.1.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.el</groupId>
|
||||
<artifactId>el-api</artifactId>
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
<!-- Bean Validation Impl. used to perform BeanValidation -->
|
||||
<dependency>
|
||||
<groupId>org.hibernate</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
<version>5.4.1.Final</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.el</groupId>
|
||||
<artifactId>el-api</artifactId>
|
||||
<version>2.2</version>
|
||||
</dependency>
|
||||
{{/performBeanValidation}}
|
||||
{{#parcelableModel}}
|
||||
<!-- Needed for Parcelable support-->
|
||||
<dependency>
|
||||
<groupId>com.google.android</groupId>
|
||||
<artifactId>android</artifactId>
|
||||
<version>4.1.1.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Needed for Parcelable support-->
|
||||
<dependency>
|
||||
<groupId>com.google.android</groupId>
|
||||
<artifactId>android</artifactId>
|
||||
<version>4.1.1.4</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
{{/parcelableModel}}
|
||||
<!-- test dependencies -->
|
||||
<dependency>
|
||||
@@ -291,12 +286,11 @@
|
||||
<swagger-core-version>1.5.18</swagger-core-version>
|
||||
<okhttp-version>2.7.5</okhttp-version>
|
||||
<gson-version>2.8.1</gson-version>
|
||||
<commons-lang3-version>3.8.1</commons-lang3-version>
|
||||
{{#joda}}
|
||||
<jodatime-version>2.9.9</jodatime-version>
|
||||
<jodatime-version>2.9.9</jodatime-version>
|
||||
{{/joda}}
|
||||
{{#threetenbp}}
|
||||
<threetenbp-version>1.3.5</threetenbp-version>
|
||||
<threetenbp-version>1.3.5</threetenbp-version>
|
||||
{{/threetenbp}}
|
||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||
<junit-version>4.12</junit-version>
|
||||
|
||||
@@ -6,7 +6,6 @@ version = '{{artifactVersion}}'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
|
||||
@@ -6,7 +6,6 @@ version = '{{artifactVersion}}'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
|
||||
@@ -6,7 +6,6 @@ version = '{{artifactVersion}}'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user