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

v2 removes inline model resolver #153

Merged
merged 14 commits into from
Apr 11, 2023
1 change: 0 additions & 1 deletion docs/generators/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|packageVersion|python package version.| |1.0.0|
|projectName|python project name in setup.py (e.g. petstore-api).| |null|
|recursionLimit|Set the recursion limit. If not set, use the system default value.| |null|
|useInlineModelResolver|use the inline model resolver, if true inline complex models will be extracted into components and $refs to them will be used| |false|
|useNose|use the nose test framework| |false|

## INSTANTIATION TYPES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,6 @@ public interface CodegenConfig {

List<VendorExtension> getSupportedVendorExtensions();

boolean getUseInlineModelResolver();

String toRefClass(String ref, String sourceJsonPath, String expectedComponentType);

CodegenRequestBody fromRequestBody(RequestBody body, String sourceJsonPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1893,6 +1893,7 @@ protected List<MappedModel> getOneOfAnyOfDescendants(String composedSchemaName,
LOGGER.warn(
"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",
composedSchemaName);
continue;
}
CodegenSchema df = discriminatorFound(composedSchemaName, sc, discPropName, openAPI);
String modelName = ModelUtils.getSimpleRef(ref);
Expand Down Expand Up @@ -4773,9 +4774,6 @@ public List<VendorExtension> getSupportedVendorExtensions() {
return new ArrayList<>();
}

@Override
public boolean getUseInlineModelResolver() { return true; }

/*
A function to convert yaml or json ingested strings like property names
And convert special characters like newline, tab, carriage return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,15 +255,6 @@ void configureGeneratorProperties() {
}

config.processOpts();

// resolve inline models
if (config.getUseInlineModelResolver()) {
InlineModelResolver inlineModelResolver = new InlineModelResolver();
inlineModelResolver.setInlineSchemaNameMapping(config.inlineSchemaNameMapping());
inlineModelResolver.setInlineSchemaNameDefaults(config.inlineSchemaNameDefault());
inlineModelResolver.flatten(openAPI);
}

config.preprocessOpenAPI(openAPI);

// set OpenAPI to make these available to all methods
Expand Down

This file was deleted.

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

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

protected Map<Character, String> regexModifiers;

Expand Down Expand Up @@ -287,8 +285,6 @@ public PythonClientCodegen() {
cliOptions.add(CliOption.newBoolean(USE_NOSE, "use the nose test framework").
defaultValue(Boolean.FALSE.toString()));
cliOptions.add(new CliOption(RECURSION_LIMIT, "Set the recursion limit. If not set, use the system default value."));
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").
defaultValue(Boolean.FALSE.toString()));
CliOption nonCompliantUseDiscrIfCompositionFails = CliOption.newBoolean(CodegenConstants.NON_COMPLIANT_USE_DISCR_IF_COMPOSITION_FAILS, CodegenConstants.NON_COMPLIANT_USE_DISCR_IF_COMPOSITION_FAILS_DESC);
Map<String, String> nonCompliantUseDiscrIfCompositionFailsOpts = new HashMap<>();
nonCompliantUseDiscrIfCompositionFailsOpts.put("true", "If composition fails and a discriminator exists, the composition errors will be ignored and validation will be attempted with the discriminator");
Expand Down Expand Up @@ -654,10 +650,6 @@ public void processOpts() {
setUseNose((String) additionalProperties.get(USE_NOSE));
}

if (additionalProperties.containsKey(USE_INLINE_MODEL_RESOLVER)) {
setUseInlineModelResolver((String) additionalProperties.get(USE_INLINE_MODEL_RESOLVER));
}

// check to see if setRecursionLimit is set and whether it's an integer
if (additionalProperties.containsKey(RECURSION_LIMIT)) {
try {
Expand Down Expand Up @@ -1789,13 +1781,6 @@ public void setUseNose(String val) {
this.useNose = Boolean.parseBoolean(val);
}

@Override
public boolean getUseInlineModelResolver() { return useInlineModelResolver; }

public void setUseInlineModelResolver(String val) {
this.useInlineModelResolver = Boolean.parseBoolean(val);
}

public void setPackageUrl(String packageUrl) {
this.packageUrl = packageUrl;
}
Expand Down
Loading