-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Package config with dynamic package name processing + more #14
Closed
Closed
Changes from 14 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
c8f6731
feat: dynamic package name via post-processing
gkocak-scottlogic fc8b016
fix: apiTemplates change
gkocak-scottlogic 2b8839b
fix: return body string
gkocak-scottlogic c70fd5a
feat: model split hack
gkocak-scottlogic 0fae95c
chore: run prettier
gkocak-scottlogic 065a600
fix: shelljs dev dep
gkocak-scottlogic 9ba381f
fix: change model fix from class regex to java parser
gkocak-scottlogic b539222
chore: error propagation in model fix
gkocak-scottlogic 4e1e0cf
fix: make classes public on model split
gkocak-scottlogic aad08db
chore: split move file logic
gkocak-scottlogic 5e3b702
chore: change default package name to com.openapi.forge
gkocak-scottlogic f1b4c09
fix: remove model split logic from branch
gkocak-scottlogic 36cba53
fix: remove java-parser from deps
gkocak-scottlogic 443f636
chore: add description to post process move
gkocak-scottlogic cd3775e
fix: cookie headers in requests
ms14981 94aed9f
feat: change adding headers to requests.
gkocak-scottlogic f288e24
fix: cookie headers when more than one cookie
ms14981 85e46fa
fix: cookie headers when more than one cookie
ms14981 bd9f349
feat: add httpResponse wrapping
gkocak-scottlogic 4d3f6de
chore: simplify response object creation in handlebar
gkocak-scottlogic 8436a0a
fix: safeTypeConvert void wrapping
gkocak-scottlogic d20674e
chore: tidy http response
gkocak-scottlogic effac7d
chore: change var names in constructor and order
gkocak-scottlogic eb48380
feat: change adding headers to requests.
gkocak-scottlogic c0ef017
feat: add httpResponse wrapping
gkocak-scottlogic eebe839
chore: simplify response object creation in handlebar
gkocak-scottlogic 496f245
fix: safeTypeConvert void wrapping
gkocak-scottlogic c13a7a3
feat: add httpResponse wrapping
gkocak-scottlogic 8a3b7c2
fix: safeTypeConvert void wrapping
gkocak-scottlogic 343d112
feat: add httpResponse wrapping
gkocak-scottlogic c27e399
fix: safeTypeConvert void wrapping
gkocak-scottlogic d218f18
feat: add httpResponse wrapping
gkocak-scottlogic 4319447
fix: safeTypeConvert void wrapping
gkocak-scottlogic f84de8c
feat: change adding headers to requests.
gkocak-scottlogic 82ececb
fix: cookie headers when more than one cookie
ms14981 e370518
feat: add httpResponse wrapping
gkocak-scottlogic bd1ca3f
chore: simplify response object creation in handlebar
gkocak-scottlogic 849e73f
feat: change adding headers to requests.
gkocak-scottlogic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"package": { | ||
"default": "com.openapi.forge", | ||
"description": "The package for the generated classes." | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,19 @@ | ||
const prettier_cli = require("prettier/cli.js"); | ||
|
||
const logLevels = [ | ||
/* quiet */ | ||
"silent", | ||
/* standard */ | ||
"warn", | ||
/* verbose */ | ||
"debug", | ||
]; | ||
|
||
module.exports = (folder, logLevel) => { | ||
return prettier_cli.run(["--write", folder, "--loglevel", logLevels[logLevel]]); | ||
}; | ||
/* quiet */ | ||
"silent", | ||
/* standard */ | ||
"warn", | ||
/* verbose */ | ||
"debug", | ||
]; | ||
|
||
module.exports = (folder, logLevel) => { | ||
return prettier_cli.run([ | ||
"--write", | ||
folder, | ||
"--loglevel", | ||
logLevels[logLevel], | ||
]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,19 @@ | ||
const typeConvert = require("./typeConvert"); | ||
|
||
const complexReturnType = (responseSchema) => { | ||
const responseType = typeConvert(responseSchema); | ||
switch (responseType) { | ||
case "boolean": | ||
case "int": | ||
case "long": | ||
case "float": | ||
case "double": | ||
case "String": | ||
return false; | ||
case "Date": | ||
default: | ||
return true; | ||
} | ||
} | ||
const complexReturnType = (responseSchema) => { | ||
const responseType = typeConvert(responseSchema); | ||
switch (responseType) { | ||
case "boolean": | ||
case "int": | ||
case "long": | ||
case "float": | ||
case "double": | ||
case "String": | ||
return false; | ||
case "Date": | ||
default: | ||
return true; | ||
} | ||
}; | ||
|
||
module.exports = complexReturnType; | ||
module.exports = complexReturnType; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
const queryType = (key) => { | ||
if (key == 'delete') { | ||
return '.delete()'; | ||
} else if (key == "put") { | ||
return '.put(RequestBody.create("", null))' | ||
} else if (key == "post") { | ||
return '.post(RequestBody.create("", null))' | ||
} else { | ||
return ''; | ||
} | ||
if (key == "delete") { | ||
return ".delete()"; | ||
} else if (key == "put") { | ||
return '.put(RequestBody.create("", null))'; | ||
} else if (key == "post") { | ||
return '.post(RequestBody.create("", null))'; | ||
} else { | ||
return ""; | ||
} | ||
}; | ||
|
||
module.exports = queryType; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
const toParamNameCapital = (name) => { | ||
name = name.replace(/[^a-z0-9_]/gi, ""); | ||
return name.charAt(0).toUpperCase() + name.substr(1); | ||
}; | ||
|
||
module.exports = toParamNameCapital; | ||
|
||
name = name.replace(/[^a-z0-9_]/gi, ""); | ||
return name.charAt(0).toUpperCase() + name.substr(1); | ||
}; | ||
|
||
module.exports = toParamNameCapital; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const move_files = require("./postProcessMoveFiles"); | ||
|
||
module.exports = (folder, _, options) => { | ||
move_files(folder, options); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
const shell = require("shelljs"); | ||
|
||
// To match the java package/folder conventions, the java files that are generated from handlebars templates | ||
// should be moved to src/main/java/<package_folder>. | ||
// The package folder name comes from the generator options and that can given as a command line argument | ||
// by --generator.package | ||
|
||
module.exports = (folder, options) => { | ||
gkocak-scottlogic marked this conversation as resolved.
Show resolved
Hide resolved
|
||
var package_name = options["generator.package"]; | ||
var package_folder = package_name.replaceAll(".", "/"); | ||
java_path = "src/main/java/" + package_folder; | ||
shell.cd(folder); | ||
shell.mkdir("-p", java_path); | ||
shell.mv("-f", "*.java", java_path); | ||
}; |
2 changes: 1 addition & 1 deletion
2
...mple/springboot/ApiClient.java.handlebars → template/ApiClient.java.handlebars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ample/springboot/ApiModel.java.handlebars → template/ApiModel.java.handlebars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...le/springboot/Application.java.handlebars → template/Application.java.handlebars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../springboot/Configuration.java.handlebars → template/Configuration.java.handlebars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ple/springboot/IApiClient.java.handlebars → template/IApiClient.java.handlebars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.example.springboot; | ||
package {{_options.[generator.package]}}; | ||
|
||
import java.util.List; | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Were we going to put formatting under the banner of post-processing? This would have the benefit of the main forge only needing to know about post-processing in general, not formatting. Although this would need changes to the other generators, I don't think those changes will be very significant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that formatting is actually a post-processing stage and it would make sense every language to do their formating in this stage. And I also agree that it's not a big change either. Maybe we can discuss this change over the demo meeting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realise that we didn't end up chatting about this. Did you want to message Colin about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, we forgot to chat about this. And since the post-processing is already merged at the main repo alongside with formatting, we can keep the logic as is in this PR at least. I can open a ticket/issue to track the merge of formatting into post-processing.