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 (Flow types) @jaypea
* JMeter: @davidkiss
* Julia: @tanmaykm
* Kotlin: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
* Kotlin (MultiPlatform): @andrewemery
* Kotlin (Volley): @alisters
@ -1028,6 +1029,7 @@ Here is a list of template creators:
* JAX-RS CXF: @hiveship
* JAX-RS CXF (CDI): @nickcmaynard
* JAX-RS RestEasy (JBoss EAP): @jfiala
* Julia: @tanmaykm
* Kotlin: @jimschubert [:heart:](https://www.patreon.com/jimschubert)
* Kotlin (Spring Boot): @dr4ke616
* 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 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) |
| 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) |
| Lua | @daurnimator (2017/08) |
| Nim | |

View File

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

View File

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

View File

@ -7,7 +7,7 @@ title: Documentation for the julia-server Generator
| Property | Value | Notes |
| -------- | ----- | ----- |
| generator name | julia-server | pass this to the generate command after -g |
| generator stability | STABLE | |
| generator stability | BETA | |
| generator type | SERVER | |
| generator language | Julia | |
| 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;
import org.openapitools.codegen.*;
@ -12,6 +28,7 @@ import org.openapitools.codegen.meta.features.WireFormatFeature;
import java.io.File;
import java.util.*;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.media.ArraySchema;
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 org.apache.commons.lang3.StringUtils;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import org.openapitools.codegen.utils.CamelizeOption;
@ -50,42 +68,42 @@ public abstract class AbstractJuliaCodegen extends DefaultCodegen {
super();
modifyFeatureSet(features -> features
.includeDocumentationFeatures(DocumentationFeature.Readme)
.includeSchemaSupportFeatures(
SchemaSupportFeature.Union, SchemaSupportFeature.allOf,
SchemaSupportFeature.anyOf, SchemaSupportFeature.oneOf
)
.excludeWireFormatFeatures(
WireFormatFeature.XML
)
.excludeSecurityFeatures(
SecurityFeature.OAuth2_Implicit, SecurityFeature.OAuth2_Password,
SecurityFeature.OAuth2_ClientCredentials, SecurityFeature.OAuth2_AuthorizationCode
)
.excludeParameterFeatures(
ParameterFeature.Cookie
)
.excludeGlobalFeatures(
GlobalFeature.Callbacks, GlobalFeature.Examples,
GlobalFeature.Produces, GlobalFeature.Consumes
)
.includeClientModificationFeatures(
ClientModificationFeature.BasePath, ClientModificationFeature.UserAgent
)
.includeDocumentationFeatures(DocumentationFeature.Readme)
.includeSchemaSupportFeatures(
SchemaSupportFeature.Union, SchemaSupportFeature.allOf,
SchemaSupportFeature.anyOf, SchemaSupportFeature.oneOf
)
.excludeWireFormatFeatures(
WireFormatFeature.XML
)
.excludeSecurityFeatures(
SecurityFeature.OAuth2_Implicit, SecurityFeature.OAuth2_Password,
SecurityFeature.OAuth2_ClientCredentials, SecurityFeature.OAuth2_AuthorizationCode
)
.excludeParameterFeatures(
ParameterFeature.Cookie
)
.excludeGlobalFeatures(
GlobalFeature.Callbacks, GlobalFeature.Examples,
GlobalFeature.Produces, GlobalFeature.Consumes
)
.includeClientModificationFeatures(
ClientModificationFeature.BasePath, ClientModificationFeature.UserAgent
)
);
reservedWords = new HashSet<String> (
Arrays.asList(
"if", "else", "elseif", "while", "for", "begin", "end", "quote",
"try", "catch", "return", "local", "function", "macro", "ccall", "finally", "break", "continue",
"global", "module", "using", "import", "export", "const", "let", "do", "baremodule",
"Type", "Enum", "Any", "DataType", "Base"
)
reservedWords = new HashSet<String>(
Arrays.asList(
"if", "else", "elseif", "while", "for", "begin", "end", "quote",
"try", "catch", "return", "local", "function", "macro", "ccall", "finally", "break", "continue",
"global", "module", "using", "import", "export", "const", "let", "do", "baremodule",
"Type", "Enum", "Any", "DataType", "Base"
)
);
// Language Specific Primitives. These types will not trigger imports by the client generator
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();
@ -141,7 +159,7 @@ public abstract class AbstractJuliaCodegen extends DefaultCodegen {
/**
* 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
*
*
* @return the escaped term
*/
@Override
@ -331,7 +349,7 @@ public abstract class AbstractJuliaCodegen extends DefaultCodegen {
if (typeMapping.containsKey(openAPIType)) {
type = typeMapping.get(openAPIType);
if(languageSpecificPrimitives.contains(type)) {
if (languageSpecificPrimitives.contains(type)) {
return type;
}
} else {
@ -343,6 +361,7 @@ public abstract class AbstractJuliaCodegen extends DefaultCodegen {
/**
* Return the default value of the property
*
* @param schema OpenAPI property object
* @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
* @return string with quotation mark removed or escaped
*/
@ -425,7 +445,7 @@ public abstract class AbstractJuliaCodegen extends DefaultCodegen {
* @param schema OAS property schema
* @param required true if the property is required in the next higher object schema, false otherwise
* @return Codegen Property object
*/
*/
@Override
public CodegenProperty fromProperty(String name, Schema schema, boolean 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
*

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