Skip to content

Commit

Permalink
Fixes for schema definition
Browse files Browse the repository at this point in the history
  • Loading branch information
altro3 committed Dec 15, 2024
1 parent f422dfe commit b96d021
Show file tree
Hide file tree
Showing 8 changed files with 137 additions and 97 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ private void processExternalDocs(ClassElement element, VisitorContext context) {
if (externalDocsAnn == null) {
return;
}
classExternalDocs = toValue(externalDocsAnn.getValues(), context, ExternalDocumentation.class, null);
classExternalDocs = toValue(externalDocsAnn.getAnnotationName(), externalDocsAnn.getValues(), context, ExternalDocumentation.class, null);
}

private boolean containsTag(String name, List<Tag> tags) {
Expand Down Expand Up @@ -700,7 +700,7 @@ private Map<String, Example> readExamples(List<AnnotationValue<ExampleObject>> e
var result = new HashMap<String, Example>();
for (var exampleAnn : exampleAnns) {
try {
var exampleMap = toValueMap(exampleAnn.getValues(), context, null);
var exampleMap = toValueMap(exampleAnn.getAnnotationName(), exampleAnn.getValues(), context, null);
result.put((String) exampleMap.get(PROP_NAME), Utils.getJsonMapper().convertValue(exampleMap, Example.class));
} catch (Exception e) {
warn("Error reading Parameter example " + exampleAnn + " for element [" + element + "]: " + e.getMessage(), context, element);
Expand Down Expand Up @@ -1096,7 +1096,7 @@ private Parameter processMethodParameterAnnotation(VisitorContext context, Opera
return null;
}

Map<CharSequence, Object> paramValues = toValueMap(paramAnn.getValues(), context, null);
Map<CharSequence, Object> paramValues = toValueMap(paramAnn.getAnnotationName(), paramAnn.getValues(), context, null);
Utils.normalizeEnumValues(paramValues, Collections.singletonMap(PROP_IN, ParameterIn.class));
if (parameter.isAnnotationPresent(Header.class)) {
paramValues.put(PROP_IN, ParameterIn.HEADER.toString());
Expand Down Expand Up @@ -1386,7 +1386,7 @@ private Pair<String, PathItem> readWebhook(@Nullable AnnotationValue<Webhook> we
Operation operation;
HttpMethod method;
if (operationAnn != null) {
operation = toValue(operationAnn.getValues(), context, Operation.class, null);
operation = toValue(operationAnn.getAnnotationName(), operationAnn.getValues(), context, Operation.class, null);
method = HttpMethod.parse(operationAnn.stringValue(PROP_METHOD).orElse(httpMethod.name()));
} else {
operation = new Operation();
Expand All @@ -1402,7 +1402,7 @@ private Map<PathItem, Operation> readOperations(String path, HttpMethod httpMeth
var operationAnn = element.findAnnotation(io.swagger.v3.oas.annotations.Operation.class).orElse(null);

for (PathItem pathItem : pathItems) {
var swaggerOperation = operationAnn != null ? toValue(operationAnn.getValues(), context, Operation.class, jsonViewClass) : null;
var swaggerOperation = operationAnn != null ? toValue(operationAnn.getAnnotationName(), operationAnn.getValues(), context, Operation.class, jsonViewClass) : null;
if (swaggerOperation == null) {
swaggerOperation = new Operation();
}
Expand Down Expand Up @@ -1568,7 +1568,7 @@ private ExternalDocumentation readExternalDocs(MethodElement element, VisitorCon
if (externalDocsAnn == null) {
return null;
}
return toValue(externalDocsAnn.getValues(), context, ExternalDocumentation.class, null);
return toValue(externalDocsAnn.getAnnotationName(), externalDocsAnn.getValues(), context, ExternalDocumentation.class, null);
}

private void readSecurityRequirements(MethodElement element, String path, Operation operation, VisitorContext context) {
Expand Down Expand Up @@ -1743,7 +1743,7 @@ private void processResponses(Operation operation,
if (apiResponses.containsKey(responseCode)) {
continue;
}
ApiResponse newApiResponse = toValue(responseAnn.getValues(), context, ApiResponse.class, jsonViewClass);
ApiResponse newApiResponse = toValue(responseAnn.getAnnotationName(), responseAnn.getValues(), context, ApiResponse.class, jsonViewClass);
if (newApiResponse != null) {
if (responseAnn.booleanValue("useReturnTypeSchema").orElse(false) && element != null) {
addResponseContent(element, context, Utils.resolveOpenApi(context), newApiResponse, jsonViewClass);
Expand Down Expand Up @@ -1811,7 +1811,7 @@ private Pair<RequestBody, Boolean> readSwaggerRequestBody(Element element, List<

var jsonViewClass = element instanceof ParameterElement ? getJsonViewClass(element, context) : null;

RequestBody requestBody = toValue(requestBodyAnn.getValues(), context, RequestBody.class, jsonViewClass);
RequestBody requestBody = toValue(requestBodyAnn.getAnnotationName(), requestBodyAnn.getValues(), context, RequestBody.class, jsonViewClass);
// if media type doesn't set in swagger annotation, check micronaut annotation
if (contentAnn != null
&& contentAnn.stringValue(PROP_MEDIA_TYPE).isEmpty()
Expand Down Expand Up @@ -1886,7 +1886,7 @@ private void processUrlCallbackExpression(VisitorContext context,
if (httpMethod == null) {
continue;
}
var op = toValue(operationAnn.getValues(), context, Operation.class, jsonViewClass);
var op = toValue(operationAnn.getAnnotationName(), operationAnn.getValues(), context, Operation.class, jsonViewClass);
if (op != null) {
setOperationOnPathItem(pathItem, httpMethod, op);
}
Expand Down Expand Up @@ -2122,7 +2122,7 @@ private List<Tag> readTags(ClassElement element, VisitorContext context) {
final List<Tag> readTags(List<AnnotationValue<io.swagger.v3.oas.annotations.tags.Tag>> tagAnns, VisitorContext context) {
var tags = new ArrayList<Tag>();
for (var tagAnn : tagAnns) {
var tag = toValue(tagAnn.getValues(), context, Tag.class, null);
var tag = toValue(tagAnn.getAnnotationName(), tagAnn.getValues(), context, Tag.class, null);
if (tag != null) {
tags.add(tag);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ protected <T, A extends Annotation> List<T> processOpenApiAnnotation(Element ele
} else {
values = tagValues;
}
T tagObj = toValue(values, context, modelType, null);
T tagObj = toValue(tag.getAnnotationName(), values, context, modelType, null);
if (tagObj != null) {
// skip all existed tags
boolean alreadyExists = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ private OpenAPI readOpenApi(ClassElement element, VisitorContext context) {
return openApi;
}

var openApi = toValue(openApiDefAnn.getValues(), context, OpenAPI.class, null);
var openApi = toValue(openApiDefAnn.getAnnotationName(), openApiDefAnn.getValues(), context, OpenAPI.class, null);
if (openApi == null) {
openApi = new OpenAPI();
}
Expand Down
Loading

0 comments on commit b96d021

Please sign in to comment.