Package io.muserver.openapi
Class ResponseObjectBuilder
- java.lang.Object
-
- io.muserver.openapi.ResponseObjectBuilder
-
public class ResponseObjectBuilder extends java.lang.Object
Describes a single response from an API Operation, including design-time, static
links
to operations based on the response.
-
-
Constructor Summary
Constructors Constructor Description ResponseObjectBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ResponseObject
build()
static ResponseObjectBuilder
mergeResponses(ResponseObject primary, ResponseObject secondary)
Creates a new build by merging two existing response objectsstatic ResponseObjectBuilder
responseObject()
Creates a builder for aResponseObject
ResponseObjectBuilder
withContent(java.util.Map<java.lang.String,MediaTypeObject> content)
ResponseObjectBuilder
withDescription(java.lang.String description)
ResponseObjectBuilder
withHeaders(java.util.Map<java.lang.String,HeaderObject> headers)
ResponseObjectBuilder
withLinks(java.util.Map<java.lang.String,LinkObject> links)
-
-
-
Method Detail
-
withDescription
public ResponseObjectBuilder withDescription(java.lang.String description)
- Parameters:
description
- REQUIRED. A short description of the response. CommonMark syntax MAY be used for rich text representation.- Returns:
- The current builder
-
withHeaders
public ResponseObjectBuilder withHeaders(java.util.Map<java.lang.String,HeaderObject> headers)
- Parameters:
headers
- Maps a header name to its definition. RFC7230 states header names are case insensitive. If a response header is defined with the name"Content-Type"
, it SHALL be ignored.- Returns:
- The current builder
-
withContent
public ResponseObjectBuilder withContent(java.util.Map<java.lang.String,MediaTypeObject> content)
- Parameters:
content
- A map containing descriptions of potential response payloads. The key is a media type or media type range and the value describes it. For responses that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/*- Returns:
- The current builder
-
withLinks
public ResponseObjectBuilder withLinks(java.util.Map<java.lang.String,LinkObject> links)
- Parameters:
links
- A map of operations links that can be followed from the response.- Returns:
- The current builder
-
build
public ResponseObject build()
- Returns:
- A new object
-
responseObject
public static ResponseObjectBuilder responseObject()
Creates a builder for aResponseObject
- Returns:
- A new builder
-
mergeResponses
public static ResponseObjectBuilder mergeResponses(ResponseObject primary, ResponseObject secondary)
Creates a new build by merging two existing response objects- Parameters:
primary
- A responses object to use. This is the dominant response who's values will be preferred when values cannot be merged (such asResponseObject.description
secondary
- The other responses object- Returns:
- A builder that is the merged value of the two given ones
-
-