Skip to content

Commit 37e8cfa

Browse files
authored
minor imrovemets to julia generators (#14560)
1 parent fd45b74 commit 37e8cfa

7 files changed

Lines changed: 109 additions & 44 deletions

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,7 @@ Here is a list of template creators:
961961
* JavaScript (Closure-annotated Angular) @achew22
962962
* JavaScript (Flow types) @jaypea
963963
* JMeter: @davidkiss
964+
* Julia: @tanmaykm
964965
* Kotlin: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
965966
* Kotlin (MultiPlatform): @andrewemery
966967
* Kotlin (Volley): @alisters
@@ -1028,6 +1029,7 @@ Here is a list of template creators:
10281029
* JAX-RS CXF: @hiveship
10291030
* JAX-RS CXF (CDI): @nickcmaynard
10301031
* JAX-RS RestEasy (JBoss EAP): @jfiala
1032+
* Julia: @tanmaykm
10311033
* Kotlin: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
10321034
* Kotlin (Spring Boot): @dr4ke616
10331035
* Kotlin (Vertx): @Wooyme
@@ -1120,6 +1122,7 @@ If you want to join the committee, please kindly apply by sending an email to te
11201122
| Java | @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10) |
11211123
| Java Spring | @cachescrubber (2022/02) @welshm (2022/02) @MelleD (2022/02) @atextor (2022/02) @manedev79 (2022/02) @javisst (2022/02) @borsch (2022/02) @banlevente (2022/02) @Zomzog (2022/09) |
11221124
| JMeter | @kannkyo (2021/01) |
1125+
| Julia | @tanmaykm (2023/01) |
11231126
| Kotlin | @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert), @dr4ke616 (2018/08) @karismann (2019/03) @Zomzog (2019/04) @andrewemery (2019/10) @4brunu (2019/11) @yutaka0m (2020/03) |
11241127
| Lua | @daurnimator (2017/08) |
11251128
| Nim | |

docs/generators.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The following generators are available:
4040
* [javascript-flowtyped](generators/javascript-flowtyped.md)
4141
* [jaxrs-cxf-client](generators/jaxrs-cxf-client.md)
4242
* [jmeter](generators/jmeter.md)
43-
* [julia-client](generators/julia-client.md)
43+
* [julia-client (beta)](generators/julia-client.md)
4444
* [k6 (beta)](generators/k6.md)
4545
* [kotlin](generators/kotlin.md)
4646
* [lua (beta)](generators/lua.md)
@@ -111,7 +111,7 @@ The following generators are available:
111111
* [jaxrs-resteasy](generators/jaxrs-resteasy.md)
112112
* [jaxrs-resteasy-eap](generators/jaxrs-resteasy-eap.md)
113113
* [jaxrs-spec](generators/jaxrs-spec.md)
114-
* [julia-server](generators/julia-server.md)
114+
* [julia-server (beta)](generators/julia-server.md)
115115
* [kotlin-server](generators/kotlin-server.md)
116116
* [kotlin-spring](generators/kotlin-spring.md)
117117
* [kotlin-vertx (beta)](generators/kotlin-vertx.md)

docs/generators/julia-client.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ title: Documentation for the julia-client Generator
77
| Property | Value | Notes |
88
| -------- | ----- | ----- |
99
| generator name | julia-client | pass this to the generate command after -g |
10-
| generator stability | STABLE | |
10+
| generator stability | BETA | |
1111
| generator type | CLIENT | |
1212
| generator language | Julia | |
1313
| generator default templating engine | mustache | |

docs/generators/julia-server.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ title: Documentation for the julia-server Generator
77
| Property | Value | Notes |
88
| -------- | ----- | ----- |
99
| generator name | julia-server | pass this to the generate command after -g |
10-
| generator stability | STABLE | |
10+
| generator stability | BETA | |
1111
| generator type | SERVER | |
1212
| generator language | Julia | |
1313
| generator default templating engine | mustache | |

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJuliaCodegen.java

Lines changed: 55 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package org.openapitools.codegen.languages;
218

319
import org.openapitools.codegen.*;
@@ -12,13 +28,15 @@
1228

1329
import java.io.File;
1430
import java.util.*;
31+
1532
import io.swagger.v3.oas.models.media.Schema;
1633
import io.swagger.v3.oas.models.media.ArraySchema;
1734
import io.swagger.v3.oas.models.parameters.Parameter;
1835
import io.swagger.v3.oas.models.Operation;
1936
import io.swagger.v3.oas.models.servers.Server;
2037

2138
import org.apache.commons.lang3.StringUtils;
39+
2240
import static org.openapitools.codegen.utils.StringUtils.camelize;
2341

2442
import org.openapitools.codegen.utils.CamelizeOption;
@@ -50,42 +68,42 @@ public AbstractJuliaCodegen() {
5068
super();
5169

5270
modifyFeatureSet(features -> features
53-
.includeDocumentationFeatures(DocumentationFeature.Readme)
54-
.includeSchemaSupportFeatures(
55-
SchemaSupportFeature.Union, SchemaSupportFeature.allOf,
56-
SchemaSupportFeature.anyOf, SchemaSupportFeature.oneOf
57-
)
58-
.excludeWireFormatFeatures(
59-
WireFormatFeature.XML
60-
)
61-
.excludeSecurityFeatures(
62-
SecurityFeature.OAuth2_Implicit, SecurityFeature.OAuth2_Password,
63-
SecurityFeature.OAuth2_ClientCredentials, SecurityFeature.OAuth2_AuthorizationCode
64-
)
65-
.excludeParameterFeatures(
66-
ParameterFeature.Cookie
67-
)
68-
.excludeGlobalFeatures(
69-
GlobalFeature.Callbacks, GlobalFeature.Examples,
70-
GlobalFeature.Produces, GlobalFeature.Consumes
71-
)
72-
.includeClientModificationFeatures(
73-
ClientModificationFeature.BasePath, ClientModificationFeature.UserAgent
74-
)
71+
.includeDocumentationFeatures(DocumentationFeature.Readme)
72+
.includeSchemaSupportFeatures(
73+
SchemaSupportFeature.Union, SchemaSupportFeature.allOf,
74+
SchemaSupportFeature.anyOf, SchemaSupportFeature.oneOf
75+
)
76+
.excludeWireFormatFeatures(
77+
WireFormatFeature.XML
78+
)
79+
.excludeSecurityFeatures(
80+
SecurityFeature.OAuth2_Implicit, SecurityFeature.OAuth2_Password,
81+
SecurityFeature.OAuth2_ClientCredentials, SecurityFeature.OAuth2_AuthorizationCode
82+
)
83+
.excludeParameterFeatures(
84+
ParameterFeature.Cookie
85+
)
86+
.excludeGlobalFeatures(
87+
GlobalFeature.Callbacks, GlobalFeature.Examples,
88+
GlobalFeature.Produces, GlobalFeature.Consumes
89+
)
90+
.includeClientModificationFeatures(
91+
ClientModificationFeature.BasePath, ClientModificationFeature.UserAgent
92+
)
7593
);
7694

77-
reservedWords = new HashSet<String> (
78-
Arrays.asList(
79-
"if", "else", "elseif", "while", "for", "begin", "end", "quote",
80-
"try", "catch", "return", "local", "function", "macro", "ccall", "finally", "break", "continue",
81-
"global", "module", "using", "import", "export", "const", "let", "do", "baremodule",
82-
"Type", "Enum", "Any", "DataType", "Base"
83-
)
95+
reservedWords = new HashSet<String>(
96+
Arrays.asList(
97+
"if", "else", "elseif", "while", "for", "begin", "end", "quote",
98+
"try", "catch", "return", "local", "function", "macro", "ccall", "finally", "break", "continue",
99+
"global", "module", "using", "import", "export", "const", "let", "do", "baremodule",
100+
"Type", "Enum", "Any", "DataType", "Base"
101+
)
84102
);
85103

86104
// Language Specific Primitives. These types will not trigger imports by the client generator
87105
languageSpecificPrimitives = new HashSet<String>(
88-
Arrays.asList("Integer", "Int128", "Int64", "Int32", "Int16", "Int8", "UInt128", "UInt64", "UInt32", "UInt16", "UInt8", "Float64", "Float32", "Float16", "Char", "Vector", "Dict", "Vector{UInt8}", "Bool", "String", "Date", "DateTime", "ZonedDateTime", "Nothing", "Any")
106+
Arrays.asList("Integer", "Int128", "Int64", "Int32", "Int16", "Int8", "UInt128", "UInt64", "UInt32", "UInt16", "UInt8", "Float64", "Float32", "Float16", "Char", "Vector", "Dict", "Vector{UInt8}", "Bool", "String", "Date", "DateTime", "ZonedDateTime", "Nothing", "Any")
89107
);
90108

91109
typeMapping.clear();
@@ -141,7 +159,7 @@ protected static String dropDots(String str) {
141159
/**
142160
* Escapes a reserved word as defined in the `reservedWords` array. Handle escaping
143161
* those terms here. This logic is only called if a variable matches the reseved words
144-
*
162+
*
145163
* @return the escaped term
146164
*/
147165
@Override
@@ -331,7 +349,7 @@ public String getSchemaType(Schema schema) {
331349

332350
if (typeMapping.containsKey(openAPIType)) {
333351
type = typeMapping.get(openAPIType);
334-
if(languageSpecificPrimitives.contains(type)) {
352+
if (languageSpecificPrimitives.contains(type)) {
335353
return type;
336354
}
337355
} else {
@@ -343,6 +361,7 @@ public String getSchemaType(Schema schema) {
343361

344362
/**
345363
* Return the default value of the property
364+
*
346365
* @param schema OpenAPI property object
347366
* @return string presentation of the default value of the property
348367
*/
@@ -381,7 +400,8 @@ public String escapeUnsafeCharacters(String input) {
381400
}
382401

383402
/**
384-
* Escape single and/or double quote to avoid code injection
403+
* Escape single and/or double quote to avoid code injection
404+
*
385405
* @param input String to be cleaned up
386406
* @return string with quotation mark removed or escaped
387407
*/
@@ -425,7 +445,7 @@ public CodegenParameter fromParameter(Parameter param, Set<String> imports) {
425445
* @param schema OAS property schema
426446
* @param required true if the property is required in the next higher object schema, false otherwise
427447
* @return Codegen Property object
428-
*/
448+
*/
429449
@Override
430450
public CodegenProperty fromProperty(String name, Schema schema, boolean required) {
431451
CodegenProperty property = super.fromProperty(name, schema, required);
@@ -464,7 +484,7 @@ private void changeParamNames(List<CodegenParameter> paramsList, HashSet<String>
464484
}
465485
}
466486
}
467-
487+
468488
/**
469489
* Convert OAS Operation object to Codegen Operation object
470490
*

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JuliaClientCodegen.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
1+
/*
2+
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package org.openapitools.codegen.languages;
218

319
import org.openapitools.codegen.*;
20+
import org.openapitools.codegen.meta.GeneratorMetadata;
21+
import org.openapitools.codegen.meta.Stability;
422

523
import java.io.File;
624

7-
public class JuliaClientCodegen extends AbstractJuliaCodegen {
25+
public class JuliaClientCodegen extends AbstractJuliaCodegen {
826
/**
927
* Configures the type of generator.
1028
*
@@ -38,6 +56,10 @@ public String getHelp() {
3856
public JuliaClientCodegen() {
3957
super();
4058

59+
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
60+
.stability(Stability.BETA)
61+
.build();
62+
4163
outputFolder = "generated-code" + File.separator + "julia-client";
4264
modelTemplateFiles.put("model.mustache", ".jl");
4365
apiTemplateFiles.put("api.mustache", ".jl");
@@ -61,8 +83,7 @@ public void processOpts() {
6183
super.processOpts();
6284
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
6385
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
64-
}
65-
else {
86+
} else {
6687
setPackageName("APIClient");
6788
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
6889
}

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JuliaServerCodegen.java

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
1+
/*
2+
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
117
package org.openapitools.codegen.languages;
218

319
import org.openapitools.codegen.*;
20+
import org.openapitools.codegen.meta.GeneratorMetadata;
21+
import org.openapitools.codegen.meta.Stability;
422

523
import java.io.File;
624

@@ -38,6 +56,10 @@ public String getHelp() {
3856
public JuliaServerCodegen() {
3957
super();
4058

59+
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
60+
.stability(Stability.BETA)
61+
.build();
62+
4163
outputFolder = "generated-code" + File.separator + "julia-server";
4264
modelTemplateFiles.put("model.mustache", ".jl");
4365
apiTemplateFiles.put("api.mustache", ".jl");
@@ -58,8 +80,7 @@ public void processOpts() {
5880
super.processOpts();
5981
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
6082
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
61-
}
62-
else {
83+
} else {
6384
setPackageName("APIServer");
6485
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
6586
}

0 commit comments

Comments
 (0)