swagger-api / swagger-api/swagger-codegen
Code generation and type flags for array
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Swagger-codegen version
2.3.0
Swagger declaration file content or url
"MediaFileCopyrightElastic": {
"type": "object",
"properties": {
"EmmisionRestrictions": {
"type": "array",
"items": {
"type": "string",
"format": "date-time"
}
}
}
The bug can be fixed by replacing the function updatePropertyForArray with the following one:
protected void updatePropertyForArray(CodegenProperty property, CodegenProperty innerProperty) {
if (innerProperty == null) {
LOGGER.warn("skipping invalid array property " + Json.pretty(property));
return;
}
property.dataFormat = innerProperty.dataFormat;
if (!languageSpecificPrimitives.contains(innerProperty.baseType)) {
property.complexType = innerProperty.baseType;
} else {
property.isPrimitiveType = true;
property.isBoolean = innerProperty.isBoolean;
property.isLong = innerProperty.isLong;
property.isInteger = innerProperty.isInteger;
property.isDouble = innerProperty.isDouble;
property.isFloat = innerProperty.isFloat;
property.isByteArray = innerProperty.isByteArray;
property.isBinary = innerProperty.isBinary;
property.isFile = innerProperty.isFile;
property.isDate = innerProperty.isDate;
property.isDateTime = innerProperty.isDateTime;
}
property.items = innerProperty;
// inner item is Enum
if (isPropertyInnerMostEnum(property)) {
// isEnum is set to true when the type is an enum
// or the inner type of an array/map is an enum
property.isEnum = true;
// update datatypeWithEnum and default value for array
// e.g. List => List
updateDataTypeWithEnumForArray(property);
// set allowable values to enum values (including array/map of enum)
property.allowableValues = getInnerEnumAllowableValues(property);
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Locate the Java implementation of updatePropertyForArray and inspect how an Array property receives its inner property's type flags. Verify the change with the existing code-generation test or reproduction for the EmmisionRestrictions array, and consider the work done when the generated property carries the expected date and primitive flags.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100