minor improve to rust server (#5020)

This commit is contained in:
William Cheng 2020-01-17 18:54:31 +08:00 committed by GitHub
parent 67d23fcf7e
commit 3f074a280a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 8 deletions

View File

@ -544,7 +544,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
} }
private boolean isMimetypePlain(String mimetype) { private boolean isMimetypePlain(String mimetype) {
return isMimetypePlainText(mimetype) || isMimetypeHtmlText(mimetype) || isMimetypeOctetStream(mimetype); return isMimetypePlainText(mimetype) || isMimetypeHtmlText(mimetype) || isMimetypeOctetStream(mimetype);
} }
@Override @Override
@ -560,7 +560,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
pathFormatString = pathFormatString.replace(paramSearch, paramReplace); pathFormatString = pathFormatString.replace(paramSearch, paramReplace);
} }
op.vendorExtensions.put("pathFormatString", pathFormatString); op.vendorExtensions.put("x-path-format-string", pathFormatString);
// The Rust code will need to contain a series of regular expressions. // The Rust code will need to contain a series of regular expressions.
// For performance, we'll construct these at start-of-day and re-use // For performance, we'll construct these at start-of-day and re-use
@ -1019,7 +1019,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
am.getItems() != null && am.getItems() != null &&
!StringUtils.isEmpty(am.getItems().get$ref())) { !StringUtils.isEmpty(am.getItems().get$ref())) {
Schema inner_schema = allDefinitions.get( Schema inner_schema = allDefinitions.get(
ModelUtils.getSimpleRef(am.getItems().get$ref())); ModelUtils.getSimpleRef(am.getItems().get$ref()));
if (inner_schema.getXml() != null && if (inner_schema.getXml() != null &&
inner_schema.getXml().getName() != null) { inner_schema.getXml().getName() != null) {
@ -1271,9 +1271,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
// the user than the alternative. // the user than the alternative.
LOGGER.warn("Ignoring additionalProperties (see https://github.com/OpenAPITools/openapi-generator/issues/318) alongside defined properties"); LOGGER.warn("Ignoring additionalProperties (see https://github.com/OpenAPITools/openapi-generator/issues/318) alongside defined properties");
cm.dataType = null; cm.dataType = null;
} } else {
else
{
String type; String type;
if (typeMapping.containsKey(cm.additionalPropertiesType)) { if (typeMapping.containsKey(cm.additionalPropertiesType)) {

View File

@ -262,7 +262,7 @@ impl<F, C> Api<C> for Client<F> where
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}} {{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}
fn {{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}(&self{{#allParams}}, param_{{{paramName}}}: {{^required}}Option<{{/required}}{{#isListContainer}}&{{/isListContainer}}{{{dataType}}}{{^required}}>{{/required}}{{/allParams}}, context: &C) -> Box<dyn Future<Item={{{operationId}}}Response, Error=ApiError>> { fn {{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}(&self{{#allParams}}, param_{{{paramName}}}: {{^required}}Option<{{/required}}{{#isListContainer}}&{{/isListContainer}}{{{dataType}}}{{^required}}>{{/required}}{{/allParams}}, context: &C) -> Box<dyn Future<Item={{{operationId}}}Response, Error=ApiError>> {
let mut uri = format!( let mut uri = format!(
"{}{{{basePathWithoutHost}}}{{#vendorExtensions}}{{pathFormatString}}{{/vendorExtensions}}", "{}{{{basePathWithoutHost}}}{{{vendorExtensions.x-path-format-string}}}",
self.base_path{{#pathParams}}, {{{paramName}}}=utf8_percent_encode(&param_{{{paramName}}}.to_string(), ID_ENCODE_SET){{/pathParams}} self.base_path{{#pathParams}}, {{{paramName}}}=utf8_percent_encode(&param_{{{paramName}}}.to_string(), ID_ENCODE_SET){{/pathParams}}
); );

View File

@ -996,7 +996,7 @@ paths:
schema: schema:
type: string type: string
responses: responses:
200: "200":
content: {} content: {}
description: Success description: Success
tags: tags: