-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
[BUG] new.sh fix generator type #9321
Conversation
new.sh
Outdated
@@ -205,7 +205,7 @@ cat > "${root}/bin/configs/${gen_name_camel}-${gen_type}-petstore-new.yaml"<<EOF | |||
generatorName: ${gen_name_camel} | |||
outputDir: samples/${gen_type}/petstore/${gen_name_camel_path} | |||
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml | |||
templateDir: modules/openapi-generator/src/main/resources/${gen_name_camel} | |||
templateDir: modules/openapi-generator/src/main/resources/${gen_name_camel}-${gen_type} |
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.
@AndersSpringborg thanks for the PR but I think we usually use the generator name directly as the template folder name (e.g. lua, perl) without adding the generator type (e.g. client, server)
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.
Oh yeah, i see what you mean!
If you follow the instruction on how to make a new client generator, for a new platform, it throws an exception, that it cannot find that template. I'll look into what course the problem tomorrow 😊
Exception in thread "main" java.lang.IllegalArgumentException: Template directory modules/openapi-generator/src/main/resources/test does not exist.
at org.openapitools.codegen.config.WorkflowSettings$Builder.withTemplateDir(WorkflowSettings.java:503)
at org.openapitools.codegen.config.WorkflowSettings.newBuilder(WorkflowSettings.java:124)
at org.openapitools.codegen.config.DynamicSettings.getWorkflowSettings(DynamicSettings.java:84)
at org.openapitools.codegen.config.CodegenConfigurator.fromFile(CodegenConfigurator.java:91)
at org.openapitools.codegen.cmd.Generate.execute(Generate.java:272)
at org.openapitools.codegen.cmd.OpenApiGeneratorCommand.run(OpenApiGeneratorCommand.java:32)
at org.openapitools.codegen.OpenAPIGenerator.main(OpenAPIGenerator.java:66)
```
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.
In the the script, the template folder is created with ${gen_name_camel}-${gen_type}
Lines 193 to 200 in 0f5e7d1
# Step 3: Create resource files | |
mkdir -p "${root}/modules/openapi-generator/src/main/resources/${gen_name_camel}-${gen_type}" | |
echo "Creating modules/openapi-generator/src/main/resources/${gen_name_camel}-${gen_type}/README.mustache" && \ | |
touch "${root}/modules/openapi-generator/src/main/resources/${gen_name_camel}-${gen_type}/README.mustache" | |
echo "Creating modules/openapi-generator/src/main/resources/${gen_name_camel}-${gen_type}/model.mustache" && \ | |
touch "${root}/modules/openapi-generator/src/main/resources/${gen_name_camel}-${gen_type}/model.mustache" | |
echo "Creating modules/openapi-generator/src/main/resources/${gen_name_camel}-${gen_type}/api.mustache" && \ | |
touch "${root}/modules/openapi-generator/src/main/resources/${gen_name_camel}-${gen_type}/api.mustache" |
So the template dir in the config, should have the same path
Line 208 in 0f5e7d1
templateDir: modules/openapi-generator/src/main/resources/${gen_name_camel} |
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.
Good point. What about updating these lines instead following the convention that I mentioned?
# Step 3: Create resource files
mkdir -p "${root}/modules/openapi-generator/src/main/resources/${gen_name_camel}-${gen_type}"
echo "Creating modules/openapi-generator/src/main/resources/${gen_name_camel}-${gen_type}/README.mustache" && \
touch "${root}/modules/openapi-generator/src/main/resources/${gen_name_camel}-${gen_type}/README.mustache"
echo "Creating modules/openapi-generator/src/main/resources/${gen_name_camel}-${gen_type}/model.mustache" && \
touch "${root}/modules/openapi-generator/src/main/resources/${gen_name_camel}-${gen_type}/model.mustache"
echo "Creating modules/openapi-generator/src/main/resources/${gen_name_camel}-${gen_type}/api.mustache" && \
touch "${root}/modules/openapi-generator/src/main/resources/${gen_name_camel}-${gen_type}/api.mustache"
cc @jimschubert
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.
Let me know if that's how you want the script to work! I'll go through it, and make sure it works with this naming convention
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.
Please update based on #9321 (comment). Thank you.
Tested and looks good
|
This is a small fix, for generating a new template. It helps getting started.
I found the issue today, as I was making a new generator.
I've made a Issue, describing the problem #9320
PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*
.For Windows users, please run the script in Git BASH.
master
,5.1.x
,6.0.x