Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit 7854764

Browse files
authored
v2 removes inline model resolver (#153)
* Removes inlinemodelresolver * Fixes 2 java tests * Fixes testDateTimeFormParameterHasDefaultValue * Fixes testHasRequiredInProperties * Fixes testHasRequiredInResponses * Fixes testHasVarsInParameter * Fixes testHasVarsInProperty * Fixes testHasVarsInResponse * Fixes testNullableProperty * Fixes testRequestBodyContent * Fixes more defaultcodegen tests * Fixes two tests in DefaultGeneratorTest * Fixes test in ModelUtilsTest * Samples regen, docs regen
1 parent da75dab commit 7854764

File tree

13 files changed

+48
-2127
lines changed

13 files changed

+48
-2127
lines changed

docs/generators/python.md

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
2828
|packageVersion|python package version.| |1.0.0|
2929
|projectName|python project name in setup.py (e.g. petstore-api).| |null|
3030
|recursionLimit|Set the recursion limit. If not set, use the system default value.| |null|
31-
|useInlineModelResolver|use the inline model resolver, if true inline complex models will be extracted into components and $refs to them will be used| |false|
3231
|useNose|use the nose test framework| |false|
3332

3433
## INSTANTIATION TYPES

modules/openapi-json-schema-generator/src/main/java/org/openapijsonschematools/codegen/CodegenConfig.java

-2
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,6 @@ public interface CodegenConfig {
325325

326326
List<VendorExtension> getSupportedVendorExtensions();
327327

328-
boolean getUseInlineModelResolver();
329-
330328
String toRefClass(String ref, String sourceJsonPath, String expectedComponentType);
331329

332330
CodegenRequestBody fromRequestBody(RequestBody body, String sourceJsonPath);

modules/openapi-json-schema-generator/src/main/java/org/openapijsonschematools/codegen/DefaultCodegen.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -1893,6 +1893,7 @@ protected List<MappedModel> getOneOfAnyOfDescendants(String composedSchemaName,
18931893
LOGGER.warn(
18941894
"Invalid inline schema defined in oneOf/anyOf in '{}'. Per the OpenApi spec, for this case when a composed schema defines a discriminator, the oneOf/anyOf schemas must use $ref. Change this inline definition to a $ref definition",
18951895
composedSchemaName);
1896+
continue;
18961897
}
18971898
CodegenSchema df = discriminatorFound(composedSchemaName, sc, discPropName, openAPI);
18981899
String modelName = ModelUtils.getSimpleRef(ref);
@@ -4773,9 +4774,6 @@ public List<VendorExtension> getSupportedVendorExtensions() {
47734774
return new ArrayList<>();
47744775
}
47754776

4776-
@Override
4777-
public boolean getUseInlineModelResolver() { return true; }
4778-
47794777
/*
47804778
A function to convert yaml or json ingested strings like property names
47814779
And convert special characters like newline, tab, carriage return

modules/openapi-json-schema-generator/src/main/java/org/openapijsonschematools/codegen/DefaultGenerator.java

-9
Original file line numberDiff line numberDiff line change
@@ -255,15 +255,6 @@ void configureGeneratorProperties() {
255255
}
256256

257257
config.processOpts();
258-
259-
// resolve inline models
260-
if (config.getUseInlineModelResolver()) {
261-
InlineModelResolver inlineModelResolver = new InlineModelResolver();
262-
inlineModelResolver.setInlineSchemaNameMapping(config.inlineSchemaNameMapping());
263-
inlineModelResolver.setInlineSchemaNameDefaults(config.inlineSchemaNameDefault());
264-
inlineModelResolver.flatten(openAPI);
265-
}
266-
267258
config.preprocessOpenAPI(openAPI);
268259

269260
// set OpenAPI to make these available to all methods

modules/openapi-json-schema-generator/src/main/java/org/openapijsonschematools/codegen/InlineModelResolver.java

-914
This file was deleted.

modules/openapi-json-schema-generator/src/main/java/org/openapijsonschematools/codegen/languages/PythonClientCodegen.java

-15
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ public class PythonClientCodegen extends AbstractPythonCodegen {
8282
// nose is a python testing framework, we use pytest if USE_NOSE is unset
8383
public static final String USE_NOSE = "useNose";
8484
public static final String RECURSION_LIMIT = "recursionLimit";
85-
public static final String USE_INLINE_MODEL_RESOLVER = "useInlineModelResolver";
8685
private final Pattern patternRegex = Pattern.compile("^/?(.+?)/?([simu]{0,4})$");
8786

8887
protected String packageUrl;
@@ -91,7 +90,6 @@ public class PythonClientCodegen extends AbstractPythonCodegen {
9190
// todo connect that custom path in here
9291
protected String modelDocPath = "docs/components/schema/";
9392
protected boolean useNose = false;
94-
protected boolean useInlineModelResolver = false;
9593

9694
protected Map<Character, String> regexModifiers;
9795

@@ -287,8 +285,6 @@ public PythonClientCodegen() {
287285
cliOptions.add(CliOption.newBoolean(USE_NOSE, "use the nose test framework").
288286
defaultValue(Boolean.FALSE.toString()));
289287
cliOptions.add(new CliOption(RECURSION_LIMIT, "Set the recursion limit. If not set, use the system default value."));
290-
cliOptions.add(CliOption.newBoolean(USE_INLINE_MODEL_RESOLVER, "use the inline model resolver, if true inline complex models will be extracted into components and $refs to them will be used").
291-
defaultValue(Boolean.FALSE.toString()));
292288
CliOption nonCompliantUseDiscrIfCompositionFails = CliOption.newBoolean(CodegenConstants.NON_COMPLIANT_USE_DISCR_IF_COMPOSITION_FAILS, CodegenConstants.NON_COMPLIANT_USE_DISCR_IF_COMPOSITION_FAILS_DESC);
293289
Map<String, String> nonCompliantUseDiscrIfCompositionFailsOpts = new HashMap<>();
294290
nonCompliantUseDiscrIfCompositionFailsOpts.put("true", "If composition fails and a discriminator exists, the composition errors will be ignored and validation will be attempted with the discriminator");
@@ -654,10 +650,6 @@ public void processOpts() {
654650
setUseNose((String) additionalProperties.get(USE_NOSE));
655651
}
656652

657-
if (additionalProperties.containsKey(USE_INLINE_MODEL_RESOLVER)) {
658-
setUseInlineModelResolver((String) additionalProperties.get(USE_INLINE_MODEL_RESOLVER));
659-
}
660-
661653
// check to see if setRecursionLimit is set and whether it's an integer
662654
if (additionalProperties.containsKey(RECURSION_LIMIT)) {
663655
try {
@@ -1789,13 +1781,6 @@ public void setUseNose(String val) {
17891781
this.useNose = Boolean.parseBoolean(val);
17901782
}
17911783

1792-
@Override
1793-
public boolean getUseInlineModelResolver() { return useInlineModelResolver; }
1794-
1795-
public void setUseInlineModelResolver(String val) {
1796-
this.useInlineModelResolver = Boolean.parseBoolean(val);
1797-
}
1798-
17991784
public void setPackageUrl(String packageUrl) {
18001785
this.packageUrl = packageUrl;
18011786
}

0 commit comments

Comments
 (0)