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:
Jérémie Bresson 2018-04-22 21:28:17 +02:00 committed by GitHub
parent a2afc6e32e
commit 7ecd5f3566
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
434 changed files with 60 additions and 49 deletions

View File

@ -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";

View File

@ -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.
*

View File

@ -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;
}

View File

@ -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()));

View File

@ -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;

View File

@ -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"));

View File

@ -3,7 +3,7 @@
-- ------------ EDIT NOTE ------------
-- This file was generated with swagger-codegen. You can modify it to implement
-- the server. After you modify this file, you should add the following line
-- to the .swagger-codegen-ignore file:
-- to the .openapi-generator-ignore file:
--
-- src/{{packageName}}.ads
--

View File

@ -3,7 +3,7 @@
-- ------------ EDIT NOTE ------------
-- This file was generated with swagger-codegen. You can modify it to implement
-- the server. After you modify this file, you should add the following line
-- to the .swagger-codegen-ignore file:
-- to the .openapi-generator-ignore file:
--
-- src/{{packageName}}.ads
--

View File

@ -3,7 +3,7 @@
-- ------------ EDIT NOTE ------------
-- This file was generated with swagger-codegen. You can modify it to implement
-- the server. After you modify this file, you should add the following line
-- to the .swagger-codegen-ignore file:
-- to the .openapi-generator-ignore file:
--
-- src/{{packageName}}-servers.adb
--

View File

@ -3,7 +3,7 @@
-- ------------ EDIT NOTE ------------
-- This file was generated with swagger-codegen. You can modify it to implement
-- the server. After you modify this file, you should add the following line
-- to the .swagger-codegen-ignore file:
-- to the .openapi-generator-ignore file:
--
-- src/{{packageName}}-servers.ads
--

View File

@ -1,5 +1,5 @@
# Swagger Codegen Ignore
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
# Openapi Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.

View File

@ -16,7 +16,7 @@ namespace {{packageName}}.Client
/// </summary>
/// <remarks>
/// A customized implementation via partial class may reside in another file and may
/// be excluded from automatic generation via a .swagger-codegen-ignore file.
/// be excluded from automatic generation via a .openapi-generator-ignore file.
/// </remarks>
public partial class GlobalConfiguration : Configuration
{

View File

@ -1,5 +1,5 @@
.travis.yaml
.swagger-codegen-ignore
.openapi-generator-ignore
README.md
tox.ini
git_push.sh

View File

@ -13,7 +13,7 @@ import {{packageName}}.settings
/**
* Application block for [CORS] configuration.
*
* This file may be excluded in .swagger-codegen-ignore,
* This file may be excluded in .openapi-generator-ignore,
* and application specific configuration can be applied in this function.
*
* See http://ktor.io/features/cors.html
@ -37,7 +37,7 @@ internal fun ApplicationCORSConfiguration(): CORS.Configuration.() -> Unit {
/**
* Application block for [HSTS] configuration.
*
* This file may be excluded in .swagger-codegen-ignore,
* This file may be excluded in .openapi-generator-ignore,
* and application specific configuration can be applied in this function.
*
* See http://ktor.io/features/hsts.html
@ -58,7 +58,7 @@ internal fun ApplicationHstsConfiguration(): HSTS.Configuration.() -> Unit {
/**
* Application block for [Compression] configuration.
*
* This file may be excluded in .swagger-codegen-ignore,
* This file may be excluded in .openapi-generator-ignore,
* and application specific configuration can be applied in this function.
*
* See http://ktor.io/features/compression.html

View File

@ -13,7 +13,7 @@
"artifactId" : "awesome-api",
"artifactVersion" : "1.2.3",
"library" : "jersey2",
"ignoreFileOverride": "/path/to/override/.swagger-codegen-ignore",
"ignoreFileOverride": "/path/to/override/.openapi-generator-ignore",
"systemProperties" : {
"systemProp1" : "value1"
},

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