Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,6 @@ private void flattenContent(Content content, String name) {
gatherInlineModels(schema, schemaName);
if (isModelNeeded(schema)) {
// If this schema should be split into its own model, do so
//Schema refSchema = this.makeSchema(schemaName, schema);
mediaType.setSchema(this.makeSchemaInComponents(schemaName, schema));
}
}
Expand Down Expand Up @@ -806,29 +805,6 @@ private void flattenComponents() {
}
}

/**
* This function fix models that are string (mostly enum). Before this fix, the
* example would look something like that in the doc: "\"example from def\""
*
* @param m Schema implementation
*/
private void fixStringModel(Schema m) {
if (schemaIsOfType(m, "string") && schemaContainsExample(m)) {
String example = m.getExample().toString();
if (example.startsWith("\"") && example.endsWith("\"")) {
m.setExample(example.substring(1, example.length() - 1));
}
}
}

private boolean schemaIsOfType(Schema m, String type) {
return m.getType() != null && m.getType().equals(type);
}

private boolean schemaContainsExample(Schema m) {
return m.getExample() != null && m.getExample() != "";
}

/**
* Generates a unique model name. Non-alphanumeric characters will be replaced
* with underscores
Expand Down Expand Up @@ -1143,19 +1119,6 @@ private Schema makeSchemaInComponents(String name, Schema schema) {
return refSchema;
}

/**
* Make a Schema
*
* @param ref new property name
* @param property Schema
* @return {@link Schema} A constructed OpenAPI property
*/
private Schema makeSchema(String ref, Schema property) {
Schema newProperty = new Schema().$ref(ref);
this.copyVendorExtensions(property, newProperty);
return newProperty;
}

/**
* Copy vendor extensions from Model to another Model
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
// Common media types.
private static final String APPLICATION_XML = "application/xml";
private static final String TEXT_XML = "text/xml";
private static final String APPLICATION_OCTET_STREAM = "application/octet-stream";
private static final String TEXT_PLAIN = "text/plain";
private static final String APPLICATION_JSON = "application/json";
private static final String APPLICATION_X_WWW_FORM_URLENCODED = "application/x-www-form-urlencoded";
Expand Down Expand Up @@ -1208,10 +1207,6 @@ private boolean isMimetypeMultipartFormData(String mimetype) {
return mimetype.toLowerCase(Locale.ROOT).startsWith("multipart/form-data");
}

private boolean isMimetypeOctetStream(String mimetype) {
return mimetype.toLowerCase(Locale.ROOT).startsWith(APPLICATION_OCTET_STREAM);
}

private boolean isMimetypeMultipartRelated(String mimetype) {
return mimetype.toLowerCase(Locale.ROOT).startsWith("multipart/related");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

package org.openapitools.codegen.languages;

import com.google.common.base.Strings;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.MapSchema;
import io.swagger.v3.oas.models.media.Schema;
Expand Down Expand Up @@ -472,33 +471,6 @@ public ModelsMap postProcessModels(ModelsMap objs) {
return postProcessModelsEnum(objs);
}

/* the following function is not used anywhere in this class so we'll remove it later
private static String getAccept(Operation operation) {
String accepts = null;
String defaultContentType = "application/json";
if (operation.getProduces() != null && !operation.getProduces().isEmpty()) {
StringBuilder sb = new StringBuilder();
for (String produces : operation.getProduces()) {
if (defaultContentType.equalsIgnoreCase(produces)) {
accepts = defaultContentType;
break;
} else {
if (sb.length() > 0) {
sb.append(",");
}
sb.append(produces);
}
}
if (accepts == null) {
accepts = sb.toString();
}
} else {
accepts = defaultContentType;
}

return accepts;
}*/

@Override
protected boolean needToImport(String type) {
return super.needToImport(type) && type.indexOf(".") < 0;
Expand Down Expand Up @@ -574,21 +546,6 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation
return op;
}

private static String sanitizePackageName(String packageName) {
packageName = packageName.trim(); // FIXME: a parameter should not be assigned. Also declare the methods parameters as 'final'.
packageName = packageName.replaceAll("[^a-zA-Z0-9_\\.]", "_");
if (Strings.isNullOrEmpty(packageName)) {
return "invalidPackageName";
}
return packageName;
}


private String sanitizePath(String p) {
//prefer replace a ", instead of a fuLL URL encode for readability
return p.replaceAll("\"", "%22");
}

@Override
public String toRegularExpression(String pattern) {
return escapeText(pattern);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,21 +272,6 @@ private void postProcessSingleOperation(OperationMap operations, CodegenOperatio
}
}

/**
* postProcessSingleParam - Modifies a single parameter, adjusting generated
* data types for Header and Query parameters.
*
* @param param CodegenParameter to be modified.
*/
private static void postProcessSingleParam(CodegenParameter param) {
if (param.isQueryParam) {
param.dataType = "std::optional<" + param.dataType + ">";
if (!param.isPrimitiveType) {
param.baseType = "std::optional<" + param.baseType + ">";
}
}
}

@Override
public String toModelFilename(String name) {
return toModelName(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,21 +275,6 @@ private void postProcessSingleOperation(OperationMap operations, CodegenOperatio
}
}

/**
* postProcessSingleParam - Modifies a single parameter, adjusting generated
* data types for Header and Query parameters.
*
* @param param CodegenParameter to be modified.
*/
private static void postProcessSingleParam(CodegenParameter param) {
if (param.isQueryParam) {
param.dataType = "std::optional<" + param.dataType + ">";
if (!param.isPrimitiveType) {
param.baseType = "std::optional<" + param.baseType + ">";
}
}
}

@Override
public String toModelFilename(String name) {
return toModelName(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -861,12 +861,6 @@ public CodegenModel fromModel(String name, Schema model) {
return codegenModel;
}

/*
private String sanitizePath(String p) {
//prefer replace a ', instead of a fuLL URL encode for readability
return p.replaceAll("'", "%27");
}*/

private String trimBrackets(String s) {
if (s != null) {
int beginIdx = s.charAt(0) == '[' ? 1 : 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -892,12 +892,6 @@ public CodegenModel fromModel(String name, Schema model) {
return codegenModel;
}

/*
private String sanitizePath(String p) {
//prefer replace a ', instead of a fuLL URL encode for readability
return p.replaceAll("'", "%27");
}*/

private String trimBrackets(String s) {
if (s != null) {
int beginIdx = s.charAt(0) == '[' ? 1 : 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -856,10 +856,6 @@ private boolean isKtor() {
return Constants.KTOR.equals(library);
}

private boolean isKtor2() {
return Constants.KTOR2.equals(library);
}

/** Computes the longest common path prefix shared by all operations. */
private static String computeCommonPath(List<CodegenOperation> ops) {
String commonPath = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ public class RustServerCodegen extends AbstractRustCodegen implements CodegenCon

private static final String xmlMimeType = "application/xml";
private static final String textXmlMimeType = "text/xml";
private static final String octetMimeType = "application/octet-stream";
private static final String plainTextMimeType = "text/plain";
private static final String jsonMimeType = "application/json";

Expand Down Expand Up @@ -429,10 +428,6 @@ private boolean isMimetypeMultipartFormData(String mimetype) {
return mimetype.toLowerCase(Locale.ROOT).startsWith("multipart/form-data");
}

private boolean isMimetypeOctetStream(String mimetype) {
return mimetype.toLowerCase(Locale.ROOT).startsWith(octetMimeType);
}

private boolean isMimetypeMultipartRelated(String mimetype) {
return mimetype.toLowerCase(Locale.ROOT).startsWith("multipart/related");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,10 +417,6 @@ private boolean isMimetypeMultipartFormData(String mimetype) {
return mimetype.toLowerCase(Locale.ROOT).startsWith("multipart/form-data");
}

private boolean isMimetypeOctetStream(String mimetype) {
return mimetype.toLowerCase(Locale.ROOT).startsWith(octetMimeType);
}

private boolean isMimetypeMultipartRelated(String mimetype) {
return mimetype.toLowerCase(Locale.ROOT).startsWith("multipart/related");
}
Expand Down
Loading