minor imrovemets to julia generators (#14560)

This commit is contained in:
William Cheng 2023-01-30 20:20:45 +08:00 committed by GitHub
parent fd45b74128
commit 37e8cfadc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 109 additions and 44 deletions

View File

@ -961,6 +961,7 @@ Here is a list of template creators:
* JavaScript (Closure-annotated Angular) @achew22 * JavaScript (Closure-annotated Angular) @achew22
* JavaScript (Flow types) @jaypea * JavaScript (Flow types) @jaypea
* JMeter: @davidkiss * JMeter: @davidkiss
* Julia: @tanmaykm
* Kotlin: @jimschubert [:heart:](https://www.patreon.com/jimschubert) * Kotlin: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
* Kotlin (MultiPlatform): @andrewemery * Kotlin (MultiPlatform): @andrewemery
* Kotlin (Volley): @alisters * Kotlin (Volley): @alisters
@ -1028,6 +1029,7 @@ Here is a list of template creators:
* JAX-RS CXF: @hiveship * JAX-RS CXF: @hiveship
* JAX-RS CXF (CDI): @nickcmaynard * JAX-RS CXF (CDI): @nickcmaynard
* JAX-RS RestEasy (JBoss EAP): @jfiala * JAX-RS RestEasy (JBoss EAP): @jfiala
* Julia: @tanmaykm
* Kotlin: @jimschubert [:heart:](https://www.patreon.com/jimschubert) * Kotlin: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
* Kotlin (Spring Boot): @dr4ke616 * Kotlin (Spring Boot): @dr4ke616
* Kotlin (Vertx): @Wooyme * Kotlin (Vertx): @Wooyme
@ -1120,6 +1122,7 @@ If you want to join the committee, please kindly apply by sending an email to te
| 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) | | 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) |
| 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) | | 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) |
| JMeter | @kannkyo (2021/01) | | JMeter | @kannkyo (2021/01) |
| Julia | @tanmaykm (2023/01) |
| 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) | | 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) |
| Lua | @daurnimator (2017/08) | | Lua | @daurnimator (2017/08) |
| Nim | | | Nim | |

View File

@ -40,7 +40,7 @@ The following generators are available:
* [javascript-flowtyped](generators/javascript-flowtyped.md) * [javascript-flowtyped](generators/javascript-flowtyped.md)
* [jaxrs-cxf-client](generators/jaxrs-cxf-client.md) * [jaxrs-cxf-client](generators/jaxrs-cxf-client.md)
* [jmeter](generators/jmeter.md) * [jmeter](generators/jmeter.md)
* [julia-client](generators/julia-client.md) * [julia-client (beta)](generators/julia-client.md)
* [k6 (beta)](generators/k6.md) * [k6 (beta)](generators/k6.md)
* [kotlin](generators/kotlin.md) * [kotlin](generators/kotlin.md)
* [lua (beta)](generators/lua.md) * [lua (beta)](generators/lua.md)
@ -111,7 +111,7 @@ The following generators are available:
* [jaxrs-resteasy](generators/jaxrs-resteasy.md) * [jaxrs-resteasy](generators/jaxrs-resteasy.md)
* [jaxrs-resteasy-eap](generators/jaxrs-resteasy-eap.md) * [jaxrs-resteasy-eap](generators/jaxrs-resteasy-eap.md)
* [jaxrs-spec](generators/jaxrs-spec.md) * [jaxrs-spec](generators/jaxrs-spec.md)
* [julia-server](generators/julia-server.md) * [julia-server (beta)](generators/julia-server.md)
* [kotlin-server](generators/kotlin-server.md) * [kotlin-server](generators/kotlin-server.md)
* [kotlin-spring](generators/kotlin-spring.md) * [kotlin-spring](generators/kotlin-spring.md)
* [kotlin-vertx (beta)](generators/kotlin-vertx.md) * [kotlin-vertx (beta)](generators/kotlin-vertx.md)

View File

@ -7,7 +7,7 @@ title: Documentation for the julia-client Generator
| Property | Value | Notes | | Property | Value | Notes |
| -------- | ----- | ----- | | -------- | ----- | ----- |
| generator name | julia-client | pass this to the generate command after -g | | generator name | julia-client | pass this to the generate command after -g |
| generator stability | STABLE | | | generator stability | BETA | |
| generator type | CLIENT | | | generator type | CLIENT | |
| generator language | Julia | | | generator language | Julia | |
| generator default templating engine | mustache | | | generator default templating engine | mustache | |

View File

