mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2026-03-18 23:49:02 +00:00
Rename "swagger" to "openapi" (#191)
* Rename ".swagger-codegen-ignore" to ".openapi-generator-ignore" * Rename setGenerateSwaggerMetadata(Boolean) to setGenerateMetadata(Boolean) * Rename Metadata Folder to .openapi-generator
This commit is contained in:
@@ -224,7 +224,7 @@ public class CodegenConstants {
|
||||
public static final String VALIDATABLE_DESC = "Generates self-validatable models.";
|
||||
|
||||
public static final String IGNORE_FILE_OVERRIDE = "ignoreFileOverride";
|
||||
public static final String IGNORE_FILE_OVERRIDE_DESC = "Specifies an override location for the .swagger-codegen-ignore file. Most useful on initial generation.";
|
||||
public static final String IGNORE_FILE_OVERRIDE_DESC = "Specifies an override location for the .openapi-generator-ignore file. Most useful on initial generation.";
|
||||
|
||||
public static final String REMOVE_OPERATION_ID_PREFIX = "removeOperationIdPrefix";
|
||||
public static final String REMOVE_OPERATION_ID_PREFIX_DESC = "Remove prefix of operationId, e.g. config_getId => getId";
|
||||
|
||||
@@ -867,7 +867,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
importMapping.put("LocalDate", "org.joda.time.*");
|
||||
importMapping.put("LocalTime", "org.joda.time.*");
|
||||
|
||||
// we've used the .swagger-codegen-ignore approach as
|
||||
// we've used the .openapi-generator-ignore approach as
|
||||
// suppportingFiles can be cleared by code generator that extends
|
||||
// the default codegen, leaving the commented code below for
|
||||
// future reference
|
||||
@@ -3754,7 +3754,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides an override location, if any is specified, for the .swagger-codegen-ignore.
|
||||
* Provides an override location, if any is specified, for the .openapi-generator-ignore.
|
||||
* <p>
|
||||
* This is originally intended for the first generation only.
|
||||
*
|
||||
|
||||
@@ -46,7 +46,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
private Boolean generateApiDocumentation = null;
|
||||
private Boolean generateModelTests = null;
|
||||
private Boolean generateModelDocumentation = null;
|
||||
private Boolean generateSwaggerMetadata = true;
|
||||
private Boolean generateMetadata = true;
|
||||
private String basePath;
|
||||
private String basePathWithoutHost;
|
||||
private String contextPath;
|
||||
@@ -77,13 +77,13 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Programmatically disable the output of .swagger-codegen/VERSION, .swagger-codegen-ignore,
|
||||
* Programmatically disable the output of .swagger-codegen/VERSION, .openapi-generator-ignore,
|
||||
* or other metadata files used by Swagger Codegen.
|
||||
* @param generateSwaggerMetadata true: enable outputs, false: disable outputs
|
||||
* @param generateMetadata true: enable outputs, false: disable outputs
|
||||
*/
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public void setGenerateSwaggerMetadata(Boolean generateSwaggerMetadata) {
|
||||
this.generateSwaggerMetadata = generateSwaggerMetadata;
|
||||
public void setGenerateMetadata(Boolean generateMetadata) {
|
||||
this.generateMetadata = generateMetadata;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,7 +152,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
}
|
||||
// for backward compatibility
|
||||
if (System.getProperty("debugSwagger") != null) {
|
||||
LOGGER.info("Please use 'debugOpenAPI' instead of 'debugSwagger` moving forward.");
|
||||
LOGGER.info("Please use system property 'debugOpenAPI' instead of 'debugSwagger'.");
|
||||
Json.prettyPrint(openAPI);
|
||||
}
|
||||
|
||||
@@ -196,8 +196,8 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
if (StringUtils.isEmpty(info.getDescription())) {
|
||||
// set a default description if none if provided
|
||||
config.additionalProperties().put("appDescription",
|
||||
"No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)");
|
||||
config.additionalProperties().put("unescapedAppDescription", "No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)");
|
||||
"No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)");
|
||||
config.additionalProperties().put("unescapedAppDescription", "No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)");
|
||||
} else {
|
||||
config.additionalProperties().put("appDescription", config.escapeText(info.getDescription()));
|
||||
config.additionalProperties().put("unescapedAppDescription", info.getDescription());
|
||||
@@ -639,37 +639,37 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
files.add(outputFile);
|
||||
}
|
||||
} else {
|
||||
LOGGER.info("Skipped generation of " + outputFilename + " due to rule in .swagger-codegen-ignore");
|
||||
LOGGER.info("Skipped generation of " + outputFilename + " due to rule in .openapi-generator-ignore");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Could not generate supporting file '" + support + "'", e);
|
||||
}
|
||||
}
|
||||
|
||||
// Consider .swagger-codegen-ignore a supporting file
|
||||
// Output .swagger-codegen-ignore if it doesn't exist and wasn't explicitly created by a generator
|
||||
final String swaggerCodegenIgnore = ".swagger-codegen-ignore";
|
||||
String ignoreFileNameTarget = config.outputFolder() + File.separator + swaggerCodegenIgnore;
|
||||
// Consider .openapi-generator-ignore a supporting file
|
||||
// Output .openapi-generator-ignore if it doesn't exist and wasn't explicitly created by a generator
|
||||
final String openapiGeneratorIgnore = ".openapi-generator-ignore";
|
||||
String ignoreFileNameTarget = config.outputFolder() + File.separator + openapiGeneratorIgnore;
|
||||
File ignoreFile = new File(ignoreFileNameTarget);
|
||||
if (generateSwaggerMetadata && !ignoreFile.exists()) {
|
||||
String ignoreFileNameSource = File.separator + config.getCommonTemplateDir() + File.separator + swaggerCodegenIgnore;
|
||||
if (generateMetadata && !ignoreFile.exists()) {
|
||||
String ignoreFileNameSource = File.separator + config.getCommonTemplateDir() + File.separator + openapiGeneratorIgnore;
|
||||
String ignoreFileContents = readResourceContents(ignoreFileNameSource);
|
||||
try {
|
||||
writeToFile(ignoreFileNameTarget, ignoreFileContents);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Could not generate supporting file '" + swaggerCodegenIgnore + "'", e);
|
||||
throw new RuntimeException("Could not generate supporting file '" + openapiGeneratorIgnore + "'", e);
|
||||
}
|
||||
files.add(ignoreFile);
|
||||
}
|
||||
|
||||
if(generateSwaggerMetadata) {
|
||||
final String swaggerVersionMetadata = config.outputFolder() + File.separator + ".swagger-codegen" + File.separator + "VERSION";
|
||||
File swaggerVersionMetadataFile = new File(swaggerVersionMetadata);
|
||||
if(generateMetadata) {
|
||||
final String versionMetadata = config.outputFolder() + File.separator + ".openapi-generator" + File.separator + "VERSION";
|
||||
File versionMetadataFile = new File(versionMetadata);
|
||||
try {
|
||||
writeToFile(swaggerVersionMetadata, ImplementationVersion.read());
|
||||
files.add(swaggerVersionMetadataFile);
|
||||
writeToFile(versionMetadata, ImplementationVersion.read());
|
||||
files.add(versionMetadataFile);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Could not generate supporting file '" + swaggerVersionMetadata + "'", e);
|
||||
throw new RuntimeException("Could not generate supporting file '" + versionMetadata + "'", e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -800,7 +800,7 @@ public class DefaultGenerator extends AbstractGenerator implements Generator {
|
||||
return new File(adjustedOutputFilename);
|
||||
}
|
||||
|
||||
LOGGER.info("Skipped generation of " + adjustedOutputFilename + " due to rule in .swagger-codegen-ignore");
|
||||
LOGGER.info("Skipped generation of " + adjustedOutputFilename + " due to rule in .openapi-generator-ignore");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.openapitools.codegen.ignore;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.io.Files;
|
||||
import org.openapitools.codegen.ignore.rules.DirectoryRule;
|
||||
import org.openapitools.codegen.ignore.rules.Rule;
|
||||
import org.slf4j.Logger;
|
||||
@@ -12,7 +13,7 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Presents a processing utility for parsing and evaluating files containing common ignore patterns. (.swagger-codegen-ignore)
|
||||
* Presents a processing utility for parsing and evaluating files containing common ignore patterns. (.openapi-generator-ignore)
|
||||
*/
|
||||
public class CodegenIgnoreProcessor {
|
||||
|
||||
@@ -24,12 +25,12 @@ public class CodegenIgnoreProcessor {
|
||||
private List<Rule> inclusionRules = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Loads the default ignore file (.swagger-codegen-ignore) from the specified path.
|
||||
* Loads the default ignore file (.openapi-generator-ignore) from the specified path.
|
||||
*
|
||||
* @param baseDirectory The base directory of the files to be processed. This contains the ignore file.
|
||||
*/
|
||||
public CodegenIgnoreProcessor(final String baseDirectory) {
|
||||
this(baseDirectory, ".swagger-codegen-ignore");
|
||||
this(baseDirectory, ".openapi-generator-ignore");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -45,7 +46,7 @@ public class CodegenIgnoreProcessor {
|
||||
if (directory.exists() && directory.isDirectory()) {
|
||||
loadFromFile(targetIgnoreFile);
|
||||
} else {
|
||||
LOGGER.warn("Output directory does not exist, or is inaccessible. No file (.swagger-codegen-ignore) will be evaluated.");
|
||||
LOGGER.warn("Output directory does not exist, or is inaccessible. No file (.openapi-generator-ignore) will be evaluated.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,6 +67,20 @@ public class CodegenIgnoreProcessor {
|
||||
} catch (IOException e) {
|
||||
LOGGER.error(String.format("Could not process %s.", targetIgnoreFile.getName()), e.getMessage());
|
||||
}
|
||||
} else if (!".swagger-codegen-ignore".equals(targetIgnoreFile.getName())) {
|
||||
final File legacyIgnoreFile = new File(targetIgnoreFile.getParentFile(), ".swagger-codegen-ignore");
|
||||
if (legacyIgnoreFile.exists() && legacyIgnoreFile.isFile()) {
|
||||
LOGGER.info(String.format("Legacy support: '%s' file renamed to '%s'.", legacyIgnoreFile.getName(), targetIgnoreFile.getName()));
|
||||
try {
|
||||
Files.move(legacyIgnoreFile, targetIgnoreFile);
|
||||
loadFromFile(targetIgnoreFile);
|
||||
} catch (IOException e) {
|
||||
LOGGER.error(String.format("Could not rename file: %s", e.getMessage()));
|
||||
}
|
||||
} else {
|
||||
// log info message
|
||||
LOGGER.info(String.format("No %s file found.", targetIgnoreFile.getName()));
|
||||
}
|
||||
} else {
|
||||
// log info message
|
||||
LOGGER.info(String.format("No %s file found.", targetIgnoreFile.getName()));
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* A special case rule which matches files only if they're located
|
||||
* in the same directory as the .swagger-codegen-ignore file.
|
||||
* in the same directory as the .openapi-generator-ignore file.
|
||||
*/
|
||||
public class RootedFileRule extends Rule {
|
||||
private String definedFilename = null;
|
||||
|
||||
@@ -167,7 +167,7 @@ public class JavaCXFServerCodegen extends AbstractJavaJAXRSServerCodegen
|
||||
writeOptional(outputFolder, new SupportingFile("server/pom.mustache", "", "pom.xml"));
|
||||
|
||||
writeOptional(outputFolder,
|
||||
new SupportingFile("server/swagger-codegen-ignore.mustache", "", ".swagger-codegen-ignore"));
|
||||
new SupportingFile("server/swagger-codegen-ignore.mustache", "", ".openapi-generator-ignore"));
|
||||
|
||||
if (this.generateSpringApplication) {
|
||||
writeOptional(outputFolder, new SupportingFile("server/readme.md", "", "readme.md"));
|
||||
|
||||
Reference in New Issue
Block a user