io.muserver.openapi.ResponsesObjectBuilder 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;
/**
* A container for the expected responses of an operation. The container maps a HTTP response code to the expected response.
* The documentation is not necessarily expected to cover all possible HTTP response codes because they may not be known
* in advance. However, documentation is expected to cover a successful operation response and any known errors.
* The default
MAY be used as a default response object for all HTTP codes that are not covered
* individually by the specification.
* The Responses Object
MUST contain at least one response code, and it SHOULD be the response for a
* successful operation call.
*/
public class ResponsesObjectBuilder {
private ResponseObject defaultValue;
private Map httpStatusCodes;
/**
* @param defaultValue The documentation of responses other than the ones declared for specific HTTP response codes.
* Use this field to cover undeclared responses.
* @return The current builder
*/
public ResponsesObjectBuilder withDefaultValue(ResponseObject defaultValue) {
this.defaultValue = defaultValue;
return this;
}
/**
* @param httpStatusCodes To define a range of response codes, this field MAY contain the uppercase wildcard character
* X
. For example, 2XX
represents all response codes between
* [200-299]
. The following range definitions are allowed: 1XX
,
* 2XX
, 3XX
, 4XX
, and 5XX
. If a response
* range is defined using an explicit code, the explicit code definition takes precedence over
* the range definition for that code.
* @return The current builder
*/
public ResponsesObjectBuilder withHttpStatusCodes(Map httpStatusCodes) {
this.httpStatusCodes = httpStatusCodes;
return this;
}
public ResponsesObject build() {
return new ResponsesObject(defaultValue, httpStatusCodes);
}
/**
* Creates a builder for a {@link ResponsesObject}
*
* @return A new builder
*/
public static ResponsesObjectBuilder responsesObject() {
return new ResponsesObjectBuilder();
}
}