Skip to content

Commit

Permalink
GH-229 Example usage of OpenApiRequired
Browse files Browse the repository at this point in the history
  • Loading branch information
dzikoysk committed Sep 4, 2024
1 parent a8dbbc5 commit 3d15957
Showing 1 changed file with 10 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,7 @@
import io.javalin.Javalin;
import io.javalin.http.Context;
import io.javalin.http.Handler;
import io.javalin.openapi.Custom;
import io.javalin.openapi.CustomAnnotation;
import io.javalin.openapi.HttpMethod;
import io.javalin.openapi.JsonSchema;
import io.javalin.openapi.JsonSchemaLoader;
import io.javalin.openapi.JsonSchemaResource;
import io.javalin.openapi.OneOf;
import io.javalin.openapi.OpenApi;
import io.javalin.openapi.OpenApiArrayValidation;
import io.javalin.openapi.OpenApiByFields;
import io.javalin.openapi.OpenApiCallback;
import io.javalin.openapi.OpenApiContent;
import io.javalin.openapi.OpenApiContentProperty;
import io.javalin.openapi.OpenApiDescription;
import io.javalin.openapi.OpenApiExample;
import io.javalin.openapi.OpenApiExampleProperty;
import io.javalin.openapi.OpenApiIgnore;
import io.javalin.openapi.OpenApiName;
import io.javalin.openapi.OpenApiNumberValidation;
import io.javalin.openapi.OpenApiObjectValidation;
import io.javalin.openapi.OpenApiParam;
import io.javalin.openapi.OpenApiPropertyType;
import io.javalin.openapi.OpenApiRequestBody;
import io.javalin.openapi.OpenApiResponse;
import io.javalin.openapi.OpenApiSecurity;
import io.javalin.openapi.OpenApiStringValidation;
import io.javalin.openapi.Visibility;
import io.javalin.openapi.*;
import io.javalin.openapi.plugin.OpenApiPlugin;
import io.javalin.openapi.plugin.redoc.ReDocPlugin;
import io.javalin.openapi.plugin.swagger.SwaggerPlugin;
Expand All @@ -57,6 +31,7 @@
/**
* Starts Javalin server with OpenAPI plugin
*/
@SuppressWarnings({"unused", "LombokGetterMayBeUsed", "LombokSetterMayBeUsed", "ProtectedMemberInFinalClass", "InnerClassMayBeStatic"})
public final class JavalinTest implements Handler {

enum Rules implements RouteRole {
Expand Down Expand Up @@ -420,6 +395,12 @@ public static String getStatic() {
return "static";
}

// by default nullable fields are not required, but we can force it
@OpenApiRequired
public String getNullableIsRequired() {
return "required";
}

}

static final class Foo {
Expand Down Expand Up @@ -498,9 +479,10 @@ public String getName() {

}

@JsonSchema
@JsonSchema(requireNonNulls = false)
static final class JsonSchemaEntity {

@OpenApiRequired
public List<EntityDto> getEntities() {
return Collections.emptyList();
}
Expand Down

0 comments on commit 3d15957

Please sign in to comment.