io.muserver.openapi.HeaderObjectBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mu-server Show documentation
Show all versions of mu-server Show documentation
A simple but powerful web server framework
package io.muserver.openapi;
import java.util.Map;
public class HeaderObjectBuilder {
private String description;
private boolean required;
private boolean deprecated;
private String style;
private String explode;
private SchemaObject schema;
private Object example;
private Map examples;
private Map content;
/**
* @param description A brief description of the header. This could contain examples of use.
* CommonMark syntax MAY be used for rich text representation.
* @return The current builder
*/
public HeaderObjectBuilder withDescription(String description) {
this.description = description;
return this;
}
/**
* @param required Determines whether this header is mandatory. The default value is false
.
* @return The current builder
*/
public HeaderObjectBuilder withRequired(boolean required) {
this.required = required;
return this;
}
/**
* @param deprecated Specifies that a header is deprecated and SHOULD be transitioned out of usage.
* @return The current builder
*/
public HeaderObjectBuilder withDeprecated(boolean deprecated) {
this.deprecated = deprecated;
return this;
}
/**
* @param style Describes how the parameter value will be serialized depending on the type of the parameter value.
* Default value is simple
.
* In order to support common ways of serializing simple parameters, a set of style
values are defined.
*
*
*
* style
* type
* Comments
*
*
*
*
* simple
* array
* Simple style parameters defined by RFC6570. This option replaces collectionFormat
with a csv
value from OpenAPI 2.0.
*
*
*
* @return The current builder
*/
public HeaderObjectBuilder withStyle(String style) {
this.style = style;
return this;
}
/**
* @param explode When this is true, parameter values of type array
or object
generate
* separate parameters for each value of the array or key-value pair of the map. For other types
* of parameters this property has no effect. When style
is form
, the
* default value is true
. For all other styles, the default value is false
.
* @return The current builder
*/
public HeaderObjectBuilder withExplode(String explode) {
this.explode = explode;
return this;
}
/**
* @param schema The schema defining the type used for the header.
* @return The current builder
*/
public HeaderObjectBuilder withSchema(SchemaObject schema) {
this.schema = schema;
return this;
}
/**
* @param example Example of the media type. The example SHOULD match the specified schema and encoding properties
* if present. The example
field is mutually exclusive of the examples
* field. Furthermore, if referencing a schema
which contains an example, the
* example
value SHALL override the example provided by the schema.
* To represent examples of media types that cannot naturally be represented in JSON or YAML,
* a string value can contain the example with escaping where necessary.
* @return The current builder
*/
public HeaderObjectBuilder withExample(Object example) {
this.example = example;
return this;
}
/**
* @param examples Examples of the media type. Each example SHOULD contain a value in the correct format as
* specified in the parameter encoding. The examples
field is mutually exclusive
* of the example
field. Furthermore, if referencing a schema
which
* contains an example, the examples
value SHALL override the example
* provided by the schema.
* @return The current builder
*/
public HeaderObjectBuilder withExamples(Map examples) {
this.examples = examples;
return this;
}
/**
* @param content A map containing the representations for the parameter. The key is the media type and the value describes it.
* The map MUST only contain one entry.
* @return The current builder
*/
public HeaderObjectBuilder withContent(Map content) {
this.content = content;
return this;
}
public HeaderObject build() {
return new HeaderObject(description, required, deprecated, style, explode, schema, example, examples, content);
}
/**
* Creates a builder for a {@link HeaderObject}
*
* @return A new builder
*/
public static HeaderObjectBuilder headerObject() {
return new HeaderObjectBuilder();
}
}