mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2026-03-18 03:49:12 +00:00
Rust server html (#1329)
Builds on #1180 by @colelawrence. This addition to the rust-server generator enables the use of text/html responses as plaintext. I've added an html endpoint to the sample to demonstrate that this works (and fixed the problem that that uncovered).
This commit is contained in:
@@ -474,6 +474,10 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
return mimetype.toLowerCase(Locale.ROOT).startsWith("text/plain");
|
||||
}
|
||||
|
||||
boolean isMimetypeHtmlText(String mimetype) {
|
||||
return mimetype.toLowerCase(Locale.ROOT).startsWith("text/html");
|
||||
}
|
||||
|
||||
boolean isMimetypeWwwFormUrlEncoded(String mimetype) {
|
||||
return mimetype.toLowerCase(Locale.ROOT).startsWith("application/x-www-form-urlencoded");
|
||||
}
|
||||
@@ -544,6 +548,8 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
consumesXml = true;
|
||||
} else if (isMimetypePlainText(mimeType)) {
|
||||
consumesPlainText = true;
|
||||
} else if (isMimetypeHtmlText(mimeType)) {
|
||||
consumesPlainText = true;
|
||||
} else if (isMimetypeWwwFormUrlEncoded(mimeType)) {
|
||||
additionalProperties.put("usesUrlEncodedForm", true);
|
||||
}
|
||||
@@ -570,6 +576,8 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
producesXml = true;
|
||||
} else if (isMimetypePlainText(mimeType)) {
|
||||
producesPlainText = true;
|
||||
} else if (isMimetypeHtmlText(mimeType)) {
|
||||
producesPlainText = true;
|
||||
}
|
||||
|
||||
mediaType.put("mediaType", mimeType);
|
||||
@@ -662,7 +670,7 @@ public class RustServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
if (isMimetypeXml(mediaType)) {
|
||||
additionalProperties.put("usesXml", true);
|
||||
consumesXml = true;
|
||||
} else if (isMimetypePlainText(mediaType)) {
|
||||
} else if (isMimetypePlainText(mediaType) || isMimetypeHtmlText(mediaType)) {
|
||||
consumesPlainText = true;
|
||||
} else if (isMimetypeWwwFormUrlEncoded(mediaType)) {
|
||||
additionalProperties.put("usesUrlEncodedForm", true);
|
||||
|
||||
Reference in New Issue
Block a user