Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set parameter schema base on schema or array of the @Parameter annotation #4665

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,18 @@ public static Parameter applyAnnotations(
if (content.isPresent()) {
parameter.setContent(content.get());
parameter.setSchema(null);
} else {
Class<?> schemaImplementation = p.schema().implementation();
boolean isArray = false;
if (schemaImplementation == Void.class) {
schemaImplementation = p.array().schema().implementation();
if (schemaImplementation != Void.class) {
isArray = true;
}
}
if (p.schema().implementation() != Void.class || isArray) {
AnnotationsUtils.getSchema(p.schema(), p.array(), isArray, schemaImplementation, components, jsonViewAnnotation).ifPresent(parameter::setSchema);
}
}
setParameterStyle(parameter, p);
setParameterExplode(parameter, p);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,17 @@ public class Parameters31Resource {
})
@Consumes({"application/json", "application/xml"})
public Parameters31Resource.SubscriptionResponse subscribe(@Parameter(description = "idParam")
@QueryParam("id") final String id) {
@QueryParam("id") final String id,
@Parameter(schema = @Schema(implementation = SubscriptionType.class))
@QueryParam("enumStringParameter") final String enumStringParameter) {
return null;
}

public static class SubscriptionResponse {
public String subscriptionId;
}

enum SubscriptionType {
EMAIL, SMS, PHONE_CALL
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,17 @@ public class ParametersResource {
})
@Consumes({"application/json", "application/xml"})
public ParametersResource.SubscriptionResponse subscribe(@Parameter(description = "idParam")
@QueryParam("id") final String id) {
@QueryParam("id") final String id,
@Parameter(schema = @Schema(implementation = SubscriptionType.class))
@QueryParam("enumStringParameter") final String enumStringParameter) {
return null;
}

static class SubscriptionResponse {
public String subscriptionId;
}

enum SubscriptionType {
EMAIL, SMS, PHONE_CALL
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,14 @@ paths:
description: idParam
schema:
type: string
- name: enumStringParameter
in: query
schema:
type: string
enum:
- EMAIL
- SMS
- PHONE_CALL
responses:
default:
description: test description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ paths:
description: idParam
schema:
type: string
- name: enumStringParameter
in: query
schema:
type: string
enum:
- EMAIL
- SMS
- PHONE_CALL
responses:
default:
description: test description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,14 @@ paths:
description: idParam
schema:
type: string
- name: enumStringParameter
in: query
schema:
type: string
enum:
- EMAIL
- SMS
- PHONE_CALL
responses:
default:
description: test description
Expand Down
Loading