Skip to content

Commit 80512fe

Browse files
committed
ref #6394 - limit to 10 examples for array types
1 parent e0904f6 commit 80512fe

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ private Object resolvePropertyToExample(String propertyName, String mediaType, P
157157
Property innerType = ((ArrayProperty) property).getItems();
158158
if (innerType != null) {
159159
int arrayLength = null == ((ArrayProperty) property).getMaxItems() ? 2 : ((ArrayProperty) property).getMaxItems();
160+
// max 10 examples to avoid OOM
161+
if (arrayLength > 10) {
162+
logger.warn("value of maxItems of property {} is {}; limiting to 10 examples", property, arrayLength);
163+
arrayLength = 10;
164+
}
160165
Object[] objectProperties = new Object[arrayLength];
161166
Object objProperty = resolvePropertyToExample(propertyName, mediaType, innerType, processedModels);
162167
for(int i=0; i < arrayLength; i++) {

0 commit comments

Comments
 (0)