0
Javaソースの変換のためにスプーンライブラリを初めて使用しました。既存のRESTサービスを変換するためにそれを使用しようとしています。要件は、例えば、クラスレベルでio.swagger.annotations.SwaggerDefinitionアノテーションを追加することです:クラスレベルでAnnotation SwaggerDefinitionを追加する際の問題
@SwaggerDefinition(
tags = {
@Tag(
name = "api name", description = "api description"
)
}
)
直面している問題は、私は、注釈を追加していたときに、そのは以下のように追加されていることである:
@SwaggerDefinition(
tags =
@Tag(
name = "api name", description = "api description"
)
)
注:
:行方不明中括弧「{」とマッチング閉じ括弧「}」後は使用されている機能であります
private CtAnnotation createSwaggerDefinitionAnnotation(CtClass<?> ctClass) throws JSONException {
CtAnnotation tagAnnotation = createTagAnnotation(ctClass);
CtAnnotation swaggerDefAnnotation = getFactory().Core().createAnnotation();
CtTypeReference<Object> ref = getFactory().Core().createTypeReference();
ref.setSimpleName("SwaggerDefinition");
CtPackageReference refPackage = getFactory().Core().createPackageReference();
refPackage.setSimpleName("io.swagger.annotations");
ref.setPackage(refPackage);
swaggerDefAnnotation.setAnnotationType(ref);
swaggerDefAnnotation.addValue("tags", tagAnnotation); // TODO: The tag should be wrapped in curly braces
return swaggerDefAnnotation;
}
private CtAnnotation createTagAnnotation(CtClass<?> ctClass) {
String className = ctClass.getQualifiedName();
CtAnnotation tagAnnotation = getFactory().Core().createAnnotation();
CtTypeReference<Object> ref = getFactory().Core().createTypeReference();
ref.setSimpleName("Tag");
CtPackageReference refPackage = getFactory().Core().createPackageReference();
refPackage.setSimpleName("io.swagger.annotations");
ref.setPackage(refPackage);
tagAnnotation.setAnnotationType(ref);
tagAnnotation.addValue("name", getSwaggerDefinitionTagName(className));
tagAnnotation.addValue("description", getSwaggerDefinitionTagDescription(className));
return tagAnnotation;
}
誰かが欠けている部分を特定できますか?私はそれを理解することができません。
大感謝@Thomas!出来た – sanjay