Package org.eclipse.microprofile.openapi.models.media

# Interface MediaType

All Superinterfaces:
  `Constructible`, `Extensible<MediaType>`

public interface MediaType extends Constructible, Extensible<MediaType>
MediaType

Each Media Type Object provides a schema and examples for the media type identified by its key.

See Also:
  - OpenAPI Specification Media Type Object

## Method Summary

Modifier and Type
Method
Description
`MediaType`
`addEncoding(String key, Encoding encodingItem)`
Adds an Encoding item to the encoding property of a MediaType instance.
`MediaType`
`addExample(String key, Example example)`
Adds an example item to the examples map of a MediaType instance.
`default MediaType`
`encoding(Map<String,Encoding> encoding)`
Sets encoding property of a MediaType instance to the given map object.
`default MediaType`
`example(Object example)`
Sets the example property of a MediaType instance to the given value.
`default MediaType`
`examples(Map<String,Example> examples)`
Sets the examples field of a MediaType instance to the given map object.
`Map<String,Encoding>`
`getEncoding()`
Returns the encoding property from a MediaType instance.
`Object`
`getExample()`
Returns the example property from a MediaType instance.
`Map<String,Example>`
`getExamples()`
Returns the collection of examples from a MediaType instance.
`Schema`
`getSchema()`
Returns the schema property from a MediaType instance.
`void`
`removeEncoding(String key)`
Removes an Encoding item to the encoding property of a MediaType instance.
`void`
`removeExample(String key)`
Removes an example item to the examples map of a MediaType instance.
`default MediaType`
`schema(Schema schema)`
Sets the schema field of a MediaType instance to the given schema object.
`void`
`setEncoding(Map<String,Encoding> encoding)`
Sets encoding property of a MediaType instance to the given map object.
`void`
`setExample(Object example)`
Sets the example property of a MediaType instance to the given value.
`void`
`setExamples(Map<String,Example> examples)`
Sets the examples field of a MediaType instance to the given map object.
`void`
`setSchema(Schema schema)`
Sets the schema field of a MediaType instance to the given schema object.

### Methods inherited from interface org.eclipse.microprofile.openapi.models.Extensible

`addExtension, extensions, getExtensions, removeExtension, setExtensions`

## Method Details

### getSchema

Schema getSchema()
Returns the schema property from a MediaType instance.

Returns:
  the schema defining the type used for the request body

### setSchema

void setSchema(Schema schema)
Sets the schema field of a MediaType instance to the given schema object.

Parameters:
  `schema` - the schema defining the type used for the request body

### schema

default MediaType schema(Schema schema)
Sets the schema field of a MediaType instance to the given schema object.

Parameters:
  `schema` - the schema defining the type used for the request body
Returns:
  the current MediaType instance

### getExamples

Map<String,Example> getExamples()
Returns the collection of examples from a MediaType instance.

Returns:
  a copy Map (potentially immutable) of examples of the media type

### setExamples

void setExamples(Map<String,Example> examples)
Sets the examples field of a MediaType instance to the given map object. Each example object should match the media type and specified schema if present. The example object is mutually exclusive of the examples object.

Parameters:
  `examples` - examples of the media type

### examples

default MediaType examples(Map<String,Example> examples)
Sets the examples field of a MediaType instance to the given map object. Each example object should match the media type and specified schema if present. The example object is mutually exclusive of the examples object.

Parameters:
  `examples` - examples of the media type
Returns:
  the current MediaType instance

### addExample

MediaType addExample(String key, Example example)
Adds an example item to the examples map of a MediaType instance. The example object should match the media type and specified schema if present.

Parameters:
  `key` - any unique name to identify the example object
  `example` - an example of a media type. null values will be rejected (implementation will throw an exception) or ignored.
Returns:
  the current MediaType instance

### removeExample

void removeExample(String key)
Removes an example item to the examples map of a MediaType instance. The example object should match the media type and specified schema if present.

Parameters:
  `key` - any unique name to identify the example object

### getExample

Object getExample()
Returns the example property from a MediaType instance.

Returns:
  an example of the media type

### setExample

void setExample(Object example)
Sets the example property of a MediaType instance to the given value. The example object should be in the correct format as specified by the media type. The example object is mutually exclusive of the examples object.

Parameters:
  `example` - an example of the media type

### example

default MediaType example(Object example)
Sets the example property of a MediaType instance to the given value. The example object should be in the correct format as specified by the media type. The example object is mutually exclusive of the examples object.

Parameters:
  `example` - an example of the media type
Returns:
  the current MediaType instance

### getEncoding

Map<String,Encoding> getEncoding()
Returns the encoding property from a MediaType instance.

Returns:
  a copy Map (potentially immutable) between a property name and its encoding information

### setEncoding

void setEncoding(Map<String,Encoding> encoding)
Sets encoding property of a MediaType instance to the given map object.

Parameters:
  `encoding` - a map between property names and their encoding information

### encoding

default MediaType encoding(Map<String,Encoding> encoding)
Sets encoding property of a MediaType instance to the given map object.

Parameters:
  `encoding` - a map between property names and their encoding information
Returns:
  the current MediaType instance

### addEncoding

MediaType addEncoding(String key, Encoding encodingItem)
Adds an Encoding item to the encoding property of a MediaType instance.

Parameters:
  `key` - a property name in the schema
  `encodingItem` - an encoding definition to apply to the schema property. null values will be rejected (implementation will throw an exception) or ignored.
Returns:
  the current MediaType instance

### removeEncoding

void removeEncoding(String key)
Removes an Encoding item to the encoding property of a MediaType instance.

Parameters:
  `key` - a property name in the schema