forked from loafle/openapi-generator-original
use legacy discriminator mapping (#6604)
This commit is contained in:
parent
233087c5aa
commit
fd2976b89c
@ -60,7 +60,6 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
*/
|
||||
public PowerShellClientCodegen() {
|
||||
super();
|
||||
|
||||
modifyFeatureSet(features -> features
|
||||
.includeDocumentationFeatures(DocumentationFeature.Readme)
|
||||
.wireFormatFeatures(EnumSet.of(WireFormatFeature.JSON, WireFormatFeature.XML))
|
||||
@ -546,6 +545,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
this.setLegacyDiscriminatorBehavior(false);
|
||||
super.processOpts();
|
||||
|
||||
if (StringUtils.isEmpty(System.getenv("POWERSHELL_POST_PROCESS_FILE"))) {
|
||||
@ -926,27 +926,6 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
||||
if ("null<String, SystemCollectionsHashtable>".equals(model.parent)) {
|
||||
model.vendorExtensions.put("x-additional-properties", true);
|
||||
}
|
||||
|
||||
// automatically create discriminator mapping for oneOf/anyOf if not present
|
||||
if (((model.oneOf != null && !model.oneOf.isEmpty()) || (model.anyOf != null && !model.anyOf.isEmpty())) &&
|
||||
model.discriminator != null && model.discriminator.getMapping() == null) {
|
||||
// create mappedModels
|
||||
Set<String> schemas = new HashSet<>();
|
||||
if (model.oneOf != null && !model.oneOf.isEmpty()) {
|
||||
schemas = model.oneOf;
|
||||
} else if (model.anyOf != null && !model.anyOf.isEmpty()) {
|
||||
schemas = model.anyOf;
|
||||
}
|
||||
|
||||
HashSet<CodegenDiscriminator.MappedModel> mappedModels = new HashSet<>();
|
||||
|
||||
for (String s: schemas) {
|
||||
mappedModels.add(new CodegenDiscriminator.MappedModel(s, s));
|
||||
}
|
||||
|
||||
model.discriminator.setMappedModels(mappedModels);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return objs;
|
||||
|
@ -65,7 +65,7 @@ function ConvertFrom-{{{apiNamePrefix}}}JsonTo{{{classname}}} {
|
||||
Write-Debug "Failed to match '{{{modelName}}}' defined in oneOf ({{{apiNamePrefix}}}{{{classname}}}) using the discriminator lookup ({{{mappingName}}}). Proceeding with the typical oneOf type matching."
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{{/mappedModels}}
|
||||
{{/discriminator}}
|
||||
{{/useOneOfDiscriminatorLookup}}
|
||||
|
@ -157,7 +157,7 @@ function ConvertFrom-{{{apiNamePrefix}}}JsonTo{{{classname}}} {
|
||||
|
||||
{{/-first}}
|
||||
if (!([bool]($JsonParameters.PSobject.Properties.name -match "{{{baseName}}}"))) {
|
||||
throw "Error! JSON cannot be serialized due to the required property `{{{baseName}}}` missing."
|
||||
throw "Error! JSON cannot be serialized due to the required property `{{{baseName}}}` missing."
|
||||
} else {
|
||||
${{name}} = $JsonParameters.PSobject.Properties["{{{baseName}}}"].value
|
||||
}
|
||||
|
@ -128,13 +128,13 @@ function ConvertFrom-PSJsonToPet {
|
||||
}
|
||||
|
||||
if (!([bool]($JsonParameters.PSobject.Properties.name -match "name"))) {
|
||||
throw "Error! JSON cannot be serialized due to the required property `name` missing."
|
||||
throw "Error! JSON cannot be serialized due to the required property `name` missing."
|
||||
} else {
|
||||
$Name = $JsonParameters.PSobject.Properties["name"].value
|
||||
}
|
||||
|
||||
if (!([bool]($JsonParameters.PSobject.Properties.name -match "photoUrls"))) {
|
||||
throw "Error! JSON cannot be serialized due to the required property `photoUrls` missing."
|
||||
throw "Error! JSON cannot be serialized due to the required property `photoUrls` missing."
|
||||
} else {
|
||||
$PhotoUrls = $JsonParameters.PSobject.Properties["photoUrls"].value
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user