[SCB-1225][WIP][WEAK] swagger generator core not depend on dynamic class#1157
Conversation
af3d78c to
d8cfa56
Compare
| } | ||
|
|
||
| public static boolean isComplexProperty(Property property) { | ||
| if (RefProperty.class.isInstance(property) || ObjectProperty.class.isInstance(property) |
There was a problem hiding this comment.
maybe instanceof is better ?
| } | ||
|
|
||
| public static void setCommaConsumes(Swagger swagger, String commaConsumes) { | ||
| if (org.apache.commons.lang3.StringUtils.isEmpty(commaConsumes)) { |
There was a problem hiding this comment.
remove org.apache.commons, already import
|
|
||
| public static void setProduces(Operation operation, String... produces) { | ||
| // same to consumes | ||
| List<String> produceList = convertConsumes(produces); |
There was a problem hiding this comment.
why produces use method name convertConsumes, maybe the method name can be changed more appropriately
There was a problem hiding this comment.
change to covertConsumesOrProduces
| return false; | ||
| } | ||
|
|
||
| if (cls == String.class |
There was a problem hiding this comment.
can simply
return cls != String.class
&& cls != Date.class
&& cls != LocalDate.class
&& cls != byte[].class
&& !Part.class.isAssignableFrom(cls);
There was a problem hiding this comment.
less code, but logic is more complex.
| return property; | ||
| } | ||
|
|
||
| private boolean isEnum(List<String> enums) { |
There was a problem hiding this comment.
can be replaced with CollectionUtils.isEmpty(enums);
There was a problem hiding this comment.
depend on spring
or use org.apache.commons.collections4.CollectionUtils, still need new dependency
just a judgment, no need to change.
| Annotation annotation) { | ||
| if (StringUtils.isEmpty(name)) { | ||
| throw new IllegalStateException( | ||
| String.format("%s.name should not be empty. method=", annotation.annotationType().getSimpleName(), method)); |
|
|
||
| Type type = processor.getGenericType(annotation); | ||
| if (type != null) { | ||
| genericType = type; |
There was a problem hiding this comment.
why not break when type != null, want the later covers the former?
There was a problem hiding this comment.
yes, always override.
7a0bb6f to
9327b93
Compare
| @Documented | ||
| public @interface RawJsonRequestBody { | ||
| @AliasFor("name") | ||
| // aliasFor "name" |
There was a problem hiding this comment.
Will it introduce some backward compatibility issue?
There was a problem hiding this comment.
will not, because we read both of the two field
| import io.swagger.models.parameters.Parameter; | ||
|
|
||
| public class ParameterGenerator { | ||
| public String parameterName; |
There was a problem hiding this comment.
Why don't you use private as usually?
There was a problem hiding this comment.
change to private.
done
9327b93 to
8e9a746
Compare
|
What's the status of this PR? I see some compile errors and imcomplete code. |
all PR about "[WEAK]" is a new branch |
rewrite generate mechanism, make extend simpler
Swagger swagger = SwaggerGenerator.generate(cls)