Conversation
ddobrin
left a comment
There was a problem hiding this comment.
Hi @dz-1 :
[1] could you please add a default to the openAPIGenerator class, for the generation of the environment variables:
...
boolean generateEnvVars = false; // I would suggest false as a default, to preserve the existing behaviour for developers
...
// if developers wish to use it, they set it in the config.json and your code makes use of it
boolean generateEnvVars = config.toBoolean("generateEnvVars");
....
[2] after the feature is merged, could we also update the document in the doc.networknt.com site?
|
@ddobrin |
|
@dz-1 I might understand it incorrectly, however, if we wish to generate environment variables, we set it in the config.json and set it to true. In the case of it being set to false, whether by default, or by explicitly adding it to config.json, it is set to false and the files are copied as is. We agreed that in the interest of time, this is good for this release. If it would be only for my current client, I would set a default to true, as I know that this is what they'll use and what they asked for, however wouldn't wish to impose this on the community at large. Let's leave that part as-is then, no issue. |
|
@ddobrin |
|
@dz-1 could you please contact me directly, I'd like to provide some feedback, and ask a question, as I have encountered a different behaviour than expected |
|
@dz-1 and I had a chat and looked into some behaviour directly |
|
Looking at issue #216 and the discussions within, I am afraid that we might have to add an additional flag: "replace lists/maps" or not, as values.yml is not auto-generated and would not get these values automatically. I'll look more into it later |
ddobrin
left a comment
There was a problem hiding this comment.
@dz-1 :
Please allow me to make some recommendations which might be helpful and will address these fixes for this release. I leave this up to you to address.
-
You have added a class and method called: YAMLFileParameterizer.rewrite(), as static. this is fine.
-
Instead of adding those 9 YML files, which the code doesn't use actually, you can add 9 rocker.raw files and render them from within the code, as is, unchanged.
ex:
L.177: transfer(targetPath, ("src.main.resources.config").replace(".", separator), "mask.yml", templates.rest.maskYml.template());
You can add for example:
an auditYml.rocker.raw files and add the line
transfer(targetPath, ("src.main.resources.config").replace(".", separator), "audit.yml", templates.rest.auditYml.template());
-
with these changes, if a developer doesn't wish envVars, the developer gets all files, as listed in handler.yml and he/she can work on it as they see fit
-
if we wish now to add functionality to add env Vars, we won't do it for every file, for example handler.yml, and we have full control, as follows:
- each line listing a config file to which we wish to add envVars can be adapted to include the call to YAMLFileParameterizer.rewrite(), retaining individualized control
-
The line:
if (config.keys().contains(GENERATE_ENV_VARS)) {
YAMLFileParameterizer.rewriteAll(..)
is not required anymore, as we actually do not wish to replace all YML files, only those YML files which can make good use of env vras, as in : server, service, datasource, audit, correlationid, etc -
In the next release, we make make this list of files generic, pass it in, etc, however that's next release
|
@ddobrin |
|
@dz-1 While I do not know why we would have two copies of the YML files, I leave this up to you to propose an implementation. As this is at code generation time, do we need to add |
|
@ddobrin |
|
But this folder is just for the temporary solution. It won't be needed if we decide to load configuration files from classpath. |
|
@ddobrin I have also changed the config item |
|
@dz-1 [1] The yml format would be invalid since lack of space after the colon But it should be Otherwise, the server wouldn't work properly and an exception is thrown [2] Only the 9 new files can be rewritten, but previous config file(server.yml, service.yml...) cannot be rewritten since they are generated from rocker instead from YAMLFileParameterizer. [3] If do not provide "generateEnvVars" in config.json. These 9 new config files would not be generated. In my opinion, generate these config files and rewrite them are separate issue, they maybe shouldn't affect each other. So, I think no matter whether "generateEnvVars" is in config.json or not. These files should be generated. |
|
@jiachen1120 |
|
@jiachen1120 Could you verify the formatting now? |
|
@dz-1 Yes, the format is correct now. |
|
@jiachen1120 : @dz-1 and me met yesterday and went over the aspects you were inquiring about |
|
@ddobrin
|
|
Hi @dz-1, could we have a pr to the light-docs repo about this change linked here? |
|
@NicholasAzar done. |
|
Linking: networknt/light-doc@e9d37fd |
Please review the changes for #216 and #217.
This change takes the simple approach. More specifically, all
.ymlfiles in thesrc/main/resources/config/folder will be re-written as per the requirement. Currently, I copied the following files to this folder. Users can add more if they want. Unit testOpenApiGeneratorTest.testGeneratorYaml()can be used to generate the config files.-metrics.yml
-correlation.yml
-traceability.yml
-audit.yml
-body.yml
-sanitizer.yml
-openapi-validator.yml
-health.yml
-info.yml
Array and Map are processed as per @jiachen1120's suggestion. But the processing of
values.ymlis not coded. I assume that's already in place.