Skip to content

Commit 8eacedc

Browse files
committed
ref #6394 - limit to 10 examples for array types
1 parent 74d9afe commit 8eacedc

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

modules/swagger-codegen/src/main/java/io/swagger/codegen/v3/examples/ExampleGenerator.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ private Object resolvePropertyToExample(String propertyName, String mediaType, S
170170
Schema innerType = ((ArraySchema) property).getItems();
171171
if (innerType != null) {
172172
int arrayLength = null == ((ArraySchema) property).getMaxItems() ? 2 : ((ArraySchema) property).getMaxItems();
173+
// max 10 examples to avoid OOM
174+
if (arrayLength > 10) {
175+
logger.warn("value of maxItems of property {} is {}; limiting to 10 examples", property, arrayLength);
176+
arrayLength = 10;
177+
}
178+
173179
Object[] objectProperties = new Object[arrayLength];
174180
Object objProperty = resolvePropertyToExample(propertyName, mediaType, innerType, processedModels);
175181
for(int i=0; i < arrayLength; i++) {

0 commit comments

Comments
 (0)