@ -7,7 +7,7 @@ title: Documentation for the julia-server Generator
| Property | Value | Notes | | Property | Value | Notes |
| -------- | ----- | ----- | | -------- | ----- | ----- |
| generator name | julia-server | pass this to the generate command after -g | | generator name | julia-server | pass this to the generate command after -g |
| generator stability | STABLE | | | generator stability | BETA | |
| generator type | SERVER | | | generator type | SERVER | |
| generator language | Julia | | | generator language | Julia | |
| generator default templating engine | mustache | | | generator default templating engine | mustache | |

View File

@ -1,3 +1,19 @@
/*
* 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
*
* https://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; package org.openapitools.codegen.languages;
import org.openapitools.codegen.*; import org.openapitools.codegen.*;
@ -12,6 +28,7 @@ import org.openapitools.codegen.meta.features.WireFormatFeature;
import java.io.File; import java.io.File;
import java.util.*; import java.util.*;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.parameters.Parameter; import io.swagger.v3.oas.models.parameters.Parameter;
@ -19,6 +36,7 @@ import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.servers.Server; import io.swagger.v3.oas.models.servers.Server;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;
import org.openapitools.codegen.utils.CamelizeOption; import org.openapitools.codegen.utils.CamelizeOption;
@ -50,42 +68,42 @@ public abstract class AbstractJuliaCodegen extends DefaultCodegen {
super(); super();
modifyFeatureSet(features -> features modifyFeatureSet(features -> features
.includeDocumentationFeatures(DocumentationFeature.Readme) .includeDocumentationFeatures(DocumentationFeature.Readme)
.includeSchemaSupportFeatures( .includeSchemaSupportFeatures(
SchemaSupportFeature.Union, SchemaSupportFeature.allOf, SchemaSupportFeature.Union, SchemaSupportFeature.allOf,
SchemaSupportFeature.anyOf, SchemaSupportFeature.oneOf SchemaSupportFeature.anyOf, SchemaSupportFeature.oneOf
) )
.excludeWireFormatFeatures( .excludeWireFormatFeatures(
WireFormatFeature.XML WireFormatFeature.XML
) )
.excludeSecurityFeatures( .excludeSecurityFeatures(
SecurityFeature.OAuth2_Implicit, SecurityFeature.OAuth2_Password, SecurityFeature.OAuth2_Implicit, SecurityFeature.OAuth2_Password,
SecurityFeature.OAuth2_ClientCredentials, SecurityFeature.OAuth2_AuthorizationCode SecurityFeature.OAuth2_ClientCredentials, SecurityFeature.OAuth2_AuthorizationCode
) )
.excludeParameterFeatures( .excludeParameterFeatures(
ParameterFeature.Cookie ParameterFeature.Cookie
) )
.excludeGlobalFeatures( .excludeGlobalFeatures(
GlobalFeature.Callbacks, GlobalFeature.Examples, GlobalFeature.Callbacks, GlobalFeature.Examples,
GlobalFeature.Produces, GlobalFeature.Consumes GlobalFeature.Produces, GlobalFeature.Consumes
) )
.includeClientModificationFeatures( .includeClientModificationFeatures(
ClientModificationFeature.BasePath, ClientModificationFeature.UserAgent ClientModificationFeature.BasePath, ClientModificationFeature.UserAgent
) )
); );
reservedWords = new HashSet<String> ( reservedWords = new HashSet<String>(
Arrays.asList( Arrays.asList(
"if", "else", "elseif", "while", "for", "begin", "end", "quote", "if", "else", "elseif", "while", "for", "begin", "end", "quote",
"try", "catch", "return", "local", "function", "macro", "ccall", "finally", "break", "continue", "try", "catch", "return", "local", "function", "macro", "ccall", "finally", "break", "continue",
"global", "module", "using", "import", "export", "const", "let", "do", "baremodule", "global", "module", "using", "import", "export", "const", "let", "do", "baremodule",
"Type", "Enum", "Any", "DataType", "Base" "Type", "Enum", "Any", "DataType", "Base"
) )
); );
// Language Specific Primitives. These types will not trigger imports by the client generator // Language Specific Primitives. These types will not trigger imports by the client generator
languageSpecificPrimitives = new HashSet<String>( languageSpecificPrimitives = new HashSet<String>(
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") 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")
); );
typeMapping.clear(); typeMapping.clear();
@ -141,7 +159,7 @@ public abstract class AbstractJuliaCodegen extends DefaultCodegen {
/** /**
* Escapes a reserved word as defined in the `reservedWords` array. Handle escaping * Escapes a reserved word as defined in the `reservedWords` array. Handle escaping
* those terms here. This logic is only called if a variable matches the reseved words * those terms here. This logic is only called if a variable matches the reseved words
* *
* @return the escaped term * @return the escaped term
*/ */
@Override @Override
@ -331,7 +349,7 @@ public abstract class AbstractJuliaCodegen extends DefaultCodegen {
if (typeMapping.containsKey(openAPIType)) { if (typeMapping.containsKey(openAPIType)) {
type = typeMapping.get(openAPIType); type = typeMapping.get(openAPIType);
if(languageSpecificPrimitives.contains(type)) { if (languageSpecificPrimitives.contains(type)) {
return type; return type;
} }
} else { } else {
@ -343,6 +361,7 @@ public abstract class AbstractJuliaCodegen extends DefaultCodegen {
/** /**
* Return the default value of the property * Return the default value of the property
*
* @param schema OpenAPI property object * @param schema OpenAPI property object
* @return string presentation of the default value of the property * @return string presentation of the default value of the property
*/ */
@ -381,7 +400,8 @@ public abstract class AbstractJuliaCodegen extends DefaultCodegen {
} }
/** /**
* Escape single and/or double quote to avoid code injection * Escape single and/or double quote to avoid code injection
*
* @param input String to be cleaned up * @param input String to be cleaned up
* @return string with quotation mark removed or escaped * @return string with quotation mark removed or escaped
*/ */
@ -425,7 +445,7 @@ public abstract class AbstractJuliaCodegen extends DefaultCodegen {
* @param schema OAS property schema * @param schema OAS property schema
* @param required true if the property is required in the next higher object schema, false otherwise * @param required true if the property is required in the next higher object schema, false otherwise
* @return Codegen Property object * @return Codegen Property object
*/ */
@Override @Override
public CodegenProperty fromProperty(String name, Schema schema, boolean required) { public CodegenProperty fromProperty(String name, Schema schema, boolean required) {
CodegenProperty property = super.fromProperty(name, schema, required); CodegenProperty property = super.fromProperty(name, schema, required);
@ -464,7 +484,7 @@ public abstract class AbstractJuliaCodegen extends DefaultCodegen {
} }
} }
} }
/** /**
* Convert OAS Operation object to Codegen Operation object * Convert OAS Operation object to Codegen Operation object
* *

View File

@ -1,10 +1,28 @@
/*
* 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
*
* https://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; package org.openapitools.codegen.languages;
import org.openapitools.codegen.*; import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability;
import java.io.File; import java.io.File;
public class JuliaClientCodegen extends AbstractJuliaCodegen { public class JuliaClientCodegen extends AbstractJuliaCodegen {
/** /**
* Configures the type of generator. * Configures the type of generator.
* *
@ -38,6 +56,10 @@ public class JuliaClientCodegen extends AbstractJuliaCodegen {
public JuliaClientCodegen() { public JuliaClientCodegen() {
super(); super();
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
.stability(Stability.BETA)
.build();
outputFolder = "generated-code" + File.separator + "julia-client"; outputFolder = "generated-code" + File.separator + "julia-client";
modelTemplateFiles.put("model.mustache", ".jl"); modelTemplateFiles.put("model.mustache", ".jl");
apiTemplateFiles.put("api.mustache", ".jl"); apiTemplateFiles.put("api.mustache", ".jl");
@ -61,8 +83,7 @@ public class JuliaClientCodegen extends AbstractJuliaCodegen {
super.processOpts(); super.processOpts();
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) { if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME)); setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
} } else {
else {
setPackageName("APIClient"); setPackageName("APIClient");
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName); additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
} }

View File

@ -1,6 +1,24 @@
/*
* 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
*
* https://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; package org.openapitools.codegen.languages;
import org.openapitools.codegen.*; import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability;
import java.io.File; import java.io.File;
@ -38,6 +56,10 @@ public class JuliaServerCodegen extends AbstractJuliaCodegen {
public JuliaServerCodegen() { public JuliaServerCodegen() {
super(); super();
generatorMetadata = GeneratorMetadata.newBuilder(generatorMetadata)
.stability(Stability.BETA)
.build();
outputFolder = "generated-code" + File.separator + "julia-server"; outputFolder = "generated-code" + File.separator + "julia-server";
modelTemplateFiles.put("model.mustache", ".jl"); modelTemplateFiles.put("model.mustache", ".jl");
apiTemplateFiles.put("api.mustache", ".jl"); apiTemplateFiles.put("api.mustache", ".jl");
@ -58,8 +80,7 @@ public class JuliaServerCodegen extends AbstractJuliaCodegen {
super.processOpts(); super.processOpts();
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) { if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME)); setPackageName((String) additionalProperties.get(CodegenConstants.PACKAGE_NAME));
} } else {
else {
setPackageName("APIServer"); setPackageName("APIServer");
additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName); additionalProperties.put(CodegenConstants.PACKAGE_NAME, packageName);
} }