adding Intellij style xml and applied to all java code (#20734)

* added intellij-codestyle.xml and sample of it being applied to some java code-gen classes

* code-format changes ONLY

* few more format changes since last merge with master

* applied code-style to all java one last time
This commit is contained in:
Ron Reynolds 2025-03-03 09:44:48 -08:00 committed by GitHub
parent 3ad5303f99
commit 2cff152e2a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
481 changed files with 5502 additions and 5688 deletions

9
intellij-codestyle.xml Normal file
View File

@ -0,0 +1,9 @@
<code_scheme name="Project" version="173">
<JavaCodeStyleSettings>
<option name="DO_NOT_WRAP_AFTER_SINGLE_ANNOTATION" value="true" />
<option name="DO_NOT_WRAP_AFTER_SINGLE_ANNOTATION_IN_PARAMETER" value="true" />
</JavaCodeStyleSettings>
<codeStyleSettings language="JAVA">
<option name="FIELD_ANNOTATION_WRAP" value="0" />
</codeStyleSettings>
</code_scheme>

View File

@ -1,7 +1,8 @@
package org.openapitools.codegen;
public class Constants {
private Constants(){ }
private Constants() {
}
public static final String CLI_NAME = "openapi-generator-cli";
public static final String GIT_REPO = "https://github.com/openapitools/openapi-generator";

View File

@ -20,11 +20,7 @@ package org.openapitools.codegen.cmd;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenConfigLoader;
import org.openapitools.codegen.GeneratorNotFoundException;
import org.openapitools.codegen.VendorExtension;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.FeatureSet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -37,8 +33,8 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.stream.Collectors;
import static org.apache.commons.text.StringEscapeUtils.escapeHtml4;
import static org.apache.commons.lang3.StringUtils.isEmpty;
import static org.apache.commons.text.StringEscapeUtils.escapeHtml4;
@SuppressWarnings({"unused", "java:S106", "java:S1192"})
@Command(name = "config-help", description = "Config help for chosen lang")

View File

@ -17,18 +17,10 @@
package org.openapitools.codegen.cmd;
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.*;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.spi.FilterAttachable;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.config.CodegenConfigurator;
@ -36,6 +28,14 @@ import org.openapitools.codegen.config.MergedSpecBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.*;
@SuppressWarnings({"java:S106"})
@Command(name = "generate", description = "Generate code with the specified generator.")
public class Generate extends OpenApiGeneratorCommand {

View File

@ -18,7 +18,6 @@ package org.openapitools.codegen.cmd;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.LoggerContext;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.databind.*;
@ -26,7 +25,6 @@ import com.fasterxml.jackson.databind.deser.BeanDeserializerModifier;
import com.fasterxml.jackson.databind.deser.std.DelegatingDeserializer;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.util.TokenBuffer;
import io.airlift.airline.Arguments;
import io.airlift.airline.Command;
import io.airlift.airline.Option;

View File

@ -1,10 +1,8 @@
package org.openapitools.codegen.cmd;
import com.google.common.base.Objects;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenConfigLoader;

View File

@ -17,9 +17,7 @@
package org.openapitools.codegen.cmd;
import static ch.lambdaj.collection.LambdaCollections.with;
import static com.google.common.base.Joiner.on;
import ch.lambdaj.function.convert.Converter;
import com.google.common.base.CaseFormat;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
@ -31,9 +29,9 @@ import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.TemplateManager;
import org.openapitools.codegen.api.TemplatePathLocator;
import org.openapitools.codegen.templating.CommonTemplateContentLocator;
import org.openapitools.codegen.templating.MustacheEngineAdapter;
import org.openapitools.codegen.templating.TemplateManagerOptions;
import org.openapitools.codegen.templating.CommonTemplateContentLocator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -43,7 +41,8 @@ import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
import ch.lambdaj.function.convert.Converter;
import static ch.lambdaj.collection.LambdaCollections.with;
import static com.google.common.base.Joiner.on;
/**
* User: lanwen Date: 24.03.15 Time: 20:22

View File

@ -19,7 +19,6 @@ package org.openapitools.codegen.cmd;
import io.airlift.airline.Command;
import io.airlift.airline.Option;
import io.swagger.parser.OpenAPIParser;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.parser.core.models.AuthorizationValue;

View File

@ -17,8 +17,8 @@
package org.openapitools.codegen.cmd.utils;
import org.openapitools.codegen.utils.OptionUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.openapitools.codegen.utils.OptionUtils;
import org.testng.annotations.Test;
import java.util.Collections;

View File

@ -27,7 +27,6 @@ public abstract class AbstractTemplatingEngineAdapter implements TemplatingEngin
* Gets all possible template paths for a given location.
*
* @param location The full location of the template.
*
* @return A new array of locations, modified according to the extensions or other adapter rules.
*/
protected String[] getModifiedFileLocation(String location) {
@ -44,7 +43,6 @@ public abstract class AbstractTemplatingEngineAdapter implements TemplatingEngin
* Returns the path without an extension for an input location.
*
* @param location The location of the file, with original file extension intact.
*
* @return The full path, without extension (e.g. /path/to/file.txt => /path/to/file)
*/
private String getPathWithoutExtension(String location) {

View File

@ -94,7 +94,9 @@ public class TemplateDefinition {
this.templateType = templateType;
}
/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
@Override
public boolean equals(Object o) {
if (this == o) return true;
@ -106,13 +108,17 @@ public class TemplateDefinition {
getTemplateType() == that.getTemplateType();
}
/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
@Override
public int hashCode() {
return Objects.hash(getTemplateFile(), getFolder(), getDestinationFilename(), getTemplateType());
}
/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
@Override
public String toString() {
return new StringJoiner(", ", TemplateDefinition.class.getSimpleName() + "[", "]")

View File

@ -17,16 +17,22 @@ public enum TemplateFileType {
private final String templateType;
TemplateFileType(String templateType) { this.templateType = templateType; }
TemplateFileType(String templateType) {
this.templateType = templateType;
}
/**
* Returns the value for this template file type
*
* @return The template type of this enum.
*/
public String value() { return this.templateType; }
public String value() {
return this.templateType;
}
/** {@inheritDoc} */
/**
* {@inheritDoc}
*/
@Override
public String toString() {
return new StringJoiner(", ", TemplateFileType.class.getSimpleName() + "[", "]")

View File

@ -15,7 +15,6 @@ public interface TemplateProcessor {
* @param data Input data
* @param template Input template location
* @param target The targeted file output location
*
* @return The actual file
* @throws IOException If file cannot be written.
*/
@ -53,5 +52,6 @@ public interface TemplateProcessor {
* @param path The path which has caused an error
* @param context The reason for the error
*/
default void error(Path path, String context) { }
default void error(Path path, String context) {
}
}

View File

@ -47,8 +47,8 @@ public interface TemplatingEngineAdapter {
/**
* Determine if the adapter handles compilation of the file
* @param filename The template filename
*
* @param filename The template filename
* @return True if the file should be compiled by this adapter, else false.
*/
default boolean handlesFile(String filename) {

View File

@ -17,6 +17,7 @@
package org.openapitools.codegen.api;
// TODO: 6.0 Remove
/**
* interface to the full template content
* implementers might take into account the -t cli option,

View File

@ -383,7 +383,6 @@ public class FeatureSet {
* Includes the defined {@link ClientModificationFeature} to the new/existing set of supported features.
*
* @param clientModificationFeature One or more {@code clientModificationFeature} to ensure are included in the set.
*
* @return a reference to this Builder
*/
public Builder includeClientModificationFeatures(ClientModificationFeature... clientModificationFeature) {
@ -395,7 +394,6 @@ public class FeatureSet {
* Excludes the defined {@link ClientModificationFeature} from the set of supported features.
*
* @param clientModificationFeature One or more {@code clientModificationFeature} to ensure are excluded from the set.
*
* @return a reference to this Builder
*/
public Builder excludeClientModificationFeatures(ClientModificationFeature... clientModificationFeature) {
@ -422,7 +420,6 @@ public class FeatureSet {
* Includes the defined {@link DataTypeFeature} to the new/existing set of supported features.
*
* @param dataTypeFeature One or more {@code dataTypeFeature} to ensure are included in the set.
*
* @return a reference to this Builder
*/
public Builder includeDataTypeFeatures(DataTypeFeature... dataTypeFeature) {
@ -434,7 +431,6 @@ public class FeatureSet {
* Excludes the defined {@link DataTypeFeature} from the set of supported features.
*
* @param dataTypeFeature One or more {@code dataTypeFeature} to ensure are excluded from the set.
*
* @return a reference to this Builder
*/
public Builder excludeDataTypeFeatures(DataTypeFeature... dataTypeFeature) {
@ -461,7 +457,6 @@ public class FeatureSet {
* Includes the defined {@link DocumentationFeature} to the new/existing set of supported features.
*
* @param documentationFeature One or more {@code documentationFeature} to ensure are included in the set.
*
* @return a reference to this Builder
*/
public Builder includeDocumentationFeatures(DocumentationFeature... documentationFeature) {
@ -473,7 +468,6 @@ public class FeatureSet {
* Excludes the defined {@link DocumentationFeature} from the set of supported features.
*
* @param documentationFeature One or more {@code documentationFeature} to ensure are excluded from the set.
*
* @return a reference to this Builder
*/
public Builder excludeDocumentationFeatures(DocumentationFeature... documentationFeature) {
@ -500,7 +494,6 @@ public class FeatureSet {
* Includes the defined {@link SchemaSupportFeature} to the new/existing set of supported features.
*
* @param schemaSupportFeature One or more {@code schemaSupportFeature} to ensure are included in the set.
*
* @return a reference to this Builder
*/
public Builder includeSchemaSupportFeatures(SchemaSupportFeature... schemaSupportFeature) {
@ -512,7 +505,6 @@ public class FeatureSet {
* Excludes the defined {@link SchemaSupportFeature} from the set of supported features.
*
* @param schemaSupportFeature One or more {@code schemaSupportFeature} to ensure are excluded from the set.
*
* @return a reference to this Builder
*/
public Builder excludeSchemaSupportFeatures(SchemaSupportFeature... schemaSupportFeature) {
@ -539,7 +531,6 @@ public class FeatureSet {
* Includes the defined {@link ParameterFeature} to the new/existing set of supported features.
*
* @param parameterFeature One or more {@code parameterFeature} to ensure are included in the set.
*
* @return a reference to this Builder
*/
public Builder includeParameterFeatures(ParameterFeature... parameterFeature) {
@ -551,7 +542,6 @@ public class FeatureSet {
* Excludes the defined {@link ParameterFeature} from the set of supported features.
*
* @param parameterFeature One or more {@code parameterFeature} to ensure are excluded from the set.
*
* @return a reference to this Builder
*/
public Builder excludeParameterFeatures(ParameterFeature... parameterFeature) {
@ -578,7 +568,6 @@ public class FeatureSet {
* Includes the defined {@link SecurityFeature} to the new/existing set of supported features.
*
* @param securityFeature One or more {@code securityFeature} to ensure are included in the set.
*
* @return a reference to this Builder
*/
public Builder includeSecurityFeatures(SecurityFeature... securityFeature) {
@ -590,7 +579,6 @@ public class FeatureSet {
* Excludes the defined {@link SecurityFeature} from the set of supported features.
*
* @param securityFeature One or more {@code securityFeature} to ensure are excluded from the set.
*
* @return a reference to this Builder
*/
public Builder excludeSecurityFeatures(SecurityFeature... securityFeature) {
@ -617,7 +605,6 @@ public class FeatureSet {
* Includes the defined {@link GlobalFeature} to the new/existing set of supported features.
*
* @param globalFeature One or more {@code globalFeatures} to ensure are included in the set.
*
* @return a reference to this Builder
*/
public Builder includeGlobalFeatures(GlobalFeature... globalFeature) {
@ -629,7 +616,6 @@ public class FeatureSet {
* Excludes the defined {@link GlobalFeature} from the set of supported features.
*
* @param globalFeature One or more {@code globalFeatures} to ensure are excluded from the set.
*
* @return a reference to this Builder
*/
public Builder excludeGlobalFeatures(GlobalFeature... globalFeature) {
@ -656,7 +642,6 @@ public class FeatureSet {
* Includes the defined {@link WireFormatFeature} to the new/existing set of supported features.
*
* @param wireFormatFeature One or more {@code wireFormatFeatures} to ensure are included in the set.
*
* @return a reference to this Builder
*/
public Builder includeWireFormatFeatures(WireFormatFeature... wireFormatFeature) {
@ -672,7 +657,6 @@ public class FeatureSet {
* </p>
*
* @param wireFormatFeature One or more {@code wireFormatFeatures} to ensure are excluded from the set.
*
* @return a reference to this Builder
*/
public Builder excludeWireFormatFeatures(WireFormatFeature... wireFormatFeature) {

View File

@ -49,7 +49,9 @@ public enum Stability {
*
* @return The descriptive value of this enum.
*/
public String value() { return description; }
public String value() {
return description;
}
public static Stability forDescription(String description) {
for (Stability value : values()) {

View File

@ -23,7 +23,7 @@ import org.openapitools.codegen.meta.features.annotations.ToolingExtension;
/**
* Defines common data types supported by a generator.
* Some of these features are defined in specs, and some are specific to the tool.
*
* <p>
* Where data types are listed as tool-specific, this either indicates that the data type is common enough that it is an officially
* supported custom data type by the toolset (see {@link DataTypeFeature#Decimal}), or that the consideration of a special type isn't
* explicitly mentioned by the specification(s) but differs enough across languages that it warrants a special callout (see {@link DataTypeFeature#ArrayOfModel}).

View File

@ -53,7 +53,7 @@ public enum ParameterFeature {
/**
* Supports form encoded parameters.
*
* <p>
* OAS 3.x specification supports this structurally via content types rather than as an "in" parameter.
*/
@OAS2

View File

@ -54,11 +54,11 @@ public enum SchemaSupportFeature {
*
* <p>
* This means that a single "Type" in generated code may refer to one of any type in a set of 2 or more types.
*
* <p>
* This is defined as a union as "OneOf" support is not explicitly limited to physical boundaries in OpenAPI Specification. The
* implementation of such a type is easily represented dynamically (a JSON object), but requires explicit language support and
* potentially a custom implementation (typed instances).
*
* <p>
* Note that a generator may support "Unions" very loosely by returning an Object/Any/ref/interface{} type, leaving onus
* on type determination to the consumer. This does *NOT* suggest generated code implements a "Union Type".
* </p>

View File

@ -39,7 +39,6 @@ public class GenericValidator<TInput> implements Validator<TInput> {
* Validates input, resulting in a instance of {@link ValidationResult} which provides details on all validations performed (success, error, warning).
*
* @param input The object instance to be validated.
*
* @return A {@link ValidationResult} which details the success, error, and warning validation results.
*/
@Override

View File

@ -48,19 +48,18 @@ public abstract class Validated {
*
* @param rule The rule which was evaluated.
* @param message The message to display to a user.
*
* @return A {@link Validated} instance representing an invalid state according to the rule.
*/
public static Validated invalid(ValidationRule rule, String message) {
return new Invalid(rule, message);
}
/**
* Creates an instance of an {@link Invalid} validation state.
*
* @param rule The rule which was evaluated.
* @param message The message to display to a user.
* @param details Additional contextual details related to the invalid state.
*
* @return A {@link Validated} instance representing an invalid state according to the rule.
*/
public static Validated invalid(ValidationRule rule, String message, String details) {
@ -71,7 +70,6 @@ public abstract class Validated {
* Creates an instance of an {@link Valid} validation state.
*
* @param rule The rule which was evaluated.
*
* @return A {@link Validated} instance representing a valid state according to the rule.
*/
public static Validated valid(ValidationRule rule) {

View File

@ -57,7 +57,6 @@ public class ValidationRule {
* Evaluate an instance of an object against this rule.
*
* @param input The instance to be evaluated.
*
* @return <code>true</code> if the object state is valid according to this rule, otherwise <code>false</code>.
*/
public Result evaluate(Object input) {
@ -102,7 +101,6 @@ public class ValidationRule {
* @param fn The test condition to be applied as a part of this rule, when this function returns <code>true</code>,
* the evaluated instance will be considered "valid" according to this rule.
* @param <T> The type of the object being evaluated.
*
* @return A new instance of a {@link ValidationRule}
*/
@SuppressWarnings("unchecked")
@ -117,7 +115,6 @@ public class ValidationRule {
* @param fn The test condition to be applied as a part of this rule, when this function returns <code>true</code>,
* the evaluated instance will be considered "valid" according to this rule.
* @param <T> The type of the object being evaluated.
*
* @return A new instance of a {@link ValidationRule}
*/
@SuppressWarnings("unchecked")
@ -133,7 +130,6 @@ public class ValidationRule {
* @param fn The test condition to be applied as a part of this rule, when this function returns <code>true</code>,
* the evaluated instance will be considered "valid" according to this rule.
* @param <T> The type of the object being evaluated.
*
* @return A new instance of a {@link ValidationRule}
*/
@SuppressWarnings("unchecked")
@ -164,17 +160,24 @@ public class ValidationRule {
}
public abstract boolean passed();
public final boolean failed() { return !passed(); }
public final boolean failed() {
return !passed();
}
public Throwable getThrowable() {
return throwable;
}
public boolean thrown() { return this.throwable == null; }
public boolean thrown() {
return this.throwable == null;
}
}
public static final class Pass extends Result {
public static Result empty() { return new Pass(); }
public static Result empty() {
return new Pass();
}
public Pass() {
super();
@ -192,7 +195,9 @@ public class ValidationRule {
}
public static final class Fail extends Result {
public static Result empty() { return new Fail(); }
public static Result empty() {
return new Fail();
}
public Fail() {
super();

View File

@ -27,7 +27,6 @@ public interface Validator<TInput> {
* Validates input, resulting in a instance of {@link ValidationResult} which provides details on all validations performed (success, error, warning).
*
* @param input The object instance to be validated.
*
* @return A {@link ValidationResult} which details the success, error, and warning validation results.
*/
ValidationResult validate(TInput input);

View File

@ -120,6 +120,7 @@ public class WorkflowSettingsTest {
WorkflowSettings defaults = WorkflowSettings.newBuilder().build();
assertOnChangesToDefaults(defaults);
}
@Test
public void customOutputDirIsSet() {
WorkflowSettings settings = WorkflowSettings.newBuilder()

View File

@ -18,12 +18,13 @@ package org.openapitools.codegen.validation;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
public class GenericValidatorTest {
static class Person {
private int age;

View File

@ -18,7 +18,8 @@ package org.openapitools.codegen.validation;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
public class ValidatedTest {
@Test

View File

@ -18,7 +18,8 @@ package org.openapitools.codegen.validation;
import org.testng.annotations.Test;
import static org.testng.Assert.*;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
public class ValidationRuleTest {
static class Sample {

View File

@ -30,11 +30,13 @@ import lombok.Setter;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecution;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugins.annotations.*;
import org.apache.maven.plugins.annotations.Component;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.project.MavenProject;
import org.apache.maven.project.MavenProjectHelper;
import org.openapitools.codegen.*;
@ -49,7 +51,10 @@ import org.sonatype.plexus.build.incremental.DefaultBuildContext;
import java.io.File;
import java.io.IOException;
import java.net.*;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.text.MessageFormat;
@ -1014,6 +1019,7 @@ public class CodeGenMojo extends AbstractMojo {
/**
* Try to parse inputSpec setting string into URL
*
* @return A valid URL or null if inputSpec is not a valid URL
*/
private URL inputSpecRemoteUrl() {
@ -1026,6 +1032,7 @@ public class CodeGenMojo extends AbstractMojo {
/**
* Get specification hash file
*
* @param inputSpecFile - Openapi specification input file to calculate its hash.
* Does not take into account if input spec is hosted on remote resource
* @return a file with previously calculated hash

View File

@ -17,10 +17,9 @@
package org.openapitools.codegen.online.api;
import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
public class ApiOriginFilter implements javax.servlet.Filter {

View File

@ -42,8 +42,8 @@ public interface GenApiDelegate {
}
/**
* @see GenApi#clientOptions
* @return A {@link ResponseEntity} listing options for the target client generator.
* @see GenApi#clientOptions
*/
default ResponseEntity<List<String>> clientOptions() {
getRequest().ifPresent(request -> {
@ -60,8 +60,8 @@ public interface GenApiDelegate {
/**
* @param fileId The unique id of the file, provided in a {@link ResponseCode} response.
* @see GenApi#downloadFile
* @return A {@link ResponseEntity} of the requested {@link Resource}.
* @see GenApi#downloadFile
*/
default ResponseEntity<Resource> downloadFile(String fileId) {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
@ -71,8 +71,8 @@ public interface GenApiDelegate {
/**
* @param language The target generator (language is a misnomer here, but kept for API consistency).
* @param generatorInput The configuration settings to be used during client generation.
* @see GenApi#generateClient
* @return A {@link ResponseEntity} referencing the unique download id and a link to download the requested client code.
* @see GenApi#generateClient
*/
default ResponseEntity<ResponseCode> generateClient(String language,
GeneratorInput generatorInput) {
@ -91,8 +91,8 @@ public interface GenApiDelegate {
/**
* @param framework The target generator name (framework is a slight misnomer here, as we may have a framework like Spring implemented in multiple languages).
* @param generatorInput The configuration settings to be used during server generation.
* @see GenApi#generateServerForLanguage
* @return A {@link ResponseEntity} referencing the unique download id and a link to download the requested server code.
* @see GenApi#generateServerForLanguage
*/
default ResponseEntity<ResponseCode> generateServerForLanguage(String framework,
GeneratorInput generatorInput) {
@ -110,8 +110,8 @@ public interface GenApiDelegate {
/**
* @param language The target generator (language is a misnomer here, but kept for API consistency).
* @see GenApi#getClientOptions
* @return A {@link ResponseEntity} of {@link CliOption}, grouped by language (generator name).
* @see GenApi#getClientOptions
*/
default ResponseEntity<Map<String, CliOption>> getClientOptions(String language) {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
@ -120,8 +120,8 @@ public interface GenApiDelegate {
/**
* @param framework The target generator name (framework is a slight misnomer here, as we may have a framework like Spring implemented in multiple languages).
* @see GenApi#getServerOptions
* @return A {@link ResponseEntity} of {@link CliOption}, grouped by framework (generator name).
* @see GenApi#getServerOptions
*/
default ResponseEntity<Map<String, CliOption>> getServerOptions(String framework) {
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
@ -129,8 +129,8 @@ public interface GenApiDelegate {
}
/**
* @see GenApi#serverOptions
* @return A {@link ResponseEntity} listing options for the target server generator.
* @see GenApi#serverOptions
*/
default ResponseEntity<List<String>> serverOptions() {
getRequest().ifPresent(request -> {

View File

@ -18,6 +18,9 @@
package org.openapitools.codegen.online.configuration;
import com.fasterxml.jackson.databind.JsonNode;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;
@ -28,17 +31,14 @@ import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
import java.util.HashSet;
@Configuration

View File

@ -35,7 +35,8 @@ public class ApiResponse {
@Getter String type;
@Getter String message;
public ApiResponse() {}
public ApiResponse() {
}
public ApiResponse(int code, String message) {
this.code = code;

View File

@ -20,7 +20,8 @@ package org.openapitools.codegen.online.model;
import lombok.Getter;
import lombok.Setter;
@Getter @Setter
@Getter
@Setter
public class Generated {
private String filename;
private String friendlyName;

View File

@ -22,7 +22,9 @@ import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Setter @NoArgsConstructor @AllArgsConstructor
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class ResponseCode {
private String code;
private String link;

View File

@ -22,11 +22,7 @@ import io.swagger.parser.OpenAPIParser;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.parser.core.models.AuthorizationValue;
import io.swagger.v3.parser.core.models.ParseOptions;
import org.openapitools.codegen.CliOption;
import org.openapitools.codegen.ClientOptInput;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenConfigLoader;
import org.openapitools.codegen.DefaultGenerator;
import org.openapitools.codegen.*;
import org.openapitools.codegen.online.model.GeneratorInput;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -35,11 +31,7 @@ import org.springframework.web.server.ResponseStatusException;
import java.io.File;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.*;
public class Generator {
private static Logger LOGGER = LoggerFactory.getLogger(Generator.class);

View File

@ -17,12 +17,7 @@
package org.openapitools.codegen.online.service;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.*;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
@ -32,7 +27,6 @@ import java.util.zip.ZipOutputStream;
* sub files and sub directories, recursively.
*
* @author Ha Minh Nam
*
*/
public class ZipUtil {
/**

View File

@ -19,7 +19,6 @@ package org.openapitools.codegen;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.parser.core.models.AuthorizationValue;
import lombok.Getter;
import org.openapitools.codegen.api.TemplateDefinition;
import org.openapitools.codegen.auth.AuthParser;
@ -84,8 +83,8 @@ public class ClientOptInput {
/**
* Sets the generator/config instance
*
* @deprecated use {@link #config(CodegenConfig)} instead
* @param config codegen config
* @deprecated use {@link #config(CodegenConfig)} instead
*/
@Deprecated
public void setConfig(CodegenConfig config) {
@ -118,8 +117,8 @@ public class ClientOptInput {
/**
* Sets the OpenAPI document
*
* @deprecated use {@link #openAPI(OpenAPI)} instead
* @param openAPI the specification
* @deprecated use {@link #openAPI(OpenAPI)} instead
*/
@Deprecated
public void setOpenAPI(OpenAPI openAPI) {

View File

@ -38,6 +38,7 @@ public class CodegenCallback {
return Objects.equals(that.expression, expression) &&
Objects.equals(that.requests, requests) && Objects.equals(that.vendorExtensions, vendorExtensions);
}
@Override
public int hashCode() {
return Objects.hash(expression, requests, vendorExtensions);

View File

@ -19,9 +19,11 @@ package org.openapitools.codegen;
import lombok.Getter;
import lombok.Setter;
import java.util.*;
import java.util.List;
import java.util.Objects;
@Getter @Setter
@Getter
@Setter
public class CodegenComposedSchemas {
private List<CodegenProperty> allOf;
private List<CodegenProperty> oneOf;

View File

@ -8,7 +8,7 @@ import java.util.*;
/**
* This class encapsulates the OpenAPI discriminator construct, as specified at
* https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#discriminatorObject.
*
* <p>
* When request bodies or response payloads may be one of a number of different schemas,
* a discriminator object can be used to aid in serialization, deserialization, and validation.
* The discriminator is a specific object in a schema which is used to inform the consumer of
@ -61,7 +61,7 @@ public class CodegenDiscriminator {
/**
* An object to hold discriminator mappings between payload values and schema names or
* references.
*
* <p>
* In the OpenAPI document, the discriminator "mapping" attribute is optional.
* In scenarios where the value of the discriminator field does not match the schema name
* or implicit mapping is not possible, an optional mapping definition MAY be used.

View File

@ -8,7 +8,8 @@ import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
@Getter public class CodegenMediaType {
@Getter
public class CodegenMediaType {
private CodegenProperty schema;
private LinkedHashMap<String, CodegenEncoding> encoding;
private HashMap<String, SchemaTestCase> testCases = new HashMap<>();

View File

@ -19,13 +19,12 @@ package org.openapitools.codegen;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.v3.oas.models.ExternalDocumentation;
import java.util.*;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import java.util.*;
/**
* CodegenModel represents a schema object in a OpenAPI document.
*/
@ -174,7 +173,9 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
public boolean isArray;
public boolean hasChildren;
public boolean isMap;
/** datatype is the generic inner parameter of a std::optional for C++, or Optional (Java) */
/**
* datatype is the generic inner parameter of a std::optional for C++, or Optional (Java)
*/
public boolean isOptional;
public boolean isNull;
public boolean isVoid = false;
@ -208,7 +209,7 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
/**
* The type of the value for the additionalProperties keyword in the OAS document.
* Used in map like objects, including composed schemas.
*
* <p>
* In most programming languages, the additional (undeclared) properties are stored
* in a map data structure, such as HashMap in Java, map in golang, or a dict in Python.
* There are multiple ways to implement the additionalProperties keyword, depending
@ -218,24 +219,23 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
* In that case 'CodegenModel.parent' is set to represent the class hierarchy.
* Another way is to use CodegenModel.additionalPropertiesType. A code generator
* such as Python does not use class inheritance to model additional properties.
*
* <p>
* For example, in the OAS schema below, the schema has a declared 'id' property
* and additional, undeclared properties of type 'integer' are allowed.
*
* <p>
* type: object
* properties:
* id:
* type: integer
* additionalProperties:
* type: integer
*
*/
@Getter @Setter
public String additionalPropertiesType;
/**
* True if additionalProperties is set to true (boolean value), any type, free form object, etc
*
* <p>
* TODO: we may rename this to isAdditionalPropertiesEnabled or something
* else to avoid confusions
*/
@ -758,14 +758,22 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
}
@Override
public boolean getIsUuid() { return isUuid; }
public boolean getIsUuid() {
return isUuid;
}
@Override
public void setIsUuid(boolean isUuid) { this.isUuid = isUuid; }
public void setIsUuid(boolean isUuid) {
this.isUuid = isUuid;
}
public boolean getIsUri() { return isUri; }
public boolean getIsUri() {
return isUri;
}
public void setIsUri(boolean isUri) { this.isUri = isUri; }
public void setIsUri(boolean isUri) {
this.isUri = isUri;
}
@Override
public void setComposedSchemas(CodegenComposedSchemas composedSchemas) {
@ -833,7 +841,8 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
}
@Override
public void setIsBinary(boolean isBinary) {}
public void setIsBinary(boolean isBinary) {
}
@Override
public boolean getIsByteArray() {
@ -841,7 +850,8 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
}
@Override
public void setIsByteArray(boolean isByteArray) {}
public void setIsByteArray(boolean isByteArray) {
}
@Override
public boolean getIsDecimal() {
@ -1141,10 +1151,14 @@ public class CodegenModel implements IJsonSchemaValidationProperties {
}
@Override
public Map<String, CodegenProperty> getRequiredVarsMap() { return requiredVarsMap; }
public Map<String, CodegenProperty> getRequiredVarsMap() {
return requiredVarsMap;
}
@Override
public void setRequiredVarsMap(Map<String, CodegenProperty> requiredVarsMap) { this.requiredVarsMap=requiredVarsMap; }
public void setRequiredVarsMap(Map<String, CodegenProperty> requiredVarsMap) {
this.requiredVarsMap = requiredVarsMap;
}
/**
* Remove duplicated properties in all variable list

View File

@ -24,7 +24,8 @@ public final class CodegenModelFactory {
public static <T> T newInstance(CodegenModelType type) {
try {
return (T) type.getDefaultImplementation().getDeclaredConstructor().newInstance();
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException e) {
} catch (IllegalAccessException | InstantiationException | NoSuchMethodException |
InvocationTargetException e) {
throw new RuntimeException(e);
}
}

View File

@ -19,7 +19,8 @@ package org.openapitools.codegen;
import lombok.Getter;
@Getter public enum CodegenModelType {
@Getter
public enum CodegenModelType {
MODEL(CodegenModel.class),
OPERATION(CodegenOperation.class),

View File

@ -220,7 +220,9 @@ public class CodegenOperation {
*
* @return true if responses contain only 1 entry and it's a default response, false otherwise
*/
public boolean getHasOnlyDefaultResponse() { return responses.size() == 1 && getHasDefaultResponse(); }
public boolean getHasOnlyDefaultResponse() {
return responses.size() == 1 && getHasDefaultResponse();
}
public boolean getAllResponsesAreErrors() {
return responses.stream().allMatch(response -> response.is4xx || response.is5xx);

View File

@ -17,17 +17,12 @@
package org.openapitools.codegen;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import io.swagger.v3.oas.models.examples.Example;
import lombok.Getter;
import lombok.Setter;
import java.util.*;
/**
* Describes a single operation parameter in the OAS specification.
* A unique parameter is defined by a combination of a name and location.
@ -50,7 +45,9 @@ public class CodegenParameter implements IJsonSchemaValidationProperties {
public boolean isString, isNumeric, isInteger, isLong, isNumber, isFloat, isDouble, isDecimal, isByteArray, isBinary,
isBoolean, isDate, isDateTime, isUuid, isUri, isEmail, isPassword, isFreeFormObject, isAnyType, isShort, isUnboundedInteger;
public boolean isArray, isMap;
/** datatype is the generic inner parameter of a std::optional for C++, or Optional (Java) */
/**
* datatype is the generic inner parameter of a std::optional for C++, or Optional (Java)
*/
public boolean isOptional;
public boolean isFile;
public boolean isEnum;

View File

@ -20,12 +20,7 @@ package org.openapitools.codegen;
import lombok.Getter;
import lombok.Setter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperties {
/**
@ -178,7 +173,9 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
public boolean isAnyType;
public boolean isArray;
public boolean isMap;
/** datatype is the generic inner parameter of a std::optional for C++, or Optional (Java) */
/**
* datatype is the generic inner parameter of a std::optional for C++, or Optional (Java)
*/
public boolean isOptional;
public boolean isEnum; // true if the enum is defined inline
public boolean isInnerEnum; // Enums declared inline will be located inside the generic model, changing how the enum is referenced in some cases.
@ -243,7 +240,9 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
private boolean hasDiscriminatorWithNonEmptyMapping;
private CodegenComposedSchemas composedSchemas = null;
private boolean hasMultipleTypes = false;
/** true if the property's baseName != name, e.g. baseName = '_prop.value', name = 'propValue' after sanitization */
/**
* true if the property's baseName != name, e.g. baseName = '_prop.value', name = 'propValue' after sanitization
*/
private boolean hasSanitizedName = false;
private Map<String, CodegenProperty> requiredVarsMap;
private String ref;
@ -849,7 +848,9 @@ public class CodegenProperty implements Cloneable, IJsonSchemaValidationProperti
return hasSanitizedName;
}
public void setHasSanitizedName(boolean hasSanitizedName) { this.hasSanitizedName = hasSanitizedName; }
public void setHasSanitizedName(boolean hasSanitizedName) {
this.hasSanitizedName = hasSanitizedName;
}
@Override
public boolean getIsUuid() {

View File

@ -63,7 +63,9 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
public boolean simpleType;
public boolean primitiveType;
public boolean isMap;
/** datatype is the generic inner parameter of a std::optional for C++, or Optional (Java) */
/**
* datatype is the generic inner parameter of a std::optional for C++, or Optional (Java)
*/
public boolean isOptional;
public boolean isArray;
public boolean isBinary = false;
@ -212,7 +214,8 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
// use content.mediaType.schema.setContains instead of this
@Override
public void setContains(CodegenProperty contains) {}
public void setContains(CodegenProperty contains) {
}
// use content.mediaType.schema.getDependentRequired instead of this
@Override
@ -222,7 +225,8 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
// use content.mediaType.schema.setDependentRequired instead of this
@Override
public void setDependentRequired(LinkedHashMap<String, List<String>> dependentRequired) {}
public void setDependentRequired(LinkedHashMap<String, List<String>> dependentRequired) {
}
// use content.mediaType.schema.getIsBooleanSchemaTrue instead of this
@Override
@ -232,7 +236,8 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
// use content.mediaType.schema.setIsBooleanSchemaTrue instead of this
@Override
public void setIsBooleanSchemaTrue(boolean isBooleanSchemaTrue) {}
public void setIsBooleanSchemaTrue(boolean isBooleanSchemaTrue) {
}
// use content.mediaType.schema.getIsBooleanSchemaFalse instead of this
@Override
@ -242,7 +247,8 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
// use content.mediaType.schema.setIsBooleanSchemaFalse instead of this
@Override
public void setIsBooleanSchemaFalse(boolean isBooleanSchemaFalse) {}
public void setIsBooleanSchemaFalse(boolean isBooleanSchemaFalse) {
}
// use content.mediaType.schema.getFormat instead of this
@Override
@ -252,7 +258,8 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
// use content.mediaType.schema.setFormat instead of this
@Override
public void setFormat(String format) {}
public void setFormat(String format) {
}
@Override
public String getPattern() {
@ -782,16 +789,24 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
}
@Override
public Map<String, CodegenProperty> getRequiredVarsMap() { return requiredVarsMap; }
public Map<String, CodegenProperty> getRequiredVarsMap() {
return requiredVarsMap;
}
@Override
public void setRequiredVarsMap(Map<String, CodegenProperty> requiredVarsMap) { this.requiredVarsMap=requiredVarsMap; }
public void setRequiredVarsMap(Map<String, CodegenProperty> requiredVarsMap) {
this.requiredVarsMap = requiredVarsMap;
}
@Override
public String getRef() { return ref; }
public String getRef() {
return ref;
}
@Override
public void setRef(String ref) { this.ref=ref; }
public void setRef(String ref) {
this.ref = ref;
}
@Override
public boolean getSchemaIsFromAdditionalProperties() {
@ -889,5 +904,6 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
}
@Override
public void setIsEnum(boolean isEnum) {}
public void setIsEnum(boolean isEnum) {
}
}

View File

@ -17,11 +17,7 @@
package org.openapitools.codegen;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
public class CodegenSecurity {

View File

@ -70,10 +70,10 @@ import org.openapitools.codegen.utils.OneOfImplementorAdditionalData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.Map.Entry;
@ -350,7 +350,6 @@ public class DefaultCodegen implements CodegenConfig {
* first from additionalProperties
* then from the getter in this instance
* then from the fields in this instance
*
*/
protected void useCodegenAsMustacheParentContext() {
additionalProperties.put(CodegenConstants.MUSTACHE_PARENT_CONTEXT, this);
@ -546,6 +545,7 @@ public class DefaultCodegen implements CodegenConfig {
* This usually occurs when the data type is different.
* We can also consider discriminators as new because the derived class discriminator will have to be defined again
* to contain a new value. Doing so prevents having to include the discriminator in the constructor.
*
* @param model
* @param property
* @return
@ -1133,6 +1133,7 @@ public class DefaultCodegen implements CodegenConfig {
/**
* This method escapes text to be used in a single quoted string
*
* @param input the input string
* @return the escaped string
*/
@ -8391,6 +8392,7 @@ public class DefaultCodegen implements CodegenConfig {
public void addImportsToOneOfInterface(List<Map<String, String>> imports) {
}
/// / End of methods related to the "useOneOfInterfaces" feature
protected void modifyFeatureSet(Consumer<FeatureSet.Builder> processor) {
@ -8403,7 +8405,8 @@ public class DefaultCodegen implements CodegenConfig {
/**
* An map entry for cached sanitized names.
*/
@Getter private static class SanitizeNameOptions {
@Getter
private static class SanitizeNameOptions {
public SanitizeNameOptions(String name, String removeCharRegEx, List<String> exceptions) {
this.name = name;
this.removeCharRegEx = removeCharRegEx;

View File

@ -18,11 +18,7 @@
package org.openapitools.codegen;
import io.swagger.v3.core.util.Json;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.PathItem;
import io.swagger.v3.oas.models.Paths;
import io.swagger.v3.oas.models.SpecVersion;
import io.swagger.v3.oas.models.*;
import io.swagger.v3.oas.models.info.Contact;
import io.swagger.v3.oas.models.info.Info;
import io.swagger.v3.oas.models.info.License;
@ -35,12 +31,8 @@ import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOCase;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.api.TemplateDefinition;
import org.openapitools.codegen.api.TemplatePathLocator;
import org.openapitools.codegen.api.TemplateProcessor;
import org.openapitools.codegen.api.*;
import org.openapitools.codegen.config.GlobalSettings;
import org.openapitools.codegen.api.TemplatingEngineAdapter;
import org.openapitools.codegen.api.TemplateFileType;
import org.openapitools.codegen.ignore.CodegenIgnoreProcessor;
import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability;
@ -50,15 +42,13 @@ import org.openapitools.codegen.templating.CommonTemplateContentLocator;
import org.openapitools.codegen.templating.GeneratorTemplateContentLocator;
import org.openapitools.codegen.templating.MustacheEngineAdapter;
import org.openapitools.codegen.templating.TemplateManagerOptions;
import org.openapitools.codegen.utils.ImplementationVersion;
import org.openapitools.codegen.utils.ModelUtils;
import org.openapitools.codegen.utils.ProcessUtils;
import org.openapitools.codegen.utils.URLPathUtils;
import org.openapitools.codegen.utils.SemVer;
import org.openapitools.codegen.utils.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.io.File;
import java.io.IOException;
import java.io.Writer;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;

View File

@ -9,7 +9,8 @@ import java.util.Locale;
/**
* Holds details about a file's write status for display via the --dry-run option of CLI
*/
@Getter class DryRunStatus {
@Getter
class DryRunStatus {
/**
* -- GETTER --
* Gets the target path of the file write operation
@ -110,7 +111,8 @@ import java.util.Locale;
/**
* Represents the possible states of a file write operation as determined by the Generator
*/
@Getter enum State {
@Getter
enum State {
Write("w", "Write"),
WriteIfNewer("n", "Write if New/Updated"),
Ignored("i", "Ignored"),

View File

@ -122,6 +122,7 @@ public class DryRunTemplateManager implements TemplateProcessor {
* been enabled via {@link #enableTemplateDataCapturing()} prior to generation.<br>
* Note: Not all files have template data (e.g. Metadata files) in such case an empty
* map is returned.
*
* @param generatedFile An absolute path to the generated file
* @return Typically one of the *Map types found in {@link org.openapitools.codegen.model}
*/

View File

@ -1,20 +1,13 @@
package org.openapitools.codegen;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Stream;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.meta.FeatureSet;
import org.openapitools.codegen.meta.features.SchemaSupportFeature;
import org.openapitools.codegen.utils.ModelUtils;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.media.Schema;
import java.util.*;
import java.util.stream.Stream;
public interface IJsonSchemaValidationProperties {
CodegenProperty getContains();
@ -116,6 +109,7 @@ public interface IJsonSchemaValidationProperties {
* but using #isModel alone without #isOptional in mustache might produce <code>const org::openapitools::server::model::std::optional&lt;org::openapitools::server::model::GetAccountVideos_categoryOneOf_parameter&gt; &amp;categoryOneOf</code> instead, that do not compile.
*/
boolean getIsOptional();
void setIsOptional(boolean isOptional);
boolean getIsArray();

View File

@ -22,8 +22,6 @@ import com.fasterxml.jackson.core.util.DefaultPrettyPrinter;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.v3.core.util.Json;
import io.swagger.v3.oas.annotations.Webhook;
import io.swagger.v3.oas.annotations.Webhooks;
import io.swagger.v3.oas.models.*;
import io.swagger.v3.oas.models.PathItem.HttpMethod;
import io.swagger.v3.oas.models.callbacks.Callback;
@ -37,7 +35,6 @@ import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.nio.file.Path;
import java.util.*;
public class InlineModelResolver {

View File

@ -20,6 +20,7 @@ public class ObjectWithTypeBooleans {
* Other booleans: isUnboundedInteger/isNumber/isString/isMap/isArray/isBoolean/isNull
* allow generator templates to decide how to render each payload into code
* based upon what type it is. The booleans isX describe the value in value.
*
* @param value the input payload that is stored
*/
public ObjectWithTypeBooleans(Object value) {

View File

@ -35,7 +35,6 @@ import java.util.*;
import java.util.stream.Collectors;
import static org.openapitools.codegen.utils.StringUtils.getUniqueString;
import static org.openapitools.codegen.utils.StringUtils.underscore;
public class OpenAPINormalizer {
private OpenAPI openAPI;
@ -1013,7 +1012,6 @@ public class OpenAPINormalizer {
}
/**
* If the schema contains anyOf/oneOf and properties, remove oneOf/anyOf as these serve as rules to
* ensure inter-dependency between properties. It's a workaround as such validation is not supported at the moment.

View File

@ -6,7 +6,8 @@ import lombok.Setter;
import java.util.Optional;
import java.util.Set;
@Getter @Setter
@Getter
@Setter
public class SpecValidationException extends RuntimeException {
private Set<String> errors;

View File

@ -27,11 +27,12 @@ import java.util.StringJoiner;
/**
* Defines the template definition for a "supporting file", that is any file which is generic and not bound to
* api/model definitions and their relevant docs or tests.
*
* <p>
* Supporting files are generated once for an entire application while api/model bound definitions are generated multiple
* times according to their target use.
*/
@Getter public class SupportingFile extends TemplateDefinition {
@Getter
public class SupportingFile extends TemplateDefinition {
private boolean canOverwrite = true;
public SupportingFile(String templateFile, String destinationFilename) {

View File

@ -13,8 +13,14 @@ import org.slf4j.LoggerFactory;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.*;
import java.util.*;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.Arrays;
import java.util.Map;
import java.util.Objects;
import java.util.Scanner;
import java.util.regex.Pattern;
/**
@ -87,7 +93,6 @@ public class TemplateManager implements TemplatingExecutor, TemplateProcessor {
* Gets a normalized classpath resource location according to OS-specific file separator
*
* @param name The name of the resource file/directory to find
*
* @return A normalized string according to OS-specific file separator
*/
public static String getCPResourcePath(final String name) {
@ -153,7 +158,6 @@ public class TemplateManager implements TemplatingExecutor, TemplateProcessor {
* @param data Input data
* @param template Input template location
* @param target The targeted file output location
*
* @return The actual file
*/
@Override

View File

@ -6,7 +6,8 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.List;
@Getter public enum VendorExtension {
@Getter
public enum VendorExtension {
X_IMPLEMENTS("x-implements", ExtensionLevel.MODEL, "Ability to specify interfaces that model must implements", "empty array"),
X_SPRING_PAGINATED("x-spring-paginated", ExtensionLevel.OPERATION, "Add org.springframework.data.domain.Pageable to controller method. Can be used to handle page & size query parameters", "false"),

View File

@ -48,7 +48,7 @@ import static org.apache.commons.lang3.StringUtils.isNotEmpty;
/**
* A class which manages the contextual configuration for code generation.
* This includes configuring the generator, templating, and the workflow which orchestrates these.
*
* <p>
* This helper also enables the deserialization of {@link GeneratorSettings} via application-specific Jackson JSON usage
* (see {@link DynamicSettings}.
*/

View File

@ -96,7 +96,8 @@ public class DynamicSettings {
* <p>Constructor for DynamicSettings.</p>
*/
@JsonCreator
public DynamicSettings() { }
public DynamicSettings() {
}
private void excludeSettingsFromDynamicProperties() {
Set<String> fieldNames = new HashSet<>();

View File

@ -27,7 +27,7 @@ import java.util.Properties;
* GlobalSettings encapsulates SystemProperties, since the codegen mechanism heavily relies on a stable,
* non-changing System Property Basis. Using plain System.(get|set|clear)Property raises Race-Conditions in combination
* with Code, that uses System.setProperties (e.g. maven-surefire-plugin).
*
* <p>
* This provides a set of properties specific to the executing thread, such that the generator may not modify system properties
* consumed by other threads.
*

View File

@ -1,32 +1,24 @@
package org.openapitools.codegen.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.google.common.collect.ImmutableMap;
import io.swagger.parser.OpenAPIParser;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.parser.core.models.ParseOptions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import com.google.common.collect.ImmutableMap;
import io.swagger.parser.OpenAPIParser;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.parser.core.models.ParseOptions;
public class MergedSpecBuilder {
private static final Logger LOGGER = LoggerFactory.getLogger(MergedSpecBuilder.class);
@ -134,10 +126,12 @@ public class MergedSpecBuilder {
private void deleteMergedFileFromPreviousRun() {
try {
Files.deleteIfExists(Paths.get(inputSpecRootDirectory + File.separator + mergeFileName + ".json"));
} catch (IOException e) { }
} catch (IOException e) {
}
try {
Files.deleteIfExists(Paths.get(inputSpecRootDirectory + File.separator + mergeFileName + ".yaml"));
} catch (IOException e) { }
} catch (IOException e) {
}
}
private static class SpecWithPaths {

View File

@ -398,6 +398,7 @@ public class ExampleGenerator {
/**
* Transverse and resolves all property examples for `allOf` composed schemas into `values` map object
*
* @param mediaType MIME type
* @param schema OAS schema
* @param processedModels Set containing all processed models

View File

@ -172,7 +172,7 @@ public class XmlExampleGenerator {
/**
* Get the example string value for the given schema.
*
* <p>
* If an example value was not provided in the specification, a default will be generated.
*
* @param schema Schema to get example string for

View File

@ -25,7 +25,10 @@ import org.slf4j.LoggerFactory;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
@ -216,7 +219,7 @@ public class CodegenIgnoreProcessor {
/**
* Allows a consumer to manually inspect all "exclusion rules". That is, patterns in the ignore file which represent
* files and directories to be excluded, unless explicitly overridden by {@link CodegenIgnoreProcessor#getInclusionRules()} rules.
*
* <p>
* NOTE: Existence in this list doesn't mean a file is excluded. The rule can be overridden by {@link CodegenIgnoreProcessor#getInclusionRules()} rules.
*
* @return A {@link Collections#unmodifiableList(List)} of rules which define exclusions by patterns in the ignore file.

View File

@ -33,5 +33,7 @@ public class EverythingRule extends Rule {
}
@Override
protected Operation getExcludeOperation(){ return Operation.EXCLUDE_AND_TERMINATE; }
protected Operation getExcludeOperation() {
return Operation.EXCLUDE_AND_TERMINATE;
}
}

View File

@ -23,7 +23,8 @@ import java.util.ArrayList;
import java.util.List;
public class IgnoreLineParser {
@Getter enum Token {
@Getter
enum Token {
MATCH_ALL("**"),
MATCH_ANY("*"),
ESCAPED_EXCLAMATION("\\!"),

View File

@ -21,7 +21,8 @@ import lombok.Getter;
import java.util.List;
@Getter public class InvalidRule extends Rule {
@Getter
public class InvalidRule extends Rule {
private final String reason;
InvalidRule(List<Part> syntax, String definition, String reason) {

View File

@ -19,7 +19,8 @@ package org.openapitools.codegen.ignore.rules;
import lombok.Getter;
@Getter class Part {
@Getter
class Part {
private final IgnoreLineParser.Token token;
private final String value;

View File

@ -83,8 +83,13 @@ public abstract class Rule {
return Operation.NOOP;
}
protected Operation getIncludeOperation(){ return Operation.INCLUDE; }
protected Operation getExcludeOperation(){ return Operation.EXCLUDE; }
protected Operation getIncludeOperation() {
return Operation.INCLUDE;
}
protected Operation getExcludeOperation() {
return Operation.EXCLUDE;
}
public static Rule create(String definition) {
// NOTE: Comments that start with a : (e.g. //:) are pulled from git documentation for .gitignore

View File

@ -27,12 +27,7 @@ import io.swagger.v3.oas.models.servers.Server;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.ClientModificationFeature;
import org.openapitools.codegen.meta.features.DocumentationFeature;
import org.openapitools.codegen.meta.features.GlobalFeature;
import org.openapitools.codegen.meta.features.SchemaSupportFeature;
import org.openapitools.codegen.meta.features.SecurityFeature;
import org.openapitools.codegen.meta.features.WireFormatFeature;
import org.openapitools.codegen.meta.features.*;
import org.openapitools.codegen.model.ModelMap;
import org.openapitools.codegen.model.ModelsMap;
import org.openapitools.codegen.model.OperationMap;

View File

@ -18,10 +18,9 @@
package org.openapitools.codegen.languages;
import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache.Lambda;
import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Mustache.Lambda;
import com.samskivert.mustache.Template;
import io.swagger.v3.oas.models.media.Schema;
import lombok.Getter;
import lombok.Setter;
@ -504,7 +503,9 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen {
}
}
/** If the value can be parsed as a double, returns the value, otherwise returns null */
/**
* If the value can be parsed as a double, returns the value, otherwise returns null
*/
public static Double asDouble(String strNum) {
if (strNum == null) {
return null;
@ -516,7 +517,9 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen {
}
}
/** If the value can be parsed as an integer, returns the value, otherwise returns null */
/**
* If the value can be parsed as an integer, returns the value, otherwise returns null
*/
public static Integer asInteger(String strNum) {
if (strNum == null) {
return null;
@ -835,6 +838,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen {
httpStatusesWithReturn.add(status);
}
}
private HashMap<String, String> duplicateOf = new HashMap<String, String>();
@Override
@ -1707,8 +1711,7 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen {
* @param name The original name
* @return The adjusted name
*/
private String adjustNamingStyle(String name)
{
private String adjustNamingStyle(String name) {
switch (getEnumPropertyNaming()) {
case camelCase:
// NOTE: Removes hyphens and underscores
@ -1765,7 +1768,9 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen {
return (this.getValueTypes().contains(var.dataType) || var.isEnum);
}
protected boolean useNet60OrLater() { return false; }
protected boolean useNet60OrLater() {
return false;
}
protected boolean useDateOnly() {
return useNet60OrLater() && !useDateTimeForDateFlag;

View File

@ -19,15 +19,14 @@ package org.openapitools.codegen.languages;
import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache.Lambda;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.servers.Server;
import io.swagger.v3.oas.models.servers.ServerVariables;
import io.swagger.v3.oas.models.servers.ServerVariable;
import org.openapitools.codegen.*;
import io.swagger.v3.oas.models.servers.ServerVariables;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.model.ModelMap;
import org.openapitools.codegen.model.ModelsMap;
import org.openapitools.codegen.templating.mustache.IndentedLambda;
@ -38,11 +37,7 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.*;
abstract public class AbstractCppCodegen extends DefaultCodegen implements CodegenConfig {
private final Logger LOGGER = LoggerFactory.getLogger(AbstractCppCodegen.class);

View File

@ -632,5 +632,7 @@ public abstract class AbstractEiffelCodegen extends DefaultCodegen implements Co
}
@Override
public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.EIFFEL; }
public GeneratorLanguage generatorLanguage() {
return GeneratorLanguage.EIFFEL;
}
}

View File

@ -18,7 +18,6 @@ package org.openapitools.codegen.languages;
import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache.Lambda;
import io.swagger.v3.core.util.Json;
import io.swagger.v3.oas.models.media.Schema;
import lombok.Getter;
@ -30,7 +29,7 @@ import org.openapitools.codegen.model.ModelMap;
import org.openapitools.codegen.model.ModelsMap;
import org.openapitools.codegen.model.OperationMap;
import org.openapitools.codegen.model.OperationsMap;
import org.openapitools.codegen.templating.mustache.*;
import org.openapitools.codegen.templating.mustache.CamelCaseAndSanitizeLambda;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -26,7 +26,10 @@ import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.PathItem;
import io.swagger.v3.oas.models.examples.Example;
import io.swagger.v3.oas.models.media.*;
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.Parameter;
import io.swagger.v3.oas.models.parameters.RequestBody;
import io.swagger.v3.oas.models.servers.Server;
@ -144,7 +147,8 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
@Getter @Setter
protected String testFolder = projectTestFolder + "/java";
protected static enum ENUM_PROPERTY_NAMING_TYPE {MACRO_CASE, legacy};
protected enum ENUM_PROPERTY_NAMING_TYPE {MACRO_CASE, legacy}
protected static final String ENUM_PROPERTY_NAMING_DESC = "Naming convention for enum properties: 'MACRO_CASE' and 'legacy'";
@Getter protected ENUM_PROPERTY_NAMING_TYPE enumPropertyNaming = ENUM_PROPERTY_NAMING_TYPE.MACRO_CASE;
@ -667,6 +671,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
/**
* Analyse and post process all Models.
*
* @param objs the models map.
* @return the processed models map.
**/
@ -1734,8 +1739,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
composedSchemas.getOneOf(),
composedSchemas.getAllOf());
for (final List<CodegenProperty> propertyList : propertyLists) {
if(propertyList == null)
{
if (propertyList == null) {
continue;
}
for (CodegenProperty cp : propertyList) {
@ -1820,7 +1824,7 @@ public abstract class AbstractJavaCodegen extends DefaultCodegen implements Code
/**
* Remove annotations from the given data type string.
*
* <p>
* For example:
* <ul>
* <li>{@code @Min(0) @Max(10)Integer} -> {@code Integer}</li>

View File

@ -50,6 +50,7 @@ public abstract class AbstractJavaJAXRSServerCodegen extends AbstractJavaCodegen
protected static final String X_MICROPROFILE_OPEN_API_SCHEMA_TYPE = "x-microprofile-open-api-schema-type";
protected static final String SCHEMA_TYPE_ARRAY = "org.eclipse.microprofile.openapi.annotations.enums.SchemaType.ARRAY";
protected static final Map<String, String> ARRAY_OF_MICROPROFILE_OPEN_API_SCHEMA_TYPES;
static {
final Map<String, String> schemaTypes = new HashMap<>();
schemaTypes.put("integer", "org.eclipse.microprofile.openapi.annotations.enums.SchemaType.INTEGER");

View File

@ -16,16 +16,24 @@
package org.openapitools.codegen.languages;
import com.google.common.base.CaseFormat;
import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache.Lambda;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.servers.Server;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.ClientModificationFeature;
import org.openapitools.codegen.meta.features.DocumentationFeature;
import org.openapitools.codegen.meta.features.GlobalFeature;
import org.openapitools.codegen.meta.features.ParameterFeature;
import org.openapitools.codegen.meta.features.SchemaSupportFeature;
import org.openapitools.codegen.meta.features.SecurityFeature;
import org.openapitools.codegen.meta.features.WireFormatFeature;
import org.openapitools.codegen.meta.features.*;
import org.openapitools.codegen.model.ModelsMap;
import org.openapitools.codegen.templating.mustache.EscapeChar;
import org.openapitools.codegen.utils.CamelizeOption;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.text.SimpleDateFormat;
@ -33,27 +41,8 @@ import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.servers.Server;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import org.openapitools.codegen.utils.CamelizeOption;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.common.base.CaseFormat;
import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache.Lambda;
import org.openapitools.codegen.templating.mustache.EscapeChar;
public abstract class AbstractJuliaCodegen extends DefaultCodegen {
protected final Logger LOGGER = LoggerFactory.getLogger(AbstractJuliaCodegen.class);

View File

@ -1012,18 +1012,15 @@ public abstract class AbstractKotlinCodegen extends DefaultCodegen implements Co
if (schema.getDefault() != null) {
return fixNumberValue(schema.getDefault().toString(), schema);
}
}
else if (ModelUtils.isIntegerSchema(schema)) {
} else if (ModelUtils.isIntegerSchema(schema)) {
if (schema.getDefault() != null) {
return fixNumberValue(schema.getDefault().toString(), schema);
}
}
else if (ModelUtils.isURISchema(schema)) {
} else if (ModelUtils.isURISchema(schema)) {
if (schema.getDefault() != null) {
return importMapping.get("URI") + ".create(\"" + schema.getDefault() + "\")";
}
}
else if (ModelUtils.isArraySchema(schema)) {
} else if (ModelUtils.isArraySchema(schema)) {
return toArrayDefaultValue(cp, schema);
} else if (ModelUtils.isStringSchema(schema)) {
if (schema.getDefault() != null) {

View File

@ -34,8 +34,8 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.CamelizeOption.UPPERCASE_FIRST_CHAR;

View File

@ -16,44 +16,14 @@
package org.openapitools.codegen.languages;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.escape;
import static org.openapitools.codegen.utils.StringUtils.underscore;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.TreeSet;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.annotation.Nullable;
import com.github.curiousoddman.rgxgen.RgxGen;
import io.swagger.v3.oas.models.examples.Example;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.Parameter;
import lombok.Setter;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenMediaType;
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.DefaultCodegen;
import org.openapitools.codegen.GeneratorLanguage;
import org.openapitools.codegen.IJsonSchemaValidationProperties;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.SecurityFeature;
import org.openapitools.codegen.model.ModelMap;
import org.openapitools.codegen.model.ModelsMap;
@ -63,14 +33,14 @@ import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.curiousoddman.rgxgen.RgxGen;
import io.swagger.v3.oas.models.examples.Example;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.Parameter;
import javax.annotation.Nullable;
import java.io.File;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static org.openapitools.codegen.utils.StringUtils.*;
public abstract class AbstractPythonCodegen extends DefaultCodegen implements CodegenConfig {

View File

@ -16,30 +16,6 @@
package org.openapitools.codegen.languages;
import java.io.File;
import java.io.IOException;
import java.util.*;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.CliOption;
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.SupportingFile;
import org.openapitools.codegen.meta.features.DocumentationFeature;
import org.openapitools.codegen.model.ApiInfoMap;
import org.openapitools.codegen.model.ModelMap;
import org.openapitools.codegen.model.ModelsMap;
import org.openapitools.codegen.model.OperationMap;
import org.openapitools.codegen.model.OperationsMap;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonSerializer;
@ -49,7 +25,6 @@ import com.fasterxml.jackson.databind.module.SimpleModule;
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
@ -59,8 +34,19 @@ import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.parameters.RequestBody;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.DocumentationFeature;
import org.openapitools.codegen.model.*;
import org.openapitools.codegen.utils.ModelUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.openapitools.codegen.utils.StringUtils.*;
import java.io.File;
import java.io.IOException;
import java.util.*;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public abstract class AbstractPythonConnexionServerCodegen extends AbstractPythonCodegen implements CodegenConfig {
private static class PythonBooleanSerializer extends JsonSerializer<Boolean> {

View File

@ -22,7 +22,6 @@ import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.media.StringSchema;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.io.FilenameUtils;

View File

@ -25,7 +25,9 @@ import org.openapitools.codegen.model.OperationsMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.*;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
public class Apache2ConfigCodegen extends DefaultCodegen implements CodegenConfig {

View File

@ -16,11 +16,16 @@
package org.openapitools.codegen.languages;
import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.media.Schema;
import lombok.Getter;
import lombok.Setter;
import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;
@ -32,15 +37,6 @@ import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import org.openapitools.codegen.meta.features.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.samskivert.mustache.Mustache;
import com.samskivert.mustache.Template;
import io.swagger.v3.oas.models.OpenAPI;
/**
* basic asciidoc markup generator.
*

View File

@ -21,7 +21,6 @@ import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.parser.util.SchemaTypeUtil;
import lombok.Getter;
import lombok.Setter;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.*;

View File

@ -1,13 +1,15 @@
package org.openapitools.codegen.languages;
import org.openapitools.codegen.*;
import java.io.File;
import java.util.*;
import org.openapitools.codegen.CodegenConfig;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.Locale;
import static java.util.UUID.randomUUID;
public class AspnetFastendpointsServerCodegen extends AbstractCSharpCodegen implements CodegenConfig {

View File

@ -16,32 +16,23 @@
package org.openapitools.codegen.languages;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.GeneratorMetadata;
import org.openapitools.codegen.meta.Stability;
import org.openapitools.codegen.meta.features.*;
import org.openapitools.codegen.model.ModelsMap;
import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.Getter;
import lombok.Setter;
import java.io.File;
import java.util.*;
import java.util.stream.Collectors;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class AvroSchemaCodegen extends DefaultCodegen implements CodegenConfig {
private final Logger LOGGER = LoggerFactory.getLogger(AvroSchemaCodegen.class);

View File

@ -26,8 +26,8 @@ import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.parameters.Parameter;
import io.swagger.v3.oas.models.servers.Server;
import lombok.Setter;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.*;
import org.openapitools.codegen.utils.ModelUtils;
@ -37,7 +37,8 @@ import org.slf4j.LoggerFactory;
import java.util.*;
import static org.openapitools.codegen.utils.CamelizeOption.LOWERCASE_FIRST_LETTER;
import static org.openapitools.codegen.utils.StringUtils.*;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
private final Logger LOGGER = LoggerFactory.getLogger(BashClientCodegen.class);
@ -795,5 +796,7 @@ public class BashClientCodegen extends DefaultCodegen implements CodegenConfig {
}
@Override
public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.BASH; }
public GeneratorLanguage generatorLanguage() {
return GeneratorLanguage.BASH;
}
}

View File

@ -18,8 +18,8 @@ package org.openapitools.codegen.languages;
import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.oas.models.servers.Server;
import lombok.Getter;
import lombok.Setter;
@ -128,6 +128,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
ALPHABETICAL,
LEGACY
}
private SortingMethod operationParameterSorting = SortingMethod.DEFAULT;
private SortingMethod modelPropertySorting = SortingMethod.DEFAULT;
@ -504,8 +505,7 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
Collections.sort(codegenModel.readOnlyVars, propertyComparatorByNotNullableRequiredNoDefaultLegacy);
Collections.sort(codegenModel.readWriteVars, propertyComparatorByNotNullableRequiredNoDefaultLegacy);
Collections.sort(codegenModel.parentVars, propertyComparatorByNotNullableRequiredNoDefaultLegacy);
}
else {
} else {
Collections.sort(codegenModel.vars, propertyComparatorByNotNullableRequiredNoDefault);
Collections.sort(codegenModel.allVars, propertyComparatorByNotNullableRequiredNoDefault);
Collections.sort(codegenModel.requiredVars, propertyComparatorByNotNullableRequiredNoDefault);

View File

@ -635,7 +635,8 @@ public class CSharpReducedClientCodegen extends AbstractCSharpCodegen {
final AtomicReference<Boolean> excludeTests = new AtomicReference<>();
syncBooleanProperty(additionalProperties, CodegenConstants.EXCLUDE_TESTS, excludeTests::set, false);
syncStringProperty(additionalProperties, "clientPackage", (s) -> {}, clientPackage);
syncStringProperty(additionalProperties, "clientPackage", (s) -> {
}, clientPackage);
syncStringProperty(additionalProperties, CodegenConstants.API_PACKAGE, this::setApiPackage, apiPackage);
syncStringProperty(additionalProperties, CodegenConstants.MODEL_PACKAGE, this::setModelPackage, modelPackage);

View File

@ -24,7 +24,10 @@ import io.swagger.v3.oas.models.info.License;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.*;
import org.openapitools.codegen.meta.features.DocumentationFeature;
import org.openapitools.codegen.meta.features.ParameterFeature;
import org.openapitools.codegen.meta.features.SchemaSupportFeature;
import org.openapitools.codegen.meta.features.SecurityFeature;
import org.openapitools.codegen.model.ModelMap;
import org.openapitools.codegen.model.OperationMap;
import org.openapitools.codegen.model.OperationsMap;
@ -400,5 +403,7 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi
}
@Override
public GeneratorLanguage generatorLanguage() { return GeneratorLanguage.CLOJURE; }
public GeneratorLanguage generatorLanguage() {
return GeneratorLanguage.CLOJURE;
}
}

View File

@ -18,6 +18,7 @@
package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.lang3.StringUtils;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.*;
import org.openapitools.codegen.model.ModelMap;
@ -25,7 +26,6 @@ import org.openapitools.codegen.model.ModelsMap;
import org.openapitools.codegen.model.OperationMap;
import org.openapitools.codegen.model.OperationsMap;
import org.openapitools.codegen.utils.ModelUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.*;
@ -158,5 +158,7 @@ public class ConfluenceWikiCodegen extends DefaultCodegen implements CodegenConf
}
@Override
public GeneratorLanguage generatorLanguage() { return null; }
public GeneratorLanguage generatorLanguage() {
return null;
}
}

View File

@ -52,28 +52,44 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
protected final String PREFIX = "";
protected String helpersPackage = "";
/** OpenApi types that shouldn't have a namespace added with getTypeDeclaration() at generation time (for nlohmann::json) */
/**
* OpenApi types that shouldn't have a namespace added with getTypeDeclaration() at generation time (for nlohmann::json)
*/
private final Set<String> openAPITypesWithoutModelNamespace = new HashSet<>();
/** int32_t (for integer) */
/**
* int32_t (for integer)
*/
private static final String INT32_T = "int32_t";
/** int64_t (for long) */
/**
* int64_t (for long)
*/
private static final String INT64_T = "int64_t";
/** nlohmann::json (for object, AnyType) */
/**
* nlohmann::json (for object, AnyType)
*/
private static final String NLOHMANN_JSON = "nlohmann::json";
/** std:string (for date, DateTime, string, file, binary, UUID, URI, ByteArray) */
/**
* std:string (for date, DateTime, string, file, binary, UUID, URI, ByteArray)
*/
private static final String STD_STRING = "std::string";
/** std:map (for map) */
/**
* std:map (for map)
*/
private static final String STD_MAP = "std::map";
/** std:set (for set) */
/**
* std:set (for set)
*/
private static final String STD_SET = "std::set";
/** std:vector (for array) */
/**
* std:vector (for array)
*/
private static final String STD_VECTOR = "std::vector";
@Override
@ -354,6 +370,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
/**
* postProcessSingleParam - Modifies a single parameter, adjusting generated
* data types for Header and Query parameters.
*
* @param param CodegenParameter to be modified.
*/
private void postProcessSingleParam(CodegenParameter param) {
@ -443,6 +460,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
/**
* Prefix an open API type with a namespace or not, depending of its current type and if it is on a list to avoid it.
*
* @param openAPIType Open API Type.
* @return type prefixed with the namespace or not.
*/
@ -450,8 +468,7 @@ public class CppPistacheServerCodegen extends AbstractCppCodegen {
// Some types might not support namespace
if (this.openAPITypesWithoutModelNamespace.contains(openAPIType) || openAPIType.startsWith("std::")) {
return openAPIType;
}
else {
} else {
String namespace = (String) additionalProperties.get("modelNamespace");
return namespace + "::" + openAPIType;
}

View File

@ -31,7 +31,7 @@ import org.openapitools.codegen.model.OperationsMap;
import java.io.File;
import java.util.List;
import static org.openapitools.codegen.utils.StringUtils.*;
import static org.openapitools.codegen.utils.StringUtils.camelize;
public class CppQtClientCodegen extends CppQtAbstractCodegen implements CodegenConfig {
public static final String OPTIONAL_PROJECT_FILE_DESC = "Generate client.pri.";

View File

@ -348,8 +348,7 @@ public class CppRestbedServerCodegen extends AbstractCppCodegen {
op.operationIdCamelCase = op1.operationIdCamelCase;
currentOtherMethodList.add(op);
op1.vendorExtensions.put(X_CODEGEN_OTHER_METHODS, currentOtherMethodList);
}
else {
} else {
newOpList.add(op);
}
}

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