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() {
|
public PowerShellClientCodegen() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
modifyFeatureSet(features -> features
|
modifyFeatureSet(features -> features
|
||||||
.includeDocumentationFeatures(DocumentationFeature.Readme)
|
.includeDocumentationFeatures(DocumentationFeature.Readme)
|
||||||
.wireFormatFeatures(EnumSet.of(WireFormatFeature.JSON, WireFormatFeature.XML))
|
.wireFormatFeatures(EnumSet.of(WireFormatFeature.JSON, WireFormatFeature.XML))
|
||||||
@ -546,6 +545,7 @@ public class PowerShellClientCodegen extends DefaultCodegen implements CodegenCo
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void processOpts() {
|
public void processOpts() {
|
||||||
|
this.setLegacyDiscriminatorBehavior(false);
|
||||||
super.processOpts();
|
super.processOpts();
|
||||||
|
|
||||||
if (StringUtils.isEmpty(System.getenv("POWERSHELL_POST_PROCESS_FILE"))) {
|
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)) {
|
if ("null<String, SystemCollectionsHashtable>".equals(model.parent)) {
|
||||||
model.vendorExtensions.put("x-additional-properties", true);
|
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;
|
return objs;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user