[core] cleanup: remove OpenAPI parameter from CodegenConfig methods (#1953)

* Add OpenAPI parameter to DefaultCodegen#toDefaultValue(..)

* Remove CodegenConfig#fromOperation()

* Remove allDefinitions parameter from fromModel(..)

* Remove definitions parameter from CodegenConfig#fromOperation(..)

* remove schemas parameter from DefaultCodegen#fromRequestBody(..)

* remove schemas parameter from DefaultCodegen#fromCallback(..)

* Remove openAPI parameter from CodegenConfig#fromModel(..)

* Remove openAPI parameter from CodegenConfig#fromOperation(..)

* Remove openAPI parameter from DefaultCodegen#fromProperty(..)

* Remove openAPI parameter from DefaultCodegen#fromParameter(..)

* Remove OpenAPI parameter from several methods

* Use ModelUtils.getReferencedParameter(..)

* Remove unused variable

* Remove openAPI parameter from DefaultCodegen#fromResponse(..)

* Remove openAPI parameter from DefaultCodegen#addHeaders(..)

* Remove from addConsumesInfo(..)/addProducesInfo(..)

* Improve test: add property to prevent Pet from being a free-form object

* remove globalSchemas Map<String, Schema>

* remove deprecated method: postProcessOperations()

* Remove 'Map<String, Schema> allSchemas' from addProperties(..)

* Remove 'Map<String, Schema> allDefinitions' from createDiscriminator(..)

* Remove 'Map<String, Schema> allSchemas' from unaliasPropertySchema(..)

* Rename globalOpenAPI to openAPI

* Update documentation

* Run “Optimize import” in IntelliJ IDEA
This commit is contained in:
Jérémie Bresson 2019-01-28 09:19:36 +01:00 committed by William Cheng
parent 6f16b45976
commit 046db19a85
243 changed files with 1368 additions and 2121 deletions

View File

@ -22,6 +22,24 @@ The option is replaced with `-g` (`--generator-name`).
* `-g` allows the same values as `-l` * `-g` allows the same values as `-l`
* See `list` command for the list of generator name * See `list` command for the list of generator name
==== Access OpenAPI instance as member and not as parameter
If you are creating or extending a generator (programmatically), you might have use one of the following parameters: `OpenAPI openAPI` or `Map<String, Schema> allDefinitions` or `Map<String, Schema> allSchemas`. Example methods:
* `CodegenConfig#fromOperation(String, String, Operation, Map<String, Schema>, OpenAPI)`
* `CodegenConfig#fromModel(String, Schema, Map<String, Schema>)`
* `DefaultCodegen#fromResponse(OpenAPI, String, ApiResponse)`
* `DefaultCodegen#DefaultCodegen.fromRequestBody(RequestBody, Map<String, Schema>, Set<String>, String)`
* `DefaultCodegen#createDiscriminator(String, Schema, Map<String, Schema>)`
* ...
The parameters (`openAPI`, `allDefinitions`, `allSchemas` ...) are now removed from the methods.
To access the current OpenAPI instance, if you are extending `DefaultCodegen` you can use the protected `openAPI` member.
If you are creating your own generator by implementing `CodegenConfig`, then the setter `CodegenConfig.setOpenAPI(OpenAPI)` will be called.
You can keep a reference on the `OpenAPI` instance.
=== From 3.1.x to 3.2.0 === From 3.1.x to 3.2.0
Version `3.2.0` is a minor version of OpenAPI-Generator, in comparison to `3.1.x` it contains some breaking changes, but with the possibility to fallback to the old behavior. Version `3.2.0` is a minor version of OpenAPI-Generator, in comparison to `3.1.x` it contains some breaking changes, but with the possibility to fallback to the old behavior.

View File

@ -19,14 +19,13 @@ package config;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map; import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ConfigParser { public class ConfigParser {
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigParser.class); private static final Logger LOGGER = LoggerFactory.getLogger(ConfigParser.class);

View File

@ -17,24 +17,15 @@
package org.openapitools.codegen; package org.openapitools.codegen;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
import java.nio.file.Paths;
import java.util.Scanner;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.*;
import java.nio.file.Paths;
import java.util.Scanner;
import java.util.regex.Pattern;
public abstract class AbstractGenerator { public abstract class AbstractGenerator {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractGenerator.class); private static final Logger LOGGER = LoggerFactory.getLogger(AbstractGenerator.class);

View File

@ -18,7 +18,6 @@
package org.openapitools.codegen; package org.openapitools.codegen;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.v3.parser.util.SchemaTypeUtil; import io.swagger.v3.parser.util.SchemaTypeUtil;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;

View File

@ -19,9 +19,10 @@ package org.openapitools.codegen;
import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.parser.core.models.AuthorizationValue; import io.swagger.v3.parser.core.models.AuthorizationValue;
import java.util.List;
import org.openapitools.codegen.auth.AuthParser; import org.openapitools.codegen.auth.AuthParser;
import java.util.List;
public class ClientOptInput { public class ClientOptInput {
private CodegenConfig config; private CodegenConfig config;
private ClientOpts opts; private ClientOpts opts;

View File

@ -17,11 +17,11 @@
package org.openapitools.codegen; package org.openapitools.codegen;
import org.openapitools.codegen.auth.AuthMethod;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.openapitools.codegen.auth.AuthMethod;
public class ClientOpts { public class ClientOpts {
protected String uri; protected String uri;
protected String target; protected String target;

View File

@ -18,7 +18,6 @@
package org.openapitools.codegen; package org.openapitools.codegen;
import com.samskivert.mustache.Mustache.Compiler; import com.samskivert.mustache.Mustache.Compiler;
import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
@ -27,7 +26,6 @@ import io.swagger.v3.oas.models.servers.Server;
import io.swagger.v3.oas.models.servers.ServerVariable; import io.swagger.v3.oas.models.servers.ServerVariable;
import java.io.File; import java.io.File;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
@ -111,11 +109,9 @@ public interface CodegenConfig {
void setOutputDir(String dir); void setOutputDir(String dir);
CodegenModel fromModel(String name, Schema schema, Map<String, Schema> allDefinitions); CodegenModel fromModel(String name, Schema schema);
CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation, Map<String, Schema> definitions, OpenAPI openAPI); CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation);
CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation, Map<String, Schema> definitions);
List<CodegenSecurity> fromSecurity(Map<String, SecurityScheme> schemas); List<CodegenSecurity> fromSecurity(Map<String, SecurityScheme> schemas);
@ -179,14 +175,6 @@ public interface CodegenConfig {
Map<String, Object> postProcessModels(Map<String, Object> objs); Map<String, Object> postProcessModels(Map<String, Object> objs);
/**
* @deprecated use {@link #postProcessOperationsWithModels(Map, List)} instead. This method will be removed
* @param objs the objects map that will be passed to the templating engine
* @return the the objects map instance.
*/
@Deprecated
Map<String, Object> postProcessOperations(Map<String, Object> objs);
Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels); Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels);
Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs); Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs);
@ -266,9 +254,10 @@ public interface CodegenConfig {
void setEnablePostProcessFile(boolean isEnablePostProcessFile); void setEnablePostProcessFile(boolean isEnablePostProcessFile);
// set OpenAPI and schemas /**
void setGlobalOpenAPI(OpenAPI openAPI); * Set the OpenAPI instance. This method needs to be called right after the instantiation of the Codegen class.
* @param openAPI specification being generated
void setGlobalSchemas(OpenAPI openAPI); */
void setOpenAPI(OpenAPI openAPI);
} }

View File

@ -17,12 +17,12 @@
package org.openapitools.codegen; package org.openapitools.codegen;
import static java.util.ServiceLoader.load;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.ServiceLoader; import java.util.ServiceLoader;
import static java.util.ServiceLoader.load;
public class CodegenConfigLoader { public class CodegenConfigLoader {
/** /**
* Tries to load config class with SPI first, then with class name directly from classpath * Tries to load config class with SPI first, then with class name directly from classpath

View File

@ -2,7 +2,10 @@ package org.openapitools.codegen;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import java.util.*; import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
public class CodegenDiscriminator { public class CodegenDiscriminator {
private String propertyName; private String propertyName;

View File

@ -17,13 +17,12 @@
package org.openapitools.codegen; package org.openapitools.codegen;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.v3.oas.models.ExternalDocumentation; import io.swagger.v3.oas.models.ExternalDocumentation;
import org.apache.commons.lang3.builder.ToStringBuilder;
import java.util.*; import java.util.*;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.apache.commons.lang3.builder.ToStringBuilder;
@JsonIgnoreProperties({"parentModel", "interfaceModels"}) @JsonIgnoreProperties({"parentModel", "interfaceModels"})
public class CodegenModel { public class CodegenModel {
public String parent, parentSchema; public String parent, parentSchema;

View File

@ -20,14 +20,7 @@ package org.openapitools.codegen;
import io.swagger.v3.oas.models.ExternalDocumentation; import io.swagger.v3.oas.models.ExternalDocumentation;
import io.swagger.v3.oas.models.tags.Tag; import io.swagger.v3.oas.models.tags.Tag;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
public class CodegenOperation { public class CodegenOperation {
public final List<CodegenProperty> responseHeaders = new ArrayList<CodegenProperty>(); public final List<CodegenProperty> responseHeaders = new ArrayList<CodegenProperty>();

View File

@ -17,8 +17,6 @@
package org.openapitools.codegen; package org.openapitools.codegen;
import io.swagger.v3.oas.models.security.Scopes;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;

View File

@ -20,25 +20,14 @@ package org.openapitools.codegen;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.google.common.base.CaseFormat; import com.google.common.base.CaseFormat;
import com.samskivert.mustache.Mustache.Compiler; import com.samskivert.mustache.Mustache.Compiler;
import io.swagger.v3.core.util.Json; import io.swagger.v3.core.util.Json;
import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.callbacks.Callback; import io.swagger.v3.oas.models.callbacks.Callback;
import io.swagger.v3.oas.models.examples.Example; import io.swagger.v3.oas.models.examples.Example;
import io.swagger.v3.oas.models.headers.Header; import io.swagger.v3.oas.models.headers.Header;
import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.oas.models.media.ComposedSchema; import io.swagger.v3.oas.models.parameters.*;
import io.swagger.v3.oas.models.media.Content;
import io.swagger.v3.oas.models.media.MediaType;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.media.StringSchema;
import io.swagger.v3.oas.models.parameters.CookieParameter;
import io.swagger.v3.oas.models.parameters.HeaderParameter;
import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.parameters.PathParameter;
import io.swagger.v3.oas.models.parameters.QueryParameter;
import io.swagger.v3.oas.models.parameters.RequestBody;
import io.swagger.v3.oas.models.responses.ApiResponse; import io.swagger.v3.oas.models.responses.ApiResponse;
import io.swagger.v3.oas.models.responses.ApiResponses; import io.swagger.v3.oas.models.responses.ApiResponses;
import io.swagger.v3.oas.models.security.OAuthFlow; import io.swagger.v3.oas.models.security.OAuthFlow;
@ -47,7 +36,6 @@ import io.swagger.v3.oas.models.security.SecurityScheme;
import io.swagger.v3.oas.models.servers.Server; import io.swagger.v3.oas.models.servers.Server;
import io.swagger.v3.oas.models.servers.ServerVariable; import io.swagger.v3.oas.models.servers.ServerVariable;
import io.swagger.v3.parser.util.SchemaTypeUtil; import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -61,29 +49,14 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeSet;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.*;
import static org.openapitools.codegen.utils.StringUtils.escape;
import static org.openapitools.codegen.utils.StringUtils.underscore;
public class DefaultCodegen implements CodegenConfig { public class DefaultCodegen implements CodegenConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultCodegen.class); private static final Logger LOGGER = LoggerFactory.getLogger(DefaultCodegen.class);
@ -139,9 +112,8 @@ public class DefaultCodegen implements CodegenConfig {
// flag to indicate whether to use environment variable to post process file // flag to indicate whether to use environment variable to post process file
protected boolean enablePostProcessFile = false; protected boolean enablePostProcessFile = false;
// make openapi and schemas available to all methods // make openapi available to all methods
protected OpenAPI globalOpenAPI; protected OpenAPI openAPI;
protected Map<String, Schema> globalSchemas;
public List<CliOption> cliOptions() { public List<CliOption> cliOptions() {
return cliOptions; return cliOptions;
@ -445,36 +417,9 @@ public class DefaultCodegen implements CodegenConfig {
} }
} }
@Override
/** public void setOpenAPI(OpenAPI openAPI) {
* Set global OpenAPI based on OpenAPI object this.openAPI = openAPI;
*
* @param openAPI OpenAPI object
*/
public void setGlobalOpenAPI(OpenAPI openAPI) {
this.globalOpenAPI = openAPI;
}
/**
* Set global schema based on OpenAPI object
*
* @param openAPI OpenAPI object
*/
public void setGlobalSchemas(OpenAPI openAPI) {
if (openAPI != null && openAPI.getComponents() != null) {
this.globalSchemas = openAPI.getComponents().getSchemas();
}
if (this.globalSchemas == null) { // initalize with empty map if it's null
this.globalSchemas = new HashMap<String, Schema>();
}
}
// override with any special post-processing
@SuppressWarnings("static-method")
public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
return objs;
} }
// override with any special post-processing // override with any special post-processing
@ -1415,7 +1360,7 @@ public class DefaultCodegen implements CodegenConfig {
} }
private String getSingleSchemaType(Schema schema) { private String getSingleSchemaType(Schema schema) {
Schema unaliasSchema = ModelUtils.unaliasSchema(globalSchemas, schema); Schema unaliasSchema = ModelUtils.unaliasSchema(this.openAPI, schema);
if (StringUtils.isNotBlank(unaliasSchema.get$ref())) { // reference to another definition/schema if (StringUtils.isNotBlank(unaliasSchema.get$ref())) { // reference to another definition/schema
// get the schema/model name from $ref // get the schema/model name from $ref
@ -1616,17 +1561,17 @@ public class DefaultCodegen implements CodegenConfig {
* *
* @param name the name of the model * @param name the name of the model
* @param schema OAS Model object * @param schema OAS Model object
* @param allDefinitions a map of all OAS models from the spec
* @return Codegen Model object * @return Codegen Model object
*/ */
public CodegenModel fromModel(String name, Schema schema, Map<String, Schema> allDefinitions) { public CodegenModel fromModel(String name, Schema schema) {
Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI);
if (typeAliases == null) { if (typeAliases == null) {
// Only do this once during first call // Only do this once during first call
typeAliases = getAllAliases(allDefinitions); typeAliases = getAllAliases(allDefinitions);
} }
// unalias schema // unalias schema
schema = ModelUtils.unaliasSchema(allDefinitions, schema); schema = ModelUtils.unaliasSchema(this.openAPI, schema);
if (schema == null) { if (schema == null) {
LOGGER.warn("Schema {} not found", name); LOGGER.warn("Schema {} not found", name);
return null; return null;
@ -1651,7 +1596,7 @@ public class DefaultCodegen implements CodegenConfig {
m.getVendorExtensions().putAll(schema.getExtensions()); m.getVendorExtensions().putAll(schema.getExtensions());
} }
m.isAlias = typeAliases.containsKey(name); m.isAlias = typeAliases.containsKey(name);
m.discriminator = createDiscriminator(name, schema, allDefinitions); m.discriminator = createDiscriminator(name, schema);
if (schema.getXml() != null) { if (schema.getXml() != null) {
m.xmlPrefix = schema.getXml().getPrefix(); m.xmlPrefix = schema.getXml().getPrefix();
@ -1684,7 +1629,7 @@ public class DefaultCodegen implements CodegenConfig {
for (Schema innerSchema : composed.getAllOf()) { // TOOD need to work with anyOf, oneOf as well for (Schema innerSchema : composed.getAllOf()) { // TOOD need to work with anyOf, oneOf as well
if (m.discriminator == null) { if (m.discriminator == null) {
LOGGER.debug("discriminator is set to null (not correctly set earlier): {}", name); LOGGER.debug("discriminator is set to null (not correctly set earlier): {}", name);
m.discriminator = createDiscriminator(name, schema, allDefinitions); m.discriminator = createDiscriminator(name, schema);
} }
if (innerSchema.getXml() != null) { if (innerSchema.getXml() != null) {
@ -1723,13 +1668,13 @@ public class DefaultCodegen implements CodegenConfig {
if (allDefinitions != null && refSchema != null) { if (allDefinitions != null && refSchema != null) {
if (allParents.contains(modelName) && supportsMultipleInheritance) { if (allParents.contains(modelName) && supportsMultipleInheritance) {
// multiple inheritance // multiple inheritance
addProperties(allProperties, allRequired, refSchema, allDefinitions); addProperties(allProperties, allRequired, refSchema);
} else if (parentName != null && parentName.equals(modelName) && supportsInheritance) { } else if (parentName != null && parentName.equals(modelName) && supportsInheritance) {
// single inheritance // single inheritance
addProperties(allProperties, allRequired, refSchema, allDefinitions); addProperties(allProperties, allRequired, refSchema);
} else { } else {
// composition // composition
addProperties(properties, required, refSchema, allDefinitions); addProperties(properties, required, refSchema);
} }
} }
@ -1766,16 +1711,16 @@ public class DefaultCodegen implements CodegenConfig {
if (component.get$ref() == null) { if (component.get$ref() == null) {
if (component != null) { if (component != null) {
// component is the child schema // component is the child schema
addProperties(properties, required, component, allDefinitions); addProperties(properties, required, component);
// includes child's properties (all, required) in allProperties, allRequired // includes child's properties (all, required) in allProperties, allRequired
addProperties(allProperties, allRequired, component, allDefinitions); addProperties(allProperties, allRequired, component);
} }
break; // at most one child only break; // at most one child only
} }
} }
addVars(m, unaliasPropertySchema(allDefinitions, properties), required, unaliasPropertySchema(allDefinitions, allProperties), allRequired); addVars(m, unaliasPropertySchema(properties), required, unaliasPropertySchema(allProperties), allRequired);
// end of code block for composed schema // end of code block for composed schema
} else { } else {
@ -1800,7 +1745,7 @@ public class DefaultCodegen implements CodegenConfig {
} }
// passing null to allProperties and allRequired as there's no parent // passing null to allProperties and allRequired as there's no parent
addVars(m, unaliasPropertySchema(allDefinitions, schema.getProperties()), schema.getRequired(), null, null); addVars(m, unaliasPropertySchema(schema.getProperties()), schema.getRequired(), null, null);
} }
// remove duplicated properties // remove duplicated properties
@ -1816,8 +1761,7 @@ public class DefaultCodegen implements CodegenConfig {
return m; return m;
} }
private CodegenDiscriminator createDiscriminator(String schemaName, Schema private CodegenDiscriminator createDiscriminator(String schemaName, Schema schema) {
schema, Map<String, Schema> allDefinitions) {
if (schema.getDiscriminator() == null) { if (schema.getDiscriminator() == null) {
return null; return null;
} }
@ -1827,12 +1771,10 @@ public class DefaultCodegen implements CodegenConfig {
if (schema.getDiscriminator().getMapping() != null && !schema.getDiscriminator().getMapping().isEmpty()) { if (schema.getDiscriminator().getMapping() != null && !schema.getDiscriminator().getMapping().isEmpty()) {
for (Entry<String, String> e : schema.getDiscriminator().getMapping().entrySet()) { for (Entry<String, String> e : schema.getDiscriminator().getMapping().entrySet()) {
String name = toModelName(ModelUtils.getSimpleRef(e.getValue())); // e.g e.getValue => #/components/schemas/Dog String name = toModelName(ModelUtils.getSimpleRef(e.getValue())); // e.g e.getValue => #/components/schemas/Dog
if (allDefinitions.get(name) == null) {
LOGGER.warn("Discriminator's mapping: model {} (mapped to {}) couldn't be found", name, e.getKey());
}
discriminator.getMappedModels().add(new MappedModel(e.getKey(), name)); discriminator.getMappedModels().add(new MappedModel(e.getKey(), name));
} }
} else { } else {
Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI);
allDefinitions.forEach((childName, child) -> { allDefinitions.forEach((childName, child) -> {
if (child instanceof ComposedSchema && ((ComposedSchema) child).getAllOf() != null) { if (child instanceof ComposedSchema && ((ComposedSchema) child).getAllOf() != null) {
Set<String> parentSchemas = ((ComposedSchema) child).getAllOf().stream() Set<String> parentSchemas = ((ComposedSchema) child).getAllOf().stream()
@ -1858,15 +1800,13 @@ public class DefaultCodegen implements CodegenConfig {
* @param properties all properties * @param properties all properties
* @param required required property only * @param required required property only
* @param schema schema in which the properties will be added to the lists * @param schema schema in which the properties will be added to the lists
* @param allSchemas all schemas
*/ */
protected void addProperties(Map<String, Schema> properties, List<String> required, Schema protected void addProperties(Map<String, Schema> properties, List<String> required, Schema schema) {
schema, Map<String, Schema> allSchemas) {
if (schema instanceof ComposedSchema) { if (schema instanceof ComposedSchema) {
ComposedSchema composedSchema = (ComposedSchema) schema; ComposedSchema composedSchema = (ComposedSchema) schema;
for (Schema component : composedSchema.getAllOf()) { for (Schema component : composedSchema.getAllOf()) {
addProperties(properties, required, component, allSchemas); addProperties(properties, required, component);
} }
if (composedSchema.getOneOf() != null) { if (composedSchema.getOneOf() != null) {
@ -1880,11 +1820,9 @@ public class DefaultCodegen implements CodegenConfig {
return; return;
} }
Schema unaliasSchema = ModelUtils.unaliasSchema(globalSchemas, schema);
if (StringUtils.isNotBlank(schema.get$ref())) { if (StringUtils.isNotBlank(schema.get$ref())) {
Schema interfaceSchema = allSchemas.get(ModelUtils.getSimpleRef(schema.get$ref())); Schema interfaceSchema = ModelUtils.getReferencedSchema(this.openAPI, schema);
addProperties(properties, required, interfaceSchema, allSchemas); addProperties(properties, required, interfaceSchema);
return; return;
} }
if (schema.getProperties() != null) { if (schema.getProperties() != null) {
@ -1924,7 +1862,7 @@ public class DefaultCodegen implements CodegenConfig {
LOGGER.debug("debugging fromProperty for " + name + " : " + p); LOGGER.debug("debugging fromProperty for " + name + " : " + p);
// unalias schema // unalias schema
p = ModelUtils.unaliasSchema(globalSchemas, p); p = ModelUtils.unaliasSchema(this.openAPI, p);
CodegenProperty property = CodegenModelFactory.newInstance(CodegenModelType.PROPERTY); CodegenProperty property = CodegenModelFactory.newInstance(CodegenModelType.PROPERTY);
property.name = toVarName(name); property.name = toVarName(name);
@ -2156,7 +2094,7 @@ public class DefaultCodegen implements CodegenConfig {
if (itemName == null) { if (itemName == null) {
itemName = property.name; itemName = property.name;
} }
Schema innerSchema = ModelUtils.unaliasSchema(globalSchemas, ((ArraySchema) p).getItems()); Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, ((ArraySchema) p).getItems());
CodegenProperty cp = fromProperty(itemName, innerSchema); CodegenProperty cp = fromProperty(itemName, innerSchema);
updatePropertyForArray(property, cp); updatePropertyForArray(property, cp);
} else if (ModelUtils.isMapSchema(p)) { } else if (ModelUtils.isMapSchema(p)) {
@ -2168,7 +2106,7 @@ public class DefaultCodegen implements CodegenConfig {
property.maxItems = p.getMaxProperties(); property.maxItems = p.getMaxProperties();
// handle inner property // handle inner property
Schema innerSchema = ModelUtils.unaliasSchema(globalSchemas, ModelUtils.getAdditionalProperties(p)); Schema innerSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getAdditionalProperties(p));
CodegenProperty cp = fromProperty("inner", innerSchema); CodegenProperty cp = fromProperty("inner", innerSchema);
updatePropertyForMap(property, cp); updatePropertyForMap(property, cp);
} else if (ModelUtils.isFreeFormObject(p)) { } else if (ModelUtils.isFreeFormObject(p)) {
@ -2369,39 +2307,21 @@ public class DefaultCodegen implements CodegenConfig {
return responses.get(code); return responses.get(code);
} }
/**
* Convert OAS Operation object to Codegen Operation object (without providing a OAS object)
*
* @param path the path of the operation
* @param httpMethod HTTP method
* @param operation OAS operation object
* @param schemas a map of OAS models
* @return Codegen Operation object
*/
public CodegenOperation fromOperation(String path, String httpMethod, Operation
operation, Map<String, Schema> schemas) {
return fromOperation(path, httpMethod, operation, schemas, null);
}
/** /**
* Convert OAS Operation object to Codegen Operation object * Convert OAS Operation object to Codegen Operation object
*
* @param path the path of the operation
* @param httpMethod HTTP method * @param httpMethod HTTP method
* @param operation OAS operation object * @param operation OAS operation object
* @param schemas a map of OAS models * @param path the path of the operation
* @param openAPI a OAS object representing the spec
* @return Codegen Operation object * @return Codegen Operation object
*/ */
public CodegenOperation fromOperation(String path, public CodegenOperation fromOperation(String path,
String httpMethod, String httpMethod,
Operation operation, Operation operation) {
Map<String, Schema> schemas,
OpenAPI openAPI) {
LOGGER.debug("fromOperation => operation: " + operation); LOGGER.debug("fromOperation => operation: " + operation);
if (operation == null) if (operation == null)
throw new RuntimeException("operation cannot be null in fromOperation"); throw new RuntimeException("operation cannot be null in fromOperation");
Map<String, Schema> schemas = ModelUtils.getSchemas(this.openAPI);
CodegenOperation op = CodegenModelFactory.newInstance(CodegenModelType.OPERATION); CodegenOperation op = CodegenModelFactory.newInstance(CodegenModelType.OPERATION);
Set<String> imports = new HashSet<String>(); Set<String> imports = new HashSet<String>();
if (operation.getExtensions() != null && !operation.getExtensions().isEmpty()) { if (operation.getExtensions() != null && !operation.getExtensions().isEmpty()) {
@ -2439,14 +2359,14 @@ public class DefaultCodegen implements CodegenConfig {
op.isDeprecated = operation.getDeprecated(); op.isDeprecated = operation.getDeprecated();
} }
addConsumesInfo(openAPI, operation, op); addConsumesInfo(operation, op);
if (operation.getResponses() != null && !operation.getResponses().isEmpty()) { if (operation.getResponses() != null && !operation.getResponses().isEmpty()) {
ApiResponse methodResponse = findMethodResponse(operation.getResponses()); ApiResponse methodResponse = findMethodResponse(operation.getResponses());
for (String key : operation.getResponses().keySet()) { for (String key : operation.getResponses().keySet()) {
ApiResponse response = operation.getResponses().get(key); ApiResponse response = operation.getResponses().get(key);
addProducesInfo(openAPI, response, op); addProducesInfo(response, op);
CodegenResponse r = fromResponse(openAPI, key, response); CodegenResponse r = fromResponse(key, response);
r.hasMore = true; r.hasMore = true;
if (r.baseType != null && if (r.baseType != null &&
!defaultIncludes.contains(r.baseType) && !defaultIncludes.contains(r.baseType) &&
@ -2465,7 +2385,7 @@ public class DefaultCodegen implements CodegenConfig {
op.responses.get(op.responses.size() - 1).hasMore = false; op.responses.get(op.responses.size() - 1).hasMore = false;
if (methodResponse != null) { if (methodResponse != null) {
Schema responseSchema = ModelUtils.unaliasSchema(globalSchemas, ModelUtils.getSchemaFromResponse(methodResponse)); Schema responseSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getSchemaFromResponse(methodResponse));
if (responseSchema != null) { if (responseSchema != null) {
CodegenProperty cm = fromProperty("response", responseSchema); CodegenProperty cm = fromProperty("response", responseSchema);
@ -2492,18 +2412,16 @@ public class DefaultCodegen implements CodegenConfig {
exampleStatusCode = key; exampleStatusCode = key;
} }
} }
op.examples = new ExampleGenerator(schemas, openAPI).generateFromResponseSchema(exampleStatusCode, responseSchema, getProducesInfo(openAPI, operation)); op.examples = new ExampleGenerator(schemas, this.openAPI).generateFromResponseSchema(exampleStatusCode, responseSchema, getProducesInfo(this.openAPI, operation));
op.defaultResponse = toDefaultValue(responseSchema); op.defaultResponse = toDefaultValue(responseSchema);
op.returnType = cm.dataType; op.returnType = cm.dataType;
op.hasReference = schemas != null && schemas.containsKey(op.returnBaseType); op.hasReference = schemas.containsKey(op.returnBaseType);
// lookup discriminator // lookup discriminator
if (schemas != null) { Schema schema = schemas.get(op.returnBaseType);
Schema schema = schemas.get(op.returnBaseType); if (schema != null) {
if (schema != null) { CodegenModel cmod = fromModel(op.returnBaseType, schema);
CodegenModel cmod = fromModel(op.returnBaseType, schema, schemas); op.discriminator = cmod.discriminator;
op.discriminator = cmod.discriminator;
}
} }
if (cm.isContainer) { if (cm.isContainer) {
@ -2522,13 +2440,13 @@ public class DefaultCodegen implements CodegenConfig {
op.returnTypeIsPrimitive = true; op.returnTypeIsPrimitive = true;
} }
} }
addHeaders(openAPI, methodResponse, op.responseHeaders); addHeaders(methodResponse, op.responseHeaders);
} }
} }
if (operation.getCallbacks() != null && !operation.getCallbacks().isEmpty()) { if (operation.getCallbacks() != null && !operation.getCallbacks().isEmpty()) {
operation.getCallbacks().forEach((name, callback) -> { operation.getCallbacks().forEach((name, callback) -> {
CodegenCallback c = fromCallback(name, callback, schemas, openAPI); CodegenCallback c = fromCallback(name, callback);
c.hasMore = true; c.hasMore = true;
op.callbacks.add(c); op.callbacks.add(c);
}); });
@ -2552,7 +2470,7 @@ public class DefaultCodegen implements CodegenConfig {
if ("application/x-www-form-urlencoded".equalsIgnoreCase(getContentType(requestBody)) || if ("application/x-www-form-urlencoded".equalsIgnoreCase(getContentType(requestBody)) ||
"multipart/form-data".equalsIgnoreCase(getContentType(requestBody))) { "multipart/form-data".equalsIgnoreCase(getContentType(requestBody))) {
// process form parameters // process form parameters
formParams = fromRequestBodyToFormParameters(requestBody, schemas, imports); formParams = fromRequestBodyToFormParameters(requestBody, imports);
for (CodegenParameter cp : formParams) { for (CodegenParameter cp : formParams) {
postProcessParameter(cp); postProcessParameter(cp);
} }
@ -2564,13 +2482,13 @@ public class DefaultCodegen implements CodegenConfig {
} }
} else { } else {
// process body parameter // process body parameter
requestBody = ModelUtils.getReferencedRequestBody(openAPI, requestBody); requestBody = ModelUtils.getReferencedRequestBody(this.openAPI, requestBody);
String bodyParameterName = ""; String bodyParameterName = "";
if (op.vendorExtensions != null && op.vendorExtensions.containsKey("x-codegen-request-body-name")) { if (op.vendorExtensions != null && op.vendorExtensions.containsKey("x-codegen-request-body-name")) {
bodyParameterName = (String) op.vendorExtensions.get("x-codegen-request-body-name"); bodyParameterName = (String) op.vendorExtensions.get("x-codegen-request-body-name");
} }
bodyParam = fromRequestBody(requestBody, schemas, imports, bodyParameterName); bodyParam = fromRequestBody(requestBody, imports, bodyParameterName);
bodyParam.description = escapeText(requestBody.getDescription()); bodyParam.description = escapeText(requestBody.getDescription());
postProcessParameter(bodyParam); postProcessParameter(bodyParam);
@ -2582,16 +2500,14 @@ public class DefaultCodegen implements CodegenConfig {
// add example // add example
if (schemas != null) { if (schemas != null) {
op.requestBodyExamples = new ExampleGenerator(schemas, openAPI).generate(null, new ArrayList<String>(getConsumesInfo(openAPI, operation)), bodyParam.baseType); op.requestBodyExamples = new ExampleGenerator(schemas, this.openAPI).generate(null, new ArrayList<String>(getConsumesInfo(this.openAPI, operation)), bodyParam.baseType);
} }
} }
} }
if (parameters != null) { if (parameters != null) {
for (Parameter param : parameters) { for (Parameter param : parameters) {
if (StringUtils.isNotBlank(param.get$ref())) { param = ModelUtils.getReferencedParameter(this.openAPI, param);
param = getParameterFromRef(param.get$ref(), openAPI);
}
CodegenParameter p = fromParameter(param, imports); CodegenParameter p = fromParameter(param, imports);
@ -2707,13 +2623,12 @@ public class DefaultCodegen implements CodegenConfig {
/** /**
* Convert OAS Response object to Codegen Response object * Convert OAS Response object to Codegen Response object
*
* @param openAPI a OAS object representing the spec
* @param responseCode HTTP response code * @param responseCode HTTP response code
* @param response OAS Response object * @param response OAS Response object
*
* @return Codegen Response object * @return Codegen Response object
*/ */
public CodegenResponse fromResponse(OpenAPI openAPI, String responseCode, ApiResponse response) { public CodegenResponse fromResponse(String responseCode, ApiResponse response) {
CodegenResponse r = CodegenModelFactory.newInstance(CodegenModelType.RESPONSE); CodegenResponse r = CodegenModelFactory.newInstance(CodegenModelType.RESPONSE);
if ("default".equals(responseCode)) { if ("default".equals(responseCode)) {
r.code = "0"; r.code = "0";
@ -2721,8 +2636,8 @@ public class DefaultCodegen implements CodegenConfig {
r.code = responseCode; r.code = responseCode;
} }
Schema responseSchema; Schema responseSchema;
if (openAPI != null && openAPI.getComponents() != null) { if (this.openAPI != null && this.openAPI.getComponents() != null) {
responseSchema = ModelUtils.unaliasSchema(openAPI.getComponents().getSchemas(), ModelUtils.getSchemaFromResponse(response)); responseSchema = ModelUtils.unaliasSchema(this.openAPI, ModelUtils.getSchemaFromResponse(response));
} else { // no model/alias defined } else { // no model/alias defined
responseSchema = ModelUtils.getSchemaFromResponse(response); responseSchema = ModelUtils.getSchemaFromResponse(response);
} }
@ -2735,7 +2650,7 @@ public class DefaultCodegen implements CodegenConfig {
if (response.getExtensions() != null && !response.getExtensions().isEmpty()) { if (response.getExtensions() != null && !response.getExtensions().isEmpty()) {
r.vendorExtensions.putAll(response.getExtensions()); r.vendorExtensions.putAll(response.getExtensions());
} }
addHeaders(openAPI, response, r.headers); addHeaders(response, r.headers);
r.hasHeaders = !r.headers.isEmpty(); r.hasHeaders = !r.headers.isEmpty();
if (r.schema != null) { if (r.schema != null) {
@ -2827,12 +2742,9 @@ public class DefaultCodegen implements CodegenConfig {
* *
* @param name callback name * @param name callback name
* @param callback OAS Callback object * @param callback OAS Callback object
* @param schemas a map of OAS models
* @param openAPI a OAS object representing the spec
* @return Codegen Response object * @return Codegen Response object
*/ */
public CodegenCallback fromCallback(String name, Callback callback, Map<String, Schema> schemas, OpenAPI public CodegenCallback fromCallback(String name, Callback callback) {
openAPI) {
CodegenCallback c = new CodegenCallback(); CodegenCallback c = new CodegenCallback();
c.name = name; c.name = name;
@ -2874,7 +2786,7 @@ public class DefaultCodegen implements CodegenConfig {
// distinguish between normal operations and callback requests // distinguish between normal operations and callback requests
op.getExtensions().put("x-callback-request", true); op.getExtensions().put("x-callback-request", true);
CodegenOperation co = fromOperation(expression, method, op, schemas, openAPI); CodegenOperation co = fromOperation(expression, method, op);
if (genId) { if (genId) {
co.operationIdOriginal = null; co.operationIdOriginal = null;
// legacy (see `fromOperation()`) // legacy (see `fromOperation()`)
@ -2923,7 +2835,7 @@ public class DefaultCodegen implements CodegenConfig {
} }
if (parameter.getSchema() != null) { if (parameter.getSchema() != null) {
Schema parameterSchema = ModelUtils.unaliasSchema(globalSchemas, parameter.getSchema()); Schema parameterSchema = ModelUtils.unaliasSchema(this.openAPI, parameter.getSchema());
if (parameterSchema == null) { if (parameterSchema == null) {
LOGGER.warn("warning! Schema not found for parameter \"" + parameter.getName() + "\", using String"); LOGGER.warn("warning! Schema not found for parameter \"" + parameter.getName() + "\", using String");
parameterSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to missing type definition."); parameterSchema = new StringSchema().description("//TODO automatically added by openapi-generator due to missing type definition.");
@ -3373,16 +3285,15 @@ public class DefaultCodegen implements CodegenConfig {
/** /**
* Add headers to codegen property * Add headers to codegen property
*
* @param response API response * @param response API response
* @param properties list of codegen property * @param properties list of codegen property
*/ */
private void addHeaders(OpenAPI openAPI, ApiResponse response, List<CodegenProperty> properties) { private void addHeaders(ApiResponse response, List<CodegenProperty> properties) {
if (response.getHeaders() != null) { if (response.getHeaders() != null) {
for (Map.Entry<String, Header> headers : response.getHeaders().entrySet()) { for (Map.Entry<String, Header> headers : response.getHeaders().entrySet()) {
String description = headers.getValue().getDescription(); String description = headers.getValue().getDescription();
// follow the $ref // follow the $ref
Header header = ModelUtils.getReferencedHeader(openAPI, headers.getValue()); Header header = ModelUtils.getReferencedHeader(this.openAPI, headers.getValue());
CodegenProperty cp = fromProperty(headers.getKey(), header.getSchema()); CodegenProperty cp = fromProperty(headers.getKey(), header.getSchema());
cp.setDescription(escapeText(description)); cp.setDescription(escapeText(description));
@ -3490,16 +3401,14 @@ public class DefaultCodegen implements CodegenConfig {
/** /**
* Loop through propertiies and unalias the reference if $ref (reference) is defined * Loop through propertiies and unalias the reference if $ref (reference) is defined
*
* @param allSchemas all schemas defined in the spec
* @param properties model properties (schemas) * @param properties model properties (schemas)
*
* @return model properties with direct reference to schemas * @return model properties with direct reference to schemas
*/ */
private Map<String, Schema> unaliasPropertySchema private Map<String, Schema> unaliasPropertySchema(Map<String, Schema> properties) {
(Map<String, Schema> allSchemas, Map<String, Schema> properties) {
if (properties != null) { if (properties != null) {
for (String key : properties.keySet()) { for (String key : properties.keySet()) {
properties.put(key, ModelUtils.unaliasSchema(allSchemas, properties.get(key))); properties.put(key, ModelUtils.unaliasSchema(this.openAPI, properties.get(key)));
} }
} }
@ -4207,15 +4116,6 @@ public class DefaultCodegen implements CodegenConfig {
return new ArrayList<>(requestBody.getContent().keySet()).get(0); return new ArrayList<>(requestBody.getContent().keySet()).get(0);
} }
protected Parameter getParameterFromRef(String ref, OpenAPI openAPI) {
String parameterName = ref.substring(ref.lastIndexOf('/') + 1);
Map<String, Parameter> parameterMap = openAPI.getComponents().getParameters();
if (parameterMap == null ) { // can't find the ref
throw new RuntimeException(ref + " not defined in the spec.");
}
return parameterMap.get(parameterName);
}
private void setOauth2Info(CodegenSecurity codegenSecurity, OAuthFlow flow) { private void setOauth2Info(CodegenSecurity codegenSecurity, OAuthFlow flow) {
codegenSecurity.authorizationUrl = flow.getAuthorizationUrl(); codegenSecurity.authorizationUrl = flow.getAuthorizationUrl();
codegenSecurity.tokenUrl = flow.getTokenUrl(); codegenSecurity.tokenUrl = flow.getTokenUrl();
@ -4241,8 +4141,8 @@ public class DefaultCodegen implements CodegenConfig {
} }
} }
private void addConsumesInfo(OpenAPI openAPI, Operation operation, CodegenOperation codegenOperation) { private void addConsumesInfo(Operation operation, CodegenOperation codegenOperation) {
RequestBody requestBody = ModelUtils.getReferencedRequestBody(openAPI, operation.getRequestBody()); RequestBody requestBody = ModelUtils.getReferencedRequestBody(this.openAPI, operation.getRequestBody());
if (requestBody == null || requestBody.getContent() == null || requestBody.getContent().isEmpty()) { if (requestBody == null || requestBody.getContent() == null || requestBody.getContent().isEmpty()) {
return; return;
} }
@ -4310,8 +4210,8 @@ public class DefaultCodegen implements CodegenConfig {
return ModelUtils.getReferencedSchema(openAPI, schema) != null; return ModelUtils.getReferencedSchema(openAPI, schema) != null;
} }
private void addProducesInfo(OpenAPI openAPI, ApiResponse inputResponse, CodegenOperation codegenOperation) { private void addProducesInfo(ApiResponse inputResponse, CodegenOperation codegenOperation) {
ApiResponse response = ModelUtils.getReferencedApiResponse(openAPI, inputResponse); ApiResponse response = ModelUtils.getReferencedApiResponse(this.openAPI, inputResponse);
if (response == null || response.getContent() == null || response.getContent().isEmpty()) { if (response == null || response.getContent() == null || response.getContent().isEmpty()) {
return; return;
} }
@ -4408,14 +4308,11 @@ public class DefaultCodegen implements CodegenConfig {
return null; return null;
} }
public List<CodegenParameter> fromRequestBodyToFormParameters(RequestBody public List<CodegenParameter> fromRequestBodyToFormParameters(RequestBody body, Set<String> imports) {
body, Map<String, Schema> schemas, Set<String> imports) {
List<CodegenParameter> parameters = new ArrayList<CodegenParameter>(); List<CodegenParameter> parameters = new ArrayList<CodegenParameter>();
LOGGER.debug("debugging fromRequestBodyToFormParameters= " + body); LOGGER.debug("debugging fromRequestBodyToFormParameters= " + body);
Schema schema = ModelUtils.getSchemaFromRequestBody(body); Schema schema = ModelUtils.getSchemaFromRequestBody(body);
if (StringUtils.isNotBlank(schema.get$ref())) { schema = ModelUtils.getReferencedSchema(this.openAPI, schema);
schema = schemas.get(ModelUtils.getSimpleRef(schema.get$ref()));
}
if (schema.getProperties() != null && !schema.getProperties().isEmpty()) { if (schema.getProperties() != null && !schema.getProperties().isEmpty()) {
Map<String, Schema> properties = schema.getProperties(); Map<String, Schema> properties = schema.getProperties();
for (Map.Entry<String, Schema> entry : properties.entrySet()) { for (Map.Entry<String, Schema> entry : properties.entrySet()) {
@ -4565,8 +4462,7 @@ public class DefaultCodegen implements CodegenConfig {
return codegenParameter; return codegenParameter;
} }
public CodegenParameter fromRequestBody(RequestBody public CodegenParameter fromRequestBody(RequestBody body, Set<String> imports, String bodyParameterName) {
body, Map<String, Schema> schemas, Set<String> imports, String bodyParameterName) {
if (body == null) { if (body == null) {
LOGGER.error("body in fromRequestBody cannot be null!"); LOGGER.error("body in fromRequestBody cannot be null!");
} }
@ -4586,8 +4482,8 @@ public class DefaultCodegen implements CodegenConfig {
if (StringUtils.isNotBlank(schema.get$ref())) { if (StringUtils.isNotBlank(schema.get$ref())) {
name = ModelUtils.getSimpleRef(schema.get$ref()); name = ModelUtils.getSimpleRef(schema.get$ref());
schema = schemas.get(name);
} }
schema = ModelUtils.getReferencedSchema(this.openAPI, schema);
if (ModelUtils.isMapSchema(schema)) { if (ModelUtils.isMapSchema(schema)) {
Schema inner = ModelUtils.getAdditionalProperties(schema); Schema inner = ModelUtils.getAdditionalProperties(schema);
@ -4686,7 +4582,7 @@ public class DefaultCodegen implements CodegenConfig {
CodegenModel codegenModel = null; CodegenModel codegenModel = null;
if (StringUtils.isNotBlank(name)) { if (StringUtils.isNotBlank(name)) {
schema.setName(name); schema.setName(name);
codegenModel = fromModel(name, schema, schemas); codegenModel = fromModel(name, schema);
} }
if (codegenModel != null) { if (codegenModel != null) {
codegenParameter.isModel = true; codegenParameter.isModel = true;

View File

@ -19,7 +19,6 @@ package org.openapitools.codegen;
import com.samskivert.mustache.Mustache; import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template; import com.samskivert.mustache.Template;
import io.swagger.v3.core.util.Json; import io.swagger.v3.core.util.Json;
import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.Operation;
@ -33,7 +32,6 @@ import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.security.SecurityRequirement; import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme; import io.swagger.v3.oas.models.security.SecurityScheme;
import io.swagger.v3.oas.models.tags.Tag; import io.swagger.v3.oas.models.tags.Tag;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.ObjectUtils; import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
@ -46,9 +44,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.*; import java.io.*;
import java.util.*; import java.net.URL;
import java.net.*;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.util.*;
public class DefaultGenerator extends AbstractGenerator implements Generator { public class DefaultGenerator extends AbstractGenerator implements Generator {
protected final Logger LOGGER = LoggerFactory.getLogger(DefaultGenerator.class); protected final Logger LOGGER = LoggerFactory.getLogger(DefaultGenerator.class);
@ -182,9 +180,8 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
config.processOpts(); config.processOpts();
config.preprocessOpenAPI(openAPI); config.preprocessOpenAPI(openAPI);
// set OpenAPI and schemas to make these available to all methods // set OpenAPI to make these available to all methods
config.setGlobalOpenAPI(openAPI); config.setOpenAPI(openAPI);
config.setGlobalSchemas(openAPI);
config.additionalProperties().put("generatorVersion", ImplementationVersion.read()); config.additionalProperties().put("generatorVersion", ImplementationVersion.read());
config.additionalProperties().put("generatedDate", ZonedDateTime.now().toString()); config.additionalProperties().put("generatedDate", ZonedDateTime.now().toString());
@ -449,7 +446,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
Map<String, Schema> schemaMap = new HashMap<>(); Map<String, Schema> schemaMap = new HashMap<>();
schemaMap.put(name, schema); schemaMap.put(name, schema);
Map<String, Object> models = processModels(config, schemaMap, schemas); Map<String, Object> models = processModels(config, schemaMap);
models.put("classname", config.toModelName(name)); models.put("classname", config.toModelName(name));
models.putAll(config.additionalProperties()); models.putAll(config.additionalProperties());
allProcessedModels.put(name, models); allProcessedModels.put(name, models);
@ -1016,7 +1013,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
final List<SecurityRequirement> globalSecurities = openAPI.getSecurity(); final List<SecurityRequirement> globalSecurities = openAPI.getSecurity();
for (Tag tag : tags) { for (Tag tag : tags) {
try { try {
CodegenOperation codegenOperation = config.fromOperation(resourcePath, httpMethod, operation, schemas, openAPI); CodegenOperation codegenOperation = config.fromOperation(resourcePath, httpMethod, operation);
codegenOperation.tags = new ArrayList<>(tags); codegenOperation.tags = new ArrayList<>(tags);
config.addOperationToGroup(config.sanitizeTag(tag.getName()), resourcePath, operation, codegenOperation, operations); config.addOperationToGroup(config.sanitizeTag(tag.getName()), resourcePath, operation, codegenOperation, operations);
@ -1112,7 +1109,6 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
operations.put("hasImport", true); operations.put("hasImport", true);
} }
config.postProcessOperations(operations);
config.postProcessOperationsWithModels(operations, allModels); config.postProcessOperationsWithModels(operations, allModels);
if (objs.size() > 0) { if (objs.size() > 0) {
List<CodegenOperation> os = (List<CodegenOperation>) objs.get("operation"); List<CodegenOperation> os = (List<CodegenOperation>) objs.get("operation");
@ -1126,7 +1122,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
} }
private Map<String, Object> processModels(CodegenConfig config, Map<String, Schema> definitions, Map<String, Schema> allDefinitions) { private Map<String, Object> processModels(CodegenConfig config, Map<String, Schema> definitions) {
Map<String, Object> objs = new HashMap<String, Object>(); Map<String, Object> objs = new HashMap<String, Object>();
objs.put("package", config.modelPackage()); objs.put("package", config.modelPackage());
List<Object> models = new ArrayList<Object>(); List<Object> models = new ArrayList<Object>();
@ -1135,7 +1131,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
Schema schema = definitions.get(key); Schema schema = definitions.get(key);
if (schema == null) if (schema == null)
throw new RuntimeException("schema cannot be null in processMoels"); throw new RuntimeException("schema cannot be null in processMoels");
CodegenModel cm = config.fromModel(key, schema, allDefinitions); CodegenModel cm = config.fromModel(key, schema);
Map<String, Object> mo = new HashMap<String, Object>(); Map<String, Object> mo = new HashMap<String, Object>();
mo.put("model", cm); mo.put("model", cm);
mo.put("importPath", config.toModelImport(cm.classname)); mo.put("importPath", config.toModelImport(cm.classname));

View File

@ -17,27 +17,19 @@
package org.openapitools.codegen; package org.openapitools.codegen;
import io.swagger.v3.core.util.Json;
import io.swagger.v3.oas.models.*; import io.swagger.v3.oas.models.*;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.ObjectSchema;
import io.swagger.v3.oas.models.media.*; import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.oas.models.responses.ApiResponse;
import io.swagger.v3.oas.models.parameters.Parameter; import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.parameters.RequestBody; import io.swagger.v3.oas.models.parameters.RequestBody;
import io.swagger.v3.core.util.Json; import io.swagger.v3.oas.models.responses.ApiResponse;
import io.swagger.v3.oas.models.responses.ApiResponses; import io.swagger.v3.oas.models.responses.ApiResponses;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import io.swagger.v3.oas.models.media.Content;
import io.swagger.v3.oas.models.media.MediaType;
import java.util.*; import java.util.*;
import io.swagger.v3.oas.models.media.XML;
public class InlineModelResolver { public class InlineModelResolver {
private OpenAPI openapi; private OpenAPI openapi;
private Map<String, Schema> addedModels = new HashMap<String, Schema>(); private Map<String, Schema> addedModels = new HashMap<String, Schema>();

View File

@ -26,26 +26,9 @@ import io.swagger.v3.parser.core.models.AuthorizationValue;
import io.swagger.v3.parser.core.models.ParseOptions; import io.swagger.v3.parser.core.models.ParseOptions;
import io.swagger.v3.parser.core.models.SwaggerParseResult; import io.swagger.v3.parser.core.models.SwaggerParseResult;
import org.apache.commons.lang3.Validate; import org.apache.commons.lang3.Validate;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.*;
import org.openapitools.codegen.ClientOptInput;
import org.openapitools.codegen.ClientOpts;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenConfigLoader;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.SpecValidationException;
import org.openapitools.codegen.auth.AuthParser; import org.openapitools.codegen.auth.AuthParser;
import org.openapitools.codegen.languages.CSharpNancyFXServerCodegen; import org.openapitools.codegen.languages.*;
import org.openapitools.codegen.languages.CppQt5ClientCodegen;
import org.openapitools.codegen.languages.CppRestSdkClientCodegen;
import org.openapitools.codegen.languages.CppTizenClientCodegen;
import org.openapitools.codegen.languages.JavaJerseyServerCodegen;
import org.openapitools.codegen.languages.PhpLumenServerCodegen;
import org.openapitools.codegen.languages.PhpSlimServerCodegen;
import org.openapitools.codegen.languages.PhpZendExpressivePathHandlerServerCodegen;
import org.openapitools.codegen.languages.RubySinatraServerCodegen;
import org.openapitools.codegen.languages.ScalaAkkaClientCodegen;
import org.openapitools.codegen.languages.ScalaHttpClientCodegen;
import org.openapitools.codegen.languages.SwiftClientCodegen;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -54,12 +37,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.Serializable; import java.io.Serializable;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.HashMap; import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import static org.apache.commons.lang3.StringUtils.isNotEmpty; import static org.apache.commons.lang3.StringUtils.isNotEmpty;

View File

@ -17,8 +17,8 @@
package org.openapitools.codegen.config; package org.openapitools.codegen.config;
import org.openapitools.codegen.utils.OptionUtils;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.openapitools.codegen.utils.OptionUtils;
import java.util.*; import java.util.*;

View File

@ -18,30 +18,14 @@
package org.openapitools.codegen.examples; package org.openapitools.codegen.examples;
import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.BooleanSchema;
import io.swagger.v3.oas.models.media.DateSchema;
import io.swagger.v3.oas.models.media.DateTimeSchema;
import io.swagger.v3.oas.models.media.IntegerSchema;
import io.swagger.v3.oas.models.media.NumberSchema;
import io.swagger.v3.oas.models.media.PasswordSchema;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.media.StringSchema;
import io.swagger.v3.oas.models.media.UUIDSchema;
import io.swagger.v3.oas.models.media.XML; import io.swagger.v3.oas.models.media.XML;
import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.Collection; import java.util.*;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
public class XmlExampleGenerator { public class XmlExampleGenerator {
protected final Logger LOGGER = LoggerFactory.getLogger(XmlExampleGenerator.class); protected final Logger LOGGER = LoggerFactory.getLogger(XmlExampleGenerator.class);

View File

@ -17,7 +17,8 @@
package org.openapitools.codegen.ignore.rules; package org.openapitools.codegen.ignore.rules;
import java.nio.file.*; import java.nio.file.FileSystems;
import java.nio.file.PathMatcher;
import java.util.List; import java.util.List;
public class DirectoryRule extends FileRule { public class DirectoryRule extends FileRule {

View File

@ -19,32 +19,18 @@ package org.openapitools.codegen.languages;
import com.samskivert.mustache.Escapers; import com.samskivert.mustache.Escapers;
import com.samskivert.mustache.Mustache; import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.responses.ApiResponse; import io.swagger.v3.oas.models.responses.ApiResponse;
import io.swagger.v3.oas.models.security.SecurityRequirement; import io.swagger.v3.oas.models.security.SecurityRequirement;
import io.swagger.v3.oas.models.security.SecurityScheme; import io.swagger.v3.oas.models.security.SecurityScheme;
import org.openapitools.codegen.CodegenConfig; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenSecurity;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;
@ -403,9 +389,8 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
} }
@Override @Override
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, public CodegenOperation fromOperation(String path, String httpMethod, Operation operation) {
Map<String, Schema> definitions, OpenAPI openAPI) { CodegenOperation op = super.fromOperation(path, httpMethod, operation);
CodegenOperation op = super.fromOperation(path, httpMethod, operation, definitions, openAPI);
if (operation.getResponses() != null && !operation.getResponses().isEmpty()) { if (operation.getResponses() != null && !operation.getResponses().isEmpty()) {
ApiResponse methodResponse = findMethodResponse(operation.getResponses()); ApiResponse methodResponse = findMethodResponse(operation.getResponses());
@ -424,8 +409,8 @@ abstract public class AbstractAdaCodegen extends DefaultCodegen implements Codeg
// the scopes required by the operation. // the scopes required by the operation.
final List<SecurityRequirement> securities = operation.getSecurity(); final List<SecurityRequirement> securities = operation.getSecurity();
if (securities != null && securities.size() > 0) { if (securities != null && securities.size() > 0) {
final Map<String, SecurityScheme> securitySchemes = openAPI.getComponents() != null ? openAPI.getComponents().getSecuritySchemes() : null; final Map<String, SecurityScheme> securitySchemes = this.openAPI.getComponents() != null ? this.openAPI.getComponents().getSecuritySchemes() : null;
final List<SecurityRequirement> globalSecurities = openAPI.getSecurity(); final List<SecurityRequirement> globalSecurities = this.openAPI.getSecurity();
Map<String, List<String>> scopes = getAuthScopes(securities, securitySchemes); Map<String, List<String>> scopes = getAuthScopes(securities, securitySchemes);
if (scopes.isEmpty() && globalSecurities != null) { if (scopes.isEmpty() && globalSecurities != null) {

View File

@ -17,25 +17,20 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import java.util.*;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.utils.ModelUtils;
import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.MapSchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.responses.ApiResponse; import io.swagger.v3.oas.models.responses.ApiResponse;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;
public abstract class AbstractApexCodegen extends DefaultCodegen implements CodegenConfig { public abstract class AbstractApexCodegen extends DefaultCodegen implements CodegenConfig {
@ -437,8 +432,8 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
} }
@Override @Override
public CodegenModel fromModel(String name, Schema model, Map<String, Schema> allDefinitions) { public CodegenModel fromModel(String name, Schema model) {
CodegenModel cm = super.fromModel(name, model, allDefinitions); CodegenModel cm = super.fromModel(name, model);
// TODO Check enum model handling // TODO Check enum model handling
if (cm.interfaces == null) { if (cm.interfaces == null) {
@ -566,10 +561,10 @@ public abstract class AbstractApexCodegen extends DefaultCodegen implements Code
} }
@Override @Override
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map<String, Schema> definitions, OpenAPI openAPI) { public CodegenOperation fromOperation(String path, String httpMethod, Operation operation) {
CodegenOperation op = super.fromOperation( CodegenOperation op = super.fromOperation(
path, httpMethod, operation, definitions, openAPI); path, httpMethod, operation);
if (op.getHasExamples()) { if (op.getHasExamples()) {
// prepare examples for Apex test classes // prepare examples for Apex test classes

View File

@ -20,20 +20,13 @@ package org.openapitools.codegen.languages;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache; import com.samskivert.mustache.Mustache;
import io.swagger.v3.core.util.Json; import io.swagger.v3.core.util.Json;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*; import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.*;
import org.openapitools.codegen.utils.ModelUtils;
import org.openapitools.codegen.mustache.*; import org.openapitools.codegen.mustache.*;
import io.swagger.v3.oas.models.security.SecurityScheme; import org.openapitools.codegen.utils.ModelUtils;
import io.swagger.v3.oas.models.*;
import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.oas.models.responses.ApiResponse;
import io.swagger.v3.oas.models.parameters.*;
import io.swagger.v3.core.util.Yaml;
import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -759,7 +752,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
/** /**
* Return the default value of the property * Return the default value of the property
*
* @param p OpenAPI property object * @param p OpenAPI property object
* @return string presentation of the default value of the property * @return string presentation of the default value of the property
*/ */

View File

@ -17,12 +17,11 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache; import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CodegenConfig; import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenProperty; import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.DefaultCodegen; import org.openapitools.codegen.DefaultCodegen;

View File

@ -17,36 +17,18 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import static com.google.common.base.Strings.isNullOrEmpty;
import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import io.swagger.v3.core.util.Json; import io.swagger.v3.core.util.Json;
import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.Arrays; import java.util.*;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import static com.google.common.base.Strings.isNullOrEmpty; import static com.google.common.base.Strings.isNullOrEmpty;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;
@ -475,11 +457,12 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
} }
@Override @Override
public CodegenModel fromModel(String name, Schema model, Map<String, Schema> allDefinitions) { public CodegenModel fromModel(String name, Schema model) {
CodegenModel codegenModel = super.fromModel(name, model, allDefinitions); Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI);
CodegenModel codegenModel = super.fromModel(name, model);
if (allDefinitions != null && codegenModel.parentSchema != null && codegenModel.hasEnums) { if (allDefinitions != null && codegenModel.parentSchema != null && codegenModel.hasEnums) {
final Schema parentModel = allDefinitions.get(codegenModel.parentSchema); final Schema parentModel = allDefinitions.get(codegenModel.parentSchema);
final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel, allDefinitions); final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel);
codegenModel = AbstractEiffelCodegen.reconcileInlineEnums(codegenModel, parentCodegenModel); codegenModel = AbstractEiffelCodegen.reconcileInlineEnums(codegenModel, parentCodegenModel);
} }
return codegenModel; return codegenModel;

View File

@ -19,15 +19,14 @@ package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*; import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.io.IOException;
import java.util.*; import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;

View File

@ -417,7 +417,7 @@ public abstract class AbstractGraphQLCodegen extends DefaultCodegen implements C
} }
@Override @Override
public Map<String, Object> postProcessOperations(Map<String, Object> operations) { public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> operations, List<Object> allModels) {
Map<String, Object> objs = (Map<String, Object>) operations.get("operations"); Map<String, Object> objs = (Map<String, Object>) operations.get("operations");
for (CodegenOperation op : (List<CodegenOperation>) objs.get("operation")) { for (CodegenOperation op : (List<CodegenOperation>) objs.get("operation")) {

View File

@ -18,7 +18,6 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import com.google.common.base.Strings; import com.google.common.base.Strings;
import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.PathItem; import io.swagger.v3.oas.models.PathItem;
@ -26,18 +25,10 @@ import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.media.StringSchema; import io.swagger.v3.oas.models.media.StringSchema;
import io.swagger.v3.parser.util.SchemaTypeUtil; import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -46,9 +37,7 @@ import java.io.File;
import java.util.*; import java.util.*;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static org.openapitools.codegen.utils.StringUtils.escape; import static org.openapitools.codegen.utils.StringUtils.*;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
public abstract class AbstractJavaCodegen extends DefaultCodegen implements CodegenConfig { public abstract class AbstractJavaCodegen extends DefaultCodegen implements CodegenConfig {
@ -944,8 +933,9 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
} }
@Override @Override
public CodegenModel fromModel(String name, Schema model, Map<String, Schema> allDefinitions) { public CodegenModel fromModel(String name, Schema model) {
CodegenModel codegenModel = super.fromModel(name, model, allDefinitions); Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI);
CodegenModel codegenModel = super.fromModel(name, model);
if (codegenModel.description != null) { if (codegenModel.description != null) {
codegenModel.imports.add("ApiModel"); codegenModel.imports.add("ApiModel");
} }
@ -955,7 +945,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
} }
if (allDefinitions != null && codegenModel.parentSchema != null && codegenModel.hasEnums) { if (allDefinitions != null && codegenModel.parentSchema != null && codegenModel.hasEnums) {
final Schema parentModel = allDefinitions.get(codegenModel.parentSchema); final Schema parentModel = allDefinitions.get(codegenModel.parentSchema);
final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel, allDefinitions); final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel);
codegenModel = AbstractJavaCodegen.reconcileInlineEnums(codegenModel, parentCodegenModel); codegenModel = AbstractJavaCodegen.reconcileInlineEnums(codegenModel, parentCodegenModel);
} }
return codegenModel; return codegenModel;
@ -1139,8 +1129,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
} }
@Override @Override
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, Map<String, Schema> definitions, OpenAPI openAPI) { public CodegenOperation fromOperation(String path, String httpMethod, Operation operation) {
CodegenOperation op = super.fromOperation(path, httpMethod, operation, definitions, openAPI); CodegenOperation op = super.fromOperation(path, httpMethod, operation);
op.path = sanitizePath(op.path); op.path = sanitizePath(op.path);
return op; return op;
} }

View File

@ -20,13 +20,7 @@ package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.PathItem; import io.swagger.v3.oas.models.PathItem;
import org.openapitools.codegen.*;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenResponse;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.languages.features.BeanValidationFeatures; import org.openapitools.codegen.languages.features.BeanValidationFeatures;
import org.openapitools.codegen.utils.URLPathUtils; import org.openapitools.codegen.utils.URLPathUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -34,11 +28,7 @@ import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;

View File

@ -32,9 +32,7 @@ import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.util.*; import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.*;
import static org.openapitools.codegen.utils.StringUtils.escape;
import static org.openapitools.codegen.utils.StringUtils.underscore;
public abstract class AbstractKotlinCodegen extends DefaultCodegen implements CodegenConfig { public abstract class AbstractKotlinCodegen extends DefaultCodegen implements CodegenConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractKotlinCodegen.class); private static final Logger LOGGER = LoggerFactory.getLogger(AbstractKotlinCodegen.class);

View File

@ -21,31 +21,15 @@ import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.media.StringSchema; import io.swagger.v3.oas.models.media.StringSchema;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore; import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -568,7 +552,6 @@ public abstract class AbstractPhpCodegen extends DefaultCodegen implements Codeg
/** /**
* Return the default value of the property * Return the default value of the property
*
* @param p Swagger property object * @param p Swagger property object
* @return string presentation of the default value of the property * @return string presentation of the default value of the property
*/ */

View File

@ -17,10 +17,10 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CodegenConfig; import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.DefaultCodegen; import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;

View File

@ -19,15 +19,8 @@ package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

View File

@ -17,25 +17,12 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.openapitools.codegen.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.*;
public class Apache2ConfigCodegen extends DefaultCodegen implements CodegenConfig { public class Apache2ConfigCodegen extends DefaultCodegen implements CodegenConfig {
public static final String USER_INFO_PATH = "userInfoPath"; public static final String USER_INFO_PATH = "userInfoPath";

View File

@ -17,18 +17,22 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenProperty; import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.SupportingFile; import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.oas.models.info.*;
import io.swagger.v3.oas.models.OpenAPI;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.util.*; import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;

View File

@ -28,7 +28,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.lang.IllegalArgumentException;
import java.net.URL; import java.net.URL;
import java.util.Arrays; import java.util.Arrays;
import java.util.Locale; import java.util.Locale;

View File

@ -20,31 +20,19 @@ package org.openapitools.codegen.languages;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils;
import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.*; import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.parameters.*; import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.Parameter;
import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.Arrays; import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class BashClientCodegen extends DefaultCodegen implements CodegenConfig { public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(BashClientCodegen.class); private static final Logger LOGGER = LoggerFactory.getLogger(BashClientCodegen.class);
@ -419,9 +407,9 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
/** /**
* Convert OpenAPI Parameter object to Codegen Parameter object * Convert OpenAPI Parameter object to Codegen Parameter object
*
* @param param OpenAPI parameter object
* @param imports set of imports for library/package/module * @param imports set of imports for library/package/module
* @param param OpenAPI parameter object
*
* @return Codegen Parameter object * @return Codegen Parameter object
*/ */
@Override @Override
@ -578,12 +566,9 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
@Override @Override
public CodegenOperation fromOperation(String path, String httpMethod, public CodegenOperation fromOperation(String path, String httpMethod,
Operation operation, Operation operation) {
Map<String, Schema> definitions, Map<String, Schema> definitions = ModelUtils.getSchemas(this.openAPI);
OpenAPI openAPI) { CodegenOperation op = super.fromOperation(path, httpMethod, operation);
CodegenOperation op = super.fromOperation(path, httpMethod, operation,
definitions, openAPI);
/** /**
* Check if the operation has a Bash codegen specific description * Check if the operation has a Bash codegen specific description
@ -626,8 +611,8 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
* If the operation produces Json and has nonempty example * If the operation produces Json and has nonempty example
* try to reformat it. * try to reformat it.
*/ */
if (getConsumesInfo(openAPI, operation) != null if (getConsumesInfo(this.openAPI, operation) != null
&& getConsumesInfo(openAPI, operation).contains("application/json") && getConsumesInfo(this.openAPI, operation).contains("application/json")
&& definitions.get(p.dataType).getExample() != null) { && definitions.get(p.dataType).getExample() != null) {
ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();

View File

@ -16,24 +16,18 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*; import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.apache.commons.io.FilenameUtils;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.*;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore; import static org.openapitools.codegen.utils.StringUtils.underscore;

View File

@ -17,29 +17,16 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache; import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenConstants; import org.openapitools.codegen.utils.ModelUtils;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import static org.apache.commons.lang3.StringUtils.isEmpty; import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;
@ -537,12 +524,13 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
} }
@Override @Override
public CodegenModel fromModel(String name, Schema model, Map<String, Schema> allDefinitions) { public CodegenModel fromModel(String name, Schema model) {
CodegenModel codegenModel = super.fromModel(name, model, allDefinitions); Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI);
CodegenModel codegenModel = super.fromModel(name, model);
if (allDefinitions != null && codegenModel != null && codegenModel.parent != null) { if (allDefinitions != null && codegenModel != null && codegenModel.parent != null) {
final Schema parentModel = allDefinitions.get(toModelName(codegenModel.parent)); final Schema parentModel = allDefinitions.get(toModelName(codegenModel.parent));
if (parentModel != null) { if (parentModel != null) {
final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel, allDefinitions); final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel);
if (codegenModel.hasEnums) { if (codegenModel.hasEnums) {
codegenModel = this.reconcileInlineEnums(codegenModel, parentCodegenModel); codegenModel = this.reconcileInlineEnums(codegenModel, parentCodegenModel);
} }

View File

@ -17,7 +17,10 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.openapitools.codegen.*; import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import java.io.File; import java.io.File;

View File

@ -18,19 +18,10 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.*;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.CodegenModel; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import org.openapitools.codegen.utils.URLPathUtils; import org.openapitools.codegen.utils.URLPathUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -38,38 +29,14 @@ import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.*;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set;
import static com.google.common.base.Strings.isNullOrEmpty; import static com.google.common.base.Strings.isNullOrEmpty;
import static java.util.Arrays.asList; import static java.util.Arrays.asList;
import static java.util.UUID.randomUUID; import static java.util.UUID.randomUUID;
import static org.apache.commons.lang3.StringUtils.capitalize; import static org.apache.commons.lang3.StringUtils.capitalize;
import static org.openapitools.codegen.CodegenConstants.INTERFACE_PREFIX; import static org.openapitools.codegen.CodegenConstants.*;
import static org.openapitools.codegen.CodegenConstants.INTERFACE_PREFIX_DESC;
import static org.openapitools.codegen.CodegenConstants.OPTIONAL_PROJECT_FILE;
import static org.openapitools.codegen.CodegenConstants.OPTIONAL_PROJECT_FILE_DESC;
import static org.openapitools.codegen.CodegenConstants.OPTIONAL_PROJECT_GUID;
import static org.openapitools.codegen.CodegenConstants.OPTIONAL_PROJECT_GUID_DESC;
import static org.openapitools.codegen.CodegenConstants.PACKAGE_NAME;
import static org.openapitools.codegen.CodegenConstants.PACKAGE_VERSION;
import static org.openapitools.codegen.CodegenConstants.RETURN_ICOLLECTION;
import static org.openapitools.codegen.CodegenConstants.RETURN_ICOLLECTION_DESC;
import static org.openapitools.codegen.CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG;
import static org.openapitools.codegen.CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC;
import static org.openapitools.codegen.CodegenConstants.SOURCE_FOLDER;
import static org.openapitools.codegen.CodegenConstants.SOURCE_FOLDER_DESC;
import static org.openapitools.codegen.CodegenConstants.USE_COLLECTION;
import static org.openapitools.codegen.CodegenConstants.USE_COLLECTION_DESC;
import static org.openapitools.codegen.CodegenConstants.USE_DATETIME_OFFSET;
import static org.openapitools.codegen.CodegenConstants.USE_DATETIME_OFFSET_DESC;
import static org.openapitools.codegen.CodegenType.SERVER; import static org.openapitools.codegen.CodegenType.SERVER;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;

View File

@ -17,34 +17,18 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache; import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.*;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore; import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -563,12 +547,13 @@ public class CSharpRefactorClientCodegen extends AbstractCSharpCodegen {
} }
@Override @Override
public CodegenModel fromModel(String name, Schema model, Map<String, Schema> allDefinitions) { public CodegenModel fromModel(String name, Schema model) {
CodegenModel codegenModel = super.fromModel(name, model, allDefinitions); Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI);
CodegenModel codegenModel = super.fromModel(name, model);
if (allDefinitions != null && codegenModel != null && codegenModel.parent != null) { if (allDefinitions != null && codegenModel != null && codegenModel.parent != null) {
final Schema parentModel = allDefinitions.get(toModelName(codegenModel.parent)); final Schema parentModel = allDefinitions.get(toModelName(codegenModel.parent));
if (parentModel != null) { if (parentModel != null) {
final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel, allDefinitions); final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel);
if (codegenModel.hasEnums) { if (codegenModel.hasEnums) {
codegenModel = this.reconcileInlineEnums(codegenModel, parentCodegenModel); codegenModel = this.reconcileInlineEnums(codegenModel, parentCodegenModel);
} }

View File

@ -17,12 +17,14 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.openapitools.codegen.*;
import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.media.*; import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.*; import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import java.io.File; import java.io.File;
@ -171,8 +173,8 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi
} }
@Override @Override
public CodegenModel fromModel(String name, Schema mod, Map<String, Schema> allDefinitions) { public CodegenModel fromModel(String name, Schema mod) {
CodegenModel model = super.fromModel(name, mod, allDefinitions); CodegenModel model = super.fromModel(name, mod);
// If a var is a base spec we won't need to import it // If a var is a base spec we won't need to import it
for (CodegenProperty var : model.vars) { for (CodegenProperty var : model.vars) {

View File

@ -19,20 +19,10 @@ package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import java.util.HashMap; import java.util.*;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
public class ConfluenceWikiCodegen extends DefaultCodegen implements CodegenConfig { public class ConfluenceWikiCodegen extends DefaultCodegen implements CodegenConfig {
private static final String ALL_OPERATIONS = ""; private static final String ALL_OPERATIONS = "";

View File

@ -17,29 +17,16 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.responses.ApiResponse; import io.swagger.v3.oas.models.responses.ApiResponse;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CodegenModel; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import static org.openapitools.codegen.utils.StringUtils.underscore; import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -169,8 +156,8 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
@Override @Override
public CodegenModel fromModel(String name, Schema model, Map<String, Schema> allDefinitions) { public CodegenModel fromModel(String name, Schema model) {
CodegenModel codegenModel = super.fromModel(name, model, allDefinitions); CodegenModel codegenModel = super.fromModel(name, model);
Set<String> oldImports = codegenModel.imports; Set<String> oldImports = codegenModel.imports;
codegenModel.imports = new HashSet<>(); codegenModel.imports = new HashSet<>();
@ -185,9 +172,8 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
} }
@Override @Override
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, public CodegenOperation fromOperation(String path, String httpMethod, Operation operation) {
Map<String, Schema> definitions, OpenAPI openAPI) { CodegenOperation op = super.fromOperation(path, httpMethod, operation);
CodegenOperation op = super.fromOperation(path, httpMethod, operation, definitions, openAPI);
if (operation.getResponses() != null && !operation.getResponses().isEmpty()) { if (operation.getResponses() != null && !operation.getResponses().isEmpty()) {
ApiResponse apiResponse = findMethodResponse(operation.getResponses()); ApiResponse apiResponse = findMethodResponse(operation.getResponses());

View File

@ -1,24 +1,16 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import java.io.File; import io.swagger.v3.oas.models.media.ArraySchema;
import java.util.ArrayList; import io.swagger.v3.oas.models.media.Schema;
import java.util.Arrays; import io.swagger.v3.parser.util.SchemaTypeUtil;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CodegenConfig; import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenOperation; import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter; import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import io.swagger.v3.oas.models.media.ArraySchema; import java.io.File;
import io.swagger.v3.oas.models.media.Schema; import java.util.*;
import io.swagger.v3.parser.util.SchemaTypeUtil;
public class CppQt5AbstractCodegen extends AbstractCppCodegen implements CodegenConfig { public class CppQt5AbstractCodegen extends AbstractCppCodegen implements CodegenConfig {
@ -283,7 +275,7 @@ public class CppQt5AbstractCodegen extends AbstractCppCodegen implements Codegen
@Override @Override
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public Map<String, Object> postProcessOperations(Map<String, Object> objs) { public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations"); Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation"); List<CodegenOperation> operations = (List<CodegenOperation>) objectMap.get("operation");

View File

@ -21,17 +21,9 @@ import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenConstants; import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenType; import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile; import org.openapitools.codegen.SupportingFile;
import java.io.File; import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import static org.openapitools.codegen.utils.StringUtils.underscore;
public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements CodegenConfig { public class CppQt5ClientCodegen extends CppQt5AbstractCodegen implements CodegenConfig {
public static final String OPTIONAL_PROJECT_FILE_DESC = "Generate client.pri."; public static final String OPTIONAL_PROJECT_FILE_DESC = "Generate client.pri.";
// source folder where to write the files // source folder where to write the files

View File

@ -20,19 +20,9 @@ package org.openapitools.codegen.languages;
import org.openapitools.codegen.CodegenConfig; import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenType; import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile; import org.openapitools.codegen.SupportingFile;
import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import static org.openapitools.codegen.utils.StringUtils.underscore;
public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implements CodegenConfig { public class CppQt5QHttpEngineServerCodegen extends CppQt5AbstractCodegen implements CodegenConfig {
protected final String SRC_DIR = "/src"; protected final String SRC_DIR = "/src";

View File

@ -19,29 +19,15 @@ package org.openapitools.codegen.languages;
import com.google.common.collect.ArrayListMultimap; import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap; import com.google.common.collect.Multimap;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.responses.ApiResponse; import io.swagger.v3.oas.models.responses.ApiResponse;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CodegenConstants; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import java.util.Arrays; import java.util.*;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import static com.google.common.base.Strings.isNullOrEmpty; import static com.google.common.base.Strings.isNullOrEmpty;
@ -225,8 +211,8 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
} }
@Override @Override
public CodegenModel fromModel(String name, Schema model, Map<String, Schema> allDefinitions) { public CodegenModel fromModel(String name, Schema model) {
CodegenModel codegenModel = super.fromModel(name, model, allDefinitions); CodegenModel codegenModel = super.fromModel(name, model);
Set<String> oldImports = codegenModel.imports; Set<String> oldImports = codegenModel.imports;
codegenModel.imports = new HashSet<String>(); codegenModel.imports = new HashSet<String>();
@ -241,16 +227,15 @@ public class CppRestSdkClientCodegen extends AbstractCppCodegen {
} }
@Override @Override
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, public CodegenOperation fromOperation(String path, String httpMethod, Operation operation) {
Map<String, Schema> schema, OpenAPI openAPI) { CodegenOperation op = super.fromOperation(path, httpMethod, operation);
CodegenOperation op = super.fromOperation(path, httpMethod, operation, schema, openAPI);
if (operation.getResponses() != null && !operation.getResponses().isEmpty()) { if (operation.getResponses() != null && !operation.getResponses().isEmpty()) {
ApiResponse methodResponse = findMethodResponse(operation.getResponses()); ApiResponse methodResponse = findMethodResponse(operation.getResponses());
if (methodResponse != null) { if (methodResponse != null) {
Schema response = ModelUtils.getSchemaFromResponse(methodResponse); Schema response = ModelUtils.getSchemaFromResponse(methodResponse);
response = ModelUtils.unaliasSchema(openAPI.getComponents().getSchemas(), response); response = ModelUtils.unaliasSchema(this.openAPI, response);
if (response != null) { if (response != null) {
CodegenProperty cm = fromProperty("response", response); CodegenProperty cm = fromProperty("response", response);
op.vendorExtensions.put("x-codegen-response", cm); op.vendorExtensions.put("x-codegen-response", cm);

View File

@ -17,22 +17,15 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import java.io.File; import io.swagger.v3.oas.models.media.ArraySchema;
import java.util.ArrayList; import io.swagger.v3.oas.models.media.Schema;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*; import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import io.swagger.v3.oas.models.media.*; import java.io.File;
import java.util.*;
public class CppRestbedServerCodegen extends AbstractCppCodegen { public class CppRestbedServerCodegen extends AbstractCppCodegen {
@ -180,8 +173,8 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
} }
@Override @Override
public CodegenModel fromModel(String name, Schema model, Map<String, Schema> allDefinitions) { public CodegenModel fromModel(String name, Schema model) {
CodegenModel codegenModel = super.fromModel(name, model, allDefinitions); CodegenModel codegenModel = super.fromModel(name, model);
Set<String> oldImports = codegenModel.imports; Set<String> oldImports = codegenModel.imports;
codegenModel.imports = new HashSet<String>(); codegenModel.imports = new HashSet<String>();

View File

@ -17,16 +17,14 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CodegenConfig; import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenType; import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.SupportingFile; import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.parser.util.SchemaTypeUtil;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;

View File

@ -17,30 +17,17 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.openapitools.codegen.CliOption; import io.swagger.v3.oas.models.media.ArraySchema;
import org.openapitools.codegen.CodegenConfig; import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils;
import io.swagger.v3.oas.models.media.*;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore; import static org.openapitools.codegen.utils.StringUtils.underscore;

View File

@ -16,23 +16,13 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.openapitools.codegen.CliOption; import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.CodegenConstants; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CodegenModel; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import io.swagger.v3.oas.models.media.*;
import org.apache.commons.lang3.StringUtils;
import java.io.File; import java.io.File;
import java.util.HashSet; import java.util.*;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import static org.openapitools.codegen.utils.StringUtils.underscore; import static org.openapitools.codegen.utils.StringUtils.underscore;
@ -159,8 +149,8 @@ public class DartJaguarClientCodegen extends DartClientCodegen {
} }
@Override @Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) { public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
objs = super.postProcessOperations(objs); objs = super.postProcessOperationsWithModels(objs, allModels);
Map<String, Object> operations = (Map<String, Object>) objs.get("operations"); Map<String, Object> operations = (Map<String, Object>) objs.get("operations");
List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation"); List<CodegenOperation> operationList = (List<CodegenOperation>) operations.get("operation");

View File

@ -19,14 +19,13 @@ package org.openapitools.codegen.languages;
import com.samskivert.mustache.Mustache; import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template; import com.samskivert.mustache.Template;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*; import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import io.swagger.v3.oas.models.*;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.media.*;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -37,8 +36,8 @@ import java.util.*;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static org.openapitools.codegen.utils.StringUtils.underscore;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig { public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(ElixirClientCodegen.class); private static final Logger LOGGER = LoggerFactory.getLogger(ElixirClientCodegen.class);
@ -306,8 +305,8 @@ public class ElixirClientCodegen extends DefaultCodegen implements CodegenConfig
} }
@Override @Override
public CodegenModel fromModel(String name, Schema model, Map<String, Schema> allDefinitions) { public CodegenModel fromModel(String name, Schema model) {
CodegenModel cm = super.fromModel(name, model, allDefinitions); CodegenModel cm = super.fromModel(name, model);
return new ExtendedCodegenModel(cm); return new ExtendedCodegenModel(cm);
} }

View File

@ -17,41 +17,19 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.responses.ApiResponse; import io.swagger.v3.oas.models.responses.ApiResponse;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenResponse;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.text.Collator; import java.text.Collator;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;
@ -323,8 +301,8 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
} }
@Override @Override
public CodegenModel fromModel(String name, Schema schema, Map<String, Schema> allDefinitions) { public CodegenModel fromModel(String name, Schema schema) {
CodegenModel m = super.fromModel(name, schema, allDefinitions); CodegenModel m = super.fromModel(name, schema);
if (ModelUtils.isArraySchema(schema)) { if (ModelUtils.isArraySchema(schema)) {
ArraySchema am = (ArraySchema) schema; ArraySchema am = (ArraySchema) schema;
@ -660,8 +638,8 @@ public class ElmClientCodegen extends DefaultCodegen implements CodegenConfig {
} }
@Override @Override
public CodegenResponse fromResponse(OpenAPI openAPI, String responseCode, ApiResponse resp) { public CodegenResponse fromResponse(String responseCode, ApiResponse resp) {
final CodegenResponse response = super.fromResponse(openAPI, responseCode, resp); final CodegenResponse response = super.fromResponse(responseCode, resp);
if (response.dataType != null) { if (response.dataType != null) {
final boolean isPrimitiveType = response.isMapContainer ? isPrimitiveDataType(response.dataType) : response.primitiveType; final boolean isPrimitiveType = response.isMapContainer ? isPrimitiveDataType(response.dataType) : response.primitiveType;
addEncoderAndDecoder(response.vendorExtensions, response.dataType, isPrimitiveType ? DataTypeExposure.PRIMITIVE : DataTypeExposure.EXTERNAL); addEncoderAndDecoder(response.vendorExtensions, response.dataType, isPrimitiveType ? DataTypeExposure.PRIMITIVE : DataTypeExposure.EXTERNAL);

View File

@ -19,20 +19,19 @@ package org.openapitools.codegen.languages;
import com.samskivert.mustache.Mustache; import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template; import com.samskivert.mustache.Template;
import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.*; import org.openapitools.codegen.*;
import org.openapitools.codegen.mustache.JoinWithCommaLambda; import org.openapitools.codegen.mustache.JoinWithCommaLambda;
import io.swagger.v3.oas.models.media.*; import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.util.*;
import java.io.Writer;
import java.io.IOException; import java.io.IOException;
import java.io.Writer;
import java.util.*;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore; import static org.openapitools.codegen.utils.StringUtils.underscore;

View File

@ -108,8 +108,8 @@ public class ErlangProperCodegen extends DefaultCodegen implements CodegenConfig
} }
@Override @Override
public CodegenModel fromModel(String name, Schema model, Map<String, Schema> allDefinitions) { public CodegenModel fromModel(String name, Schema model) {
CodegenModel cm = super.fromModel(name, model, allDefinitions); CodegenModel cm = super.fromModel(name, model);
if(ModelUtils.isArraySchema(model)) { if(ModelUtils.isArraySchema(model)) {
return new CodegenArrayModel(cm, (ArraySchema) model); return new CodegenArrayModel(cm, (ArraySchema) model);
} else { } else {

View File

@ -17,13 +17,7 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.SupportingFile;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

View File

@ -17,7 +17,6 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConstants; import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenType; import org.openapitools.codegen.CodegenType;
@ -26,7 +25,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.util.Arrays;
public class GoClientCodegen extends AbstractGoCodegen { public class GoClientCodegen extends AbstractGoCodegen {

View File

@ -16,7 +16,6 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CodegenConstants; import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenOperation; import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenType; import org.openapitools.codegen.CodegenType;

View File

@ -17,7 +17,6 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CodegenConstants; import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenType; import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile; import org.openapitools.codegen.SupportingFile;

View File

@ -15,12 +15,6 @@
*/ */
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConfig; import org.openapitools.codegen.CodegenConfig;

View File

@ -17,9 +17,12 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.openapitools.codegen.*; import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import java.io.File; import java.io.File;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;

View File

@ -22,9 +22,9 @@ import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.security.SecurityScheme; import io.swagger.v3.oas.models.security.SecurityScheme;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
import org.openapitools.codegen.*; import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
@ -755,8 +755,8 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC
} }
@Override @Override
public CodegenModel fromModel(String name, Schema mod, Map<String, Schema> allDefinitions) { public CodegenModel fromModel(String name, Schema mod) {
CodegenModel model = super.fromModel(name, mod, allDefinitions); CodegenModel model = super.fromModel(name, mod);
// while (typeNames.contains(model.classname)) { // while (typeNames.contains(model.classname)) {
// model.classname = generateNextName(model.classname); // model.classname = generateNextName(model.classname);

View File

@ -23,28 +23,13 @@ import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;
@ -473,8 +458,8 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
@Override @Override
public CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation, Map<String, Schema> definitions, OpenAPI openAPI) { public CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation) {
CodegenOperation op = super.fromOperation(resourcePath, httpMethod, operation, definitions, openAPI); CodegenOperation op = super.fromOperation(resourcePath, httpMethod, operation);
List<String> path = pathToServantRoute(op.path, op.pathParams); List<String> path = pathToServantRoute(op.path, op.pathParams);
List<String> type = pathToClientType(op.path, op.pathParams); List<String> type = pathToClientType(op.path, op.pathParams);
@ -599,8 +584,8 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
// Override fromModel to create the appropriate model namings // Override fromModel to create the appropriate model namings
@Override @Override
public CodegenModel fromModel(String name, Schema mod, Map<String, Schema> allDefinitions) { public CodegenModel fromModel(String name, Schema mod) {
CodegenModel model = super.fromModel(name, mod, allDefinitions); CodegenModel model = super.fromModel(name, mod);
setGenerateToSchema(model); setGenerateToSchema(model);

View File

@ -17,13 +17,19 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.openapitools.codegen.*; import io.swagger.v3.oas.models.OpenAPI;
import org.openapitools.codegen.utils.*; import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.*; import io.swagger.v3.oas.models.PathItem;
import io.swagger.v3.oas.models.media.*; import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.utils.ModelUtils;
import java.util.*;
import java.io.File; import java.io.File;
import java.util.Arrays;
import java.util.HashSet;
public class JMeterClientCodegen extends DefaultCodegen implements CodegenConfig { public class JMeterClientCodegen extends DefaultCodegen implements CodegenConfig {

View File

@ -18,13 +18,7 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.Operation;
import org.openapitools.codegen.*;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.languages.features.BeanValidationFeatures; import org.openapitools.codegen.languages.features.BeanValidationFeatures;
import org.openapitools.codegen.languages.features.GzipTestFeatures; import org.openapitools.codegen.languages.features.GzipTestFeatures;
import org.openapitools.codegen.languages.features.LoggingTestFeatures; import org.openapitools.codegen.languages.features.LoggingTestFeatures;

View File

@ -18,12 +18,7 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.Operation;
import org.openapitools.codegen.*;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.languages.features.CXFServerFeatures; import org.openapitools.codegen.languages.features.CXFServerFeatures;
import org.openapitools.codegen.languages.features.GzipTestFeatures; import org.openapitools.codegen.languages.features.GzipTestFeatures;
import org.openapitools.codegen.languages.features.LoggingTestFeatures; import org.openapitools.codegen.languages.features.LoggingTestFeatures;

View File

@ -19,14 +19,7 @@ package org.openapitools.codegen.languages;
import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.languages.features.BeanValidationFeatures; import org.openapitools.codegen.languages.features.BeanValidationFeatures;
import org.openapitools.codegen.languages.features.GzipFeatures; import org.openapitools.codegen.languages.features.GzipFeatures;
import org.openapitools.codegen.languages.features.PerformBeanValidationFeatures; import org.openapitools.codegen.languages.features.PerformBeanValidationFeatures;
@ -36,12 +29,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.*;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static com.google.common.base.CaseFormat.LOWER_CAMEL; import static com.google.common.base.CaseFormat.LOWER_CAMEL;

View File

@ -20,20 +20,13 @@ package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.Operation;
import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CodegenModel; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.config.GeneratorProperties; import org.openapitools.codegen.config.GeneratorProperties;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;

View File

@ -17,7 +17,10 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.openapitools.codegen.*; import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.languages.features.BeanValidationFeatures; import org.openapitools.codegen.languages.features.BeanValidationFeatures;
import java.io.File; import java.io.File;

View File

@ -19,13 +19,8 @@ package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.SupportingFile;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
@ -190,8 +185,8 @@ public class JavaJAXRSSpecServerCodegen extends AbstractJavaJAXRSServerCodegen {
} }
@Override @Override
public CodegenModel fromModel(String name, Schema model, Map<String, Schema> allDefinitions) { public CodegenModel fromModel(String name, Schema model) {
CodegenModel codegenModel = super.fromModel(name, model, allDefinitions); CodegenModel codegenModel = super.fromModel(name, model);
if (!useSwaggerAnnotations) { if (!useSwaggerAnnotations) {
codegenModel.imports.remove("ApiModelProperty"); codegenModel.imports.remove("ApiModelProperty");
codegenModel.imports.remove("ApiModel"); codegenModel.imports.remove("ApiModel");

View File

@ -17,18 +17,15 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.SupportingFile;
import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.Operation;
import java.util.*;
import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class JavaMSF4JServerCodegen extends AbstractJavaJAXRSServerCodegen { public class JavaMSF4JServerCodegen extends AbstractJavaJAXRSServerCodegen {

View File

@ -21,25 +21,12 @@ import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.PathItem; import io.swagger.v3.oas.models.PathItem;
import io.swagger.v3.oas.models.tags.Tag; import io.swagger.v3.oas.models.tags.Tag;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenResponse;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.URLPathUtils; import org.openapitools.codegen.utils.URLPathUtils;
import java.io.File; import java.io.File;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;

View File

@ -18,14 +18,7 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.*;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.languages.features.BeanValidationFeatures; import org.openapitools.codegen.languages.features.BeanValidationFeatures;
import java.io.File; import java.io.File;
@ -228,8 +221,8 @@ public class JavaPlayFrameworkCodegen extends AbstractJavaCodegen implements Bea
} }
@Override @Override
public CodegenModel fromModel(String name, Schema model, Map<String, Schema> allDefinitions) { public CodegenModel fromModel(String name, Schema model) {
CodegenModel codegenModel = super.fromModel(name, model, allDefinitions); CodegenModel codegenModel = super.fromModel(name, model);
if (codegenModel.description != null) { if (codegenModel.description != null) {
codegenModel.imports.remove("ApiModel"); codegenModel.imports.remove("ApiModel");
} }

View File

@ -18,7 +18,6 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.Operation; import io.swagger.v3.oas.models.Operation;
import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*; import org.openapitools.codegen.*;

View File

@ -17,14 +17,17 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.openapitools.codegen.*; import io.swagger.v3.oas.models.Operation;
import org.openapitools.codegen.languages.features.JbossFeature;
import io.swagger.v3.oas.models.*;
import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.languages.features.JbossFeature;
import java.io.File; import java.io.File;
import java.util.*; import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen implements JbossFeature { public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen implements JbossFeature {

View File

@ -18,11 +18,7 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.apache.commons.lang3.BooleanUtils; import org.apache.commons.lang3.BooleanUtils;
import org.openapitools.codegen.CodegenModel; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.config.GeneratorProperties; import org.openapitools.codegen.config.GeneratorProperties;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -30,6 +26,7 @@ import org.slf4j.LoggerFactory;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;

View File

@ -22,12 +22,7 @@ import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.PathItem; import io.swagger.v3.oas.models.PathItem;
import io.swagger.v3.oas.models.PathItem.HttpMethod; import io.swagger.v3.oas.models.PathItem.HttpMethod;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.URLPathUtils; import org.openapitools.codegen.utils.URLPathUtils;
import java.io.File; import java.io.File;
@ -198,17 +193,16 @@ public class JavaVertXServerCodegen extends AbstractJavaCodegen {
@Override @Override
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, public CodegenOperation fromOperation(String path, String httpMethod, Operation operation) {
Map<String, Schema> definitions, OpenAPI openAPI) {
CodegenOperation codegenOperation = CodegenOperation codegenOperation =
super.fromOperation(path, httpMethod, operation, definitions, openAPI); super.fromOperation(path, httpMethod, operation);
codegenOperation.imports.add("MainApiException"); codegenOperation.imports.add("MainApiException");
return codegenOperation; return codegenOperation;
} }
@Override @Override
public CodegenModel fromModel(String name, Schema model, Map<String, Schema> allDefinitions) { public CodegenModel fromModel(String name, Schema model) {
CodegenModel codegenModel = super.fromModel(name, model, allDefinitions); CodegenModel codegenModel = super.fromModel(name, model);
codegenModel.imports.remove("ApiModel"); codegenModel.imports.remove("ApiModel");
codegenModel.imports.remove("ApiModelProperty"); codegenModel.imports.remove("ApiModelProperty");
return codegenModel; return codegenModel;

View File

@ -23,34 +23,17 @@ import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License; import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.openapitools.codegen.CliOption; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CodegenConfig; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.*;
import static org.openapitools.codegen.utils.StringUtils.dashize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
public class JavascriptClientCodegen extends DefaultCodegen implements CodegenConfig { public class JavascriptClientCodegen extends DefaultCodegen implements CodegenConfig {
@SuppressWarnings("hiding") @SuppressWarnings("hiding")
@ -864,12 +847,13 @@ public class JavascriptClientCodegen extends DefaultCodegen implements CodegenCo
} }
@Override @Override
public CodegenModel fromModel(String name, Schema model, Map<String, Schema> allDefinitions) { public CodegenModel fromModel(String name, Schema model) {
CodegenModel codegenModel = super.fromModel(name, model, allDefinitions); Map<String, Schema> allDefinitions = ModelUtils.getSchemas(this.openAPI);
CodegenModel codegenModel = super.fromModel(name, model);
if (allDefinitions != null && codegenModel != null && codegenModel.parent != null && codegenModel.hasEnums) { if (allDefinitions != null && codegenModel != null && codegenModel.parent != null && codegenModel.hasEnums) {
final Schema parentModel = allDefinitions.get(codegenModel.parentSchema); final Schema parentModel = allDefinitions.get(codegenModel.parentSchema);
final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel, allDefinitions); final CodegenModel parentCodegenModel = super.fromModel(codegenModel.parent, parentModel);
codegenModel = JavascriptClientCodegen.reconcileInlineEnums(codegenModel, parentCodegenModel); codegenModel = JavascriptClientCodegen.reconcileInlineEnums(codegenModel, parentCodegenModel);
} }
if (ModelUtils.isArraySchema(model)) { if (ModelUtils.isArraySchema(model)) {

View File

@ -17,30 +17,18 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.openapitools.codegen.CliOption; import io.swagger.v3.oas.models.OpenAPI;
import org.openapitools.codegen.CodegenConfig; import io.swagger.v3.oas.models.media.ArraySchema;
import org.openapitools.codegen.CodegenConstants; import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.CodegenModel; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CodegenOperation; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.oas.models.PathItem;
import io.swagger.v3.oas.models.PathItem.HttpMethod;
import io.swagger.v3.oas.models.*;
import io.swagger.v3.oas.models.parameters.*;
import io.swagger.v3.oas.models.info.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.*;
import java.io.File; import java.io.File;
import java.util.*;
import org.apache.commons.lang3.StringUtils;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;
public class JavascriptClosureAngularClientCodegen extends DefaultCodegen implements CodegenConfig { public class JavascriptClosureAngularClientCodegen extends DefaultCodegen implements CodegenConfig {

View File

@ -18,12 +18,12 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.OpenAPI; import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.parser.util.SchemaTypeUtil; import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.openapitools.codegen.*;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;

View File

@ -19,17 +19,12 @@ package org.openapitools.codegen.languages;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache; import com.samskivert.mustache.Mustache;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConstants; import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenType; import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile; import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.mustache.CamelCaseLambda; import org.openapitools.codegen.mustache.*;
import org.openapitools.codegen.mustache.IndentedLambda;
import org.openapitools.codegen.mustache.LowercaseLambda;
import org.openapitools.codegen.mustache.TitlecaseLambda;
import org.openapitools.codegen.mustache.UppercaseLambda;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;

View File

@ -554,8 +554,8 @@ public class KotlinSpringServerCodegen extends AbstractKotlinCodegen
// Can't figure out the logic in DefaultCodegen but optional vars are getting duplicated when there's // Can't figure out the logic in DefaultCodegen but optional vars are getting duplicated when there's
// inheritance involved. Also, isInherited doesn't seem to be getting set properly ¯\_()_/¯ // inheritance involved. Also, isInherited doesn't seem to be getting set properly ¯\_()_/¯
@Override @Override
public CodegenModel fromModel(String name, Schema schema, Map<String, Schema> allDefinitions) { public CodegenModel fromModel(String name, Schema schema) {
CodegenModel m = super.fromModel(name, schema, allDefinitions); CodegenModel m = super.fromModel(name, schema);
m.optionalVars = m.optionalVars.stream().distinct().collect(Collectors.toList()); m.optionalVars = m.optionalVars.stream().distinct().collect(Collectors.toList());
m.allVars.stream().filter(p -> !m.vars.contains(p)).forEach(p -> p.isInherited = true); m.allVars.stream().filter(p -> !m.vars.contains(p)).forEach(p -> p.isInherited = true);

View File

@ -20,28 +20,13 @@ package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import java.util.Map;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore; import static org.openapitools.codegen.utils.StringUtils.underscore;

View File

@ -16,29 +16,13 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenProperty;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.Collections; import java.util.*;
import java.util.HashMap;
import java.util.List;
import java.util.Vector;
import java.util.Map;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.Locale;
public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig { public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(MysqlSchemaCodegen.class); private static final Logger LOGGER = LoggerFactory.getLogger(MysqlSchemaCodegen.class);

View File

@ -26,14 +26,7 @@ import io.swagger.v3.oas.models.PathItem;
import io.swagger.v3.oas.models.PathItem.HttpMethod; import io.swagger.v3.oas.models.PathItem.HttpMethod;
import io.swagger.v3.oas.models.Paths; import io.swagger.v3.oas.models.Paths;
import io.swagger.v3.oas.models.info.Info; import io.swagger.v3.oas.models.info.Info;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenResponse;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.config.GeneratorProperties; import org.openapitools.codegen.config.GeneratorProperties;
import org.openapitools.codegen.utils.URLPathUtils; import org.openapitools.codegen.utils.URLPathUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -41,14 +34,7 @@ import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.net.URL; import java.net.URL;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.regex.Pattern; import java.util.regex.Pattern;

View File

@ -20,30 +20,14 @@ package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;
public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig { public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
@ -662,7 +646,6 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
/** /**
* Return the default value of the schema * Return the default value of the schema
*
* @param p OpenAPI schema object * @param p OpenAPI schema object
* @return string presentation of the default value of the schema * @return string presentation of the default value of the schema
*/ */

View File

@ -17,15 +17,17 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import java.io.File; import io.swagger.v3.core.util.Json;
import io.swagger.v3.oas.models.OpenAPI;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.SupportingFile;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.openapitools.codegen.*; import java.io.File;
import io.swagger.v3.oas.models.*;
import io.swagger.v3.core.util.Json;
public class OpenAPIGenerator extends DefaultCodegen implements CodegenConfig { public class OpenAPIGenerator extends DefaultCodegen implements CodegenConfig {

View File

@ -22,7 +22,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.util.Map; import java.util.Map;
import java.io.File;
public class OpenAPIYamlGenerator extends DefaultCodegen implements CodegenConfig { public class OpenAPIYamlGenerator extends DefaultCodegen implements CodegenConfig {
public static final String OUTPUT_NAME = "outputFile"; public static final String OUTPUT_NAME = "outputFile";

View File

@ -17,23 +17,19 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*; import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.io.FilenameUtils;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore; import static org.openapitools.codegen.utils.StringUtils.underscore;

View File

@ -17,21 +17,19 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConstants; import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenType; import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile; import org.openapitools.codegen.SupportingFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PhpClientCodegen extends AbstractPhpCodegen { public class PhpClientCodegen extends AbstractPhpCodegen {
@SuppressWarnings("hiding") @SuppressWarnings("hiding")
private static final Logger LOGGER = LoggerFactory.getLogger(PhpClientCodegen.class); private static final Logger LOGGER = LoggerFactory.getLogger(PhpClientCodegen.class);

View File

@ -17,7 +17,9 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.openapitools.codegen.*; import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import java.io.File; import java.io.File;
import java.util.*; import java.util.*;
@ -199,7 +201,7 @@ public class PhpLaravelServerCodegen extends AbstractPhpCodegen {
// override with any special post-processing // override with any special post-processing
@Override @Override
public Map<String, Object> postProcessOperations(Map<String, Object> objs) { public Map<String, Object> postProcessOperationsWithModels(Map<String, Object> objs, List<Object> allModels) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations"); Map<String, Object> objectMap = (Map<String, Object>) objs.get("operations");
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")

View File

@ -17,24 +17,14 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.openapitools.codegen.CodegenConfig; import io.swagger.v3.oas.models.media.ArraySchema;
import org.openapitools.codegen.CodegenConstants; import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.CodegenType; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CodegenOperation; import org.openapitools.codegen.*;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import io.swagger.v3.oas.models.media.*;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore; import static org.openapitools.codegen.utils.StringUtils.underscore;

View File

@ -17,29 +17,17 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.openapitools.codegen.CliOption; import io.swagger.v3.oas.models.Operation;
import org.openapitools.codegen.CodegenConstants; import io.swagger.v3.oas.models.security.SecurityScheme;
import org.openapitools.codegen.CodegenOperation; import org.apache.commons.lang3.StringEscapeUtils;
import org.openapitools.codegen.CodegenType; import org.openapitools.codegen.*;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.CodegenSecurity;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import io.swagger.v3.oas.models.security.SecurityScheme;
import java.io.File; import java.io.File;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.net.URLEncoder;
import org.apache.commons.lang3.StringEscapeUtils;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import io.swagger.v3.oas.models.OpenAPI; import java.util.*;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.Schema;
public class PhpSlimServerCodegen extends AbstractPhpCodegen { public class PhpSlimServerCodegen extends AbstractPhpCodegen {
private static final Logger LOGGER = LoggerFactory.getLogger(PhpSlimServerCodegen.class); private static final Logger LOGGER = LoggerFactory.getLogger(PhpSlimServerCodegen.class);
@ -254,10 +242,8 @@ public class PhpSlimServerCodegen extends AbstractPhpCodegen {
@Override @Override
public CodegenOperation fromOperation(String path, public CodegenOperation fromOperation(String path,
String httpMethod, String httpMethod,
Operation operation, Operation operation) {
Map<String, Schema> schemas, CodegenOperation op = super.fromOperation(path, httpMethod, operation);
OpenAPI openAPI) {
CodegenOperation op = super.fromOperation(path, httpMethod, operation, schemas, openAPI);
op.path = encodePath(path); op.path = encodePath(path);
return op; return op;
} }

View File

@ -20,26 +20,14 @@ package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.media.ArraySchema; import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import org.openapitools.codegen.utils.ProcessUtils; import org.openapitools.codegen.utils.ProcessUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.util.Arrays; import java.util.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import static java.util.UUID.randomUUID; import static java.util.UUID.randomUUID;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;

View File

@ -29,12 +29,13 @@ import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.Parameter; import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.parameters.RequestBody; import io.swagger.v3.oas.models.parameters.RequestBody;
import io.swagger.v3.oas.models.security.SecurityScheme; import io.swagger.v3.oas.models.security.SecurityScheme;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*; import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.util.*; import java.util.*;
@ -580,7 +581,6 @@ public class PythonAbstractConnexionServerCodegen extends DefaultCodegen impleme
/** /**
* Return the default value of the property * Return the default value of the property
*
* @param p OpenAPI property object * @param p OpenAPI property object
* @return string presentation of the default value of the property * @return string presentation of the default value of the property
*/ */

View File

@ -15,11 +15,9 @@
*/ */
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.openapitools.codegen.*; import org.openapitools.codegen.SupportingFile;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
public class PythonAiohttpConnexionServerCodegen extends PythonAbstractConnexionServerCodegen { public class PythonAiohttpConnexionServerCodegen extends PythonAbstractConnexionServerCodegen {
private static final Logger LOGGER = LoggerFactory.getLogger(PythonAiohttpConnexionServerCodegen.class); private static final Logger LOGGER = LoggerFactory.getLogger(PythonAiohttpConnexionServerCodegen.class);

View File

@ -21,26 +21,13 @@ import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption; import org.openapitools.codegen.*;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenModel;
import org.openapitools.codegen.CodegenParameter;
import org.openapitools.codegen.CodegenProperty;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.DefaultCodegen;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.camelize;
@ -611,7 +598,6 @@ public class PythonClientCodegen extends DefaultCodegen implements CodegenConfig
/** /**
* Return the default value of the property * Return the default value of the property
*
* @param p OpenAPI property object * @param p OpenAPI property object
* @return string presentation of the default value of the property * @return string presentation of the default value of the property
*/ */

View File

@ -16,14 +16,11 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import org.openapitools.codegen.*; import org.openapitools.codegen.SupportingFile;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.camelize; import java.io.File;
import static org.openapitools.codegen.utils.StringUtils.underscore;
public class PythonFlaskConnexionServerCodegen extends PythonAbstractConnexionServerCodegen { public class PythonFlaskConnexionServerCodegen extends PythonAbstractConnexionServerCodegen {
private static final Logger LOGGER = LoggerFactory.getLogger(PythonFlaskConnexionServerCodegen.class); private static final Logger LOGGER = LoggerFactory.getLogger(PythonFlaskConnexionServerCodegen.class);

View File

@ -17,9 +17,9 @@
package org.openapitools.codegen.languages; package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.examples.Example;
import io.swagger.v3.oas.models.media.Schema; import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.Parameter; import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.examples.Example;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*; import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.ModelUtils; import org.openapitools.codegen.utils.ModelUtils;

Some files were not shown because too many files have changed in this diff Show More