forked from loafle/openapi-generator-original
Syncs validation properties for arraymodels (#7357)
* Syncs validation properties for arraymodels * Adds arrayModelHasValidation test
This commit is contained in:
parent
2d5b2726d0
commit
681e821b71
@ -2272,6 +2272,7 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
m.isArrayModel = true;
|
||||
m.arrayModelType = fromProperty(name, schema).complexType;
|
||||
addParentContainer(m, name, schema);
|
||||
ModelUtils.syncValidationProperties(schema, m);
|
||||
} else if (schema instanceof ComposedSchema) {
|
||||
final ComposedSchema composed = (ComposedSchema) schema;
|
||||
Map<String, Schema> properties = new LinkedHashMap<String, Schema>();
|
||||
|
@ -2253,4 +2253,17 @@ public class DefaultCodegenTest {
|
||||
assertEquals(openAPI.getComponents().getSchemas().size(), 2);
|
||||
assertNull(cm.getDiscriminator());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void arrayModelHasValidation() {
|
||||
final OpenAPI openAPI = TestUtils.parseFlattenSpec("src/test/resources/3_0/issue7356.yaml");
|
||||
final DefaultCodegen codegen = new DefaultCodegen();
|
||||
codegen.setOpenAPI(openAPI);
|
||||
|
||||
String modelName = "ArrayWithValidations";
|
||||
Schema sc = openAPI.getComponents().getSchemas().get(modelName);
|
||||
CodegenModel cm = codegen.fromModel(modelName, sc);
|
||||
assertEquals((int) cm.getMinItems(), 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,14 @@
|
||||
openapi: 3.0.1
|
||||
info:
|
||||
title: My title
|
||||
description: API under test
|
||||
version: 1.0.7
|
||||
servers:
|
||||
- url: https://localhost:9999/root
|
||||
paths:
|
||||
components:
|
||||
schemas:
|
||||
ArrayWithValidations:
|
||||
type: array
|
||||
minItems: 1
|
||||
items: {}
|
Loading…
x
Reference in New Issue
Block a user