mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-09 10:56:10 +00:00
[all] Adds strict spec option (#2783)
* [all] Adds strict spec option Introduces an option to allow user customization of strict specification behaviors. For instance, OpenAPI 3.x requires a path object name to be prefixed with '/' so we append any missing '/', but this may not be desirable to some users or generators. In this commit, this fix specifically is the only modification affected. * Clarify strict-spec docs, add option to README.md * Update CLI options in docs/usage.md
This commit is contained in:
@@ -214,6 +214,12 @@ public class Generate implements Runnable {
|
||||
description = "Skips the default behavior of validating an input specification.")
|
||||
private Boolean skipValidateSpec;
|
||||
|
||||
@Option(name = {"--strict-spec"},
|
||||
title = "true/false strict behavior",
|
||||
description = "'MUST' and 'SHALL' wording in OpenAPI spec is strictly adhered to. e.g. when false, no fixes will be applied to documents which pass validation but don't follow the spec.",
|
||||
arity = 1)
|
||||
private Boolean strictSpecBehavior;
|
||||
|
||||
@Option(name = {"--log-to-stderr"},
|
||||
title = "Log to STDERR",
|
||||
description = "write all log messages (not just errors) to STDOUT."
|
||||
@@ -368,10 +374,15 @@ public class Generate implements Runnable {
|
||||
if (generateAliasAsModel != null) {
|
||||
configurator.setGenerateAliasAsModel(generateAliasAsModel);
|
||||
}
|
||||
|
||||
if (minimalUpdate != null) {
|
||||
configurator.setEnableMinimalUpdate(minimalUpdate);
|
||||
}
|
||||
|
||||
if (strictSpecBehavior != null) {
|
||||
configurator.setStrictSpecBehavior(strictSpecBehavior);
|
||||
}
|
||||
|
||||
applySystemPropertiesKvpList(systemProperties, configurator);
|
||||
applyInstantiationTypesKvpList(instantiationTypes, configurator);
|
||||
applyImportMappingsKvpList(importMappings, configurator);
|
||||
|
||||
@@ -277,6 +277,26 @@ public class GenerateTest {
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStrictSpec() throws Exception {
|
||||
|
||||
setupAndRunGenericTest("--strict-spec", "true");
|
||||
new FullVerifications() {
|
||||
{
|
||||
configurator.setStrictSpecBehavior(true);
|
||||
times = 1;
|
||||
}
|
||||
};
|
||||
|
||||
setupAndRunGenericTest("--strict-spec", "false");
|
||||
new FullVerifications() {
|
||||
{
|
||||
configurator.setStrictSpecBehavior(false);
|
||||
times = 1;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPackageName() throws Exception {
|
||||
final String value = "io.foo.bar.baz";
|
||||
|
||||
Reference in New Issue
Block a user