All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.muserver.openapi.RequestBodyObjectBuilder Maven / Gradle / Ivy

There is a newer version: 2.0.3
Show newest version
package io.muserver.openapi;

import java.util.Map;

/**
 * Describes a single request body.
 */
public class RequestBodyObjectBuilder {
    private String description;
    private Map content;
    private boolean required;

    /**
     * @param description A brief description of the request body. This could contain examples of use.
     *                    CommonMark syntax MAY be used for rich text representation.
     * @return The current builder
     */
    public RequestBodyObjectBuilder withDescription(String description) {
        this.description = description;
        return this;
    }

    /**
     * @param content REQUIRED. The content of the request body. The key is a media type or
     *                media type range and the value describes it.
     *                For requests that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/*
     * @return The current builder
     */
    public RequestBodyObjectBuilder withContent(Map content) {
        this.content = content;
        return this;
    }

    /**
     * @param required Determines if the request body is required in the request. Defaults to false.
     * @return The current builder
     */
    public RequestBodyObjectBuilder withRequired(boolean required) {
        this.required = required;
        return this;
    }

    public RequestBodyObject build() {
        return new RequestBodyObject(description, content, required);
    }

    /**
     * Creates a builder for a {@link RequestBodyObject}
     *
     * @return A new builder
     */
    public static RequestBodyObjectBuilder requestBodyObject() {
        return new RequestBodyObjectBuilder();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy