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

# Interface Discriminator

All Superinterfaces:
  `Constructible`

public interface Discriminator extends Constructible
Discriminator

When request bodies or response payloads may be one of a number of different schemas, a discriminator object can be used to aid in serialization, deserialization, and validation. The discriminator is a specific object in a schema which is used to inform the consumer of the specification of an alternative schema based on the value associated with it.

See Also:
  - OpenAPI Specification Discriminator Object

## Method Summary

Modifier and Type
Method
Description
`Discriminator`
`addMapping(String name, String value)`
Maps the given name to the given value and stores it in this Discriminator's mapping property.
`Map<String,String>`
`getMapping()`
Returns the mapping property from a Discriminator instance.
`String`
`getPropertyName()`
Returns the propertyName property from a Discriminator instance.
`default Discriminator`
`mapping(Map<String,String> mapping)`
Sets this Discriminator's mapping property to the given map object.
`default Discriminator`
`propertyName(String propertyName)`
Sets this Discriminator's propertyName property to the given string.
`void`
`removeMapping(String name)`
Remove the given name to the given value and stores it in this Discriminator's mapping property.
`void`
`setMapping(Map<String,String> mapping)`
Sets this Discriminator's mapping property to the given map object.
`void`
`setPropertyName(String propertyName)`
Sets this Discriminator's propertyName property to the given propertyName.

## Method Details

### propertyName

default Discriminator propertyName(String propertyName)
Sets this Discriminator's propertyName property to the given string.

Parameters:
  `propertyName` - the name of the property in the payload that will hold the discriminator value
Returns:
  the current Discriminator instance

### getPropertyName

String getPropertyName()
Returns the propertyName property from a Discriminator instance.

Returns:
  the name of the property in the payload that will hold the discriminator value

### setPropertyName

void setPropertyName(String propertyName)
Sets this Discriminator's propertyName property to the given propertyName.

Parameters:
  `propertyName` - the name of the property in the payload that will hold the discriminator value

### addMapping

Discriminator addMapping(String name, String value)
Maps the given name to the given value and stores it in this Discriminator's mapping property.

Parameters:
  `name` - a key which will be compared to information from a request body or response payload.
  `value` - a schema name or reference. null values will be rejected (implementation will throw an exception) or ignored.
Returns:
  the current Discriminator instance

### removeMapping

void removeMapping(String name)
Remove the given name to the given value and stores it in this Discriminator's mapping property.

Parameters:
  `name` - a key which will be compared to information from a request body or response payload.

### mapping

default Discriminator mapping(Map<String,String> mapping)
Sets this Discriminator's mapping property to the given map object.

Parameters:
  `mapping` - a map containing keys and schema names or references
Returns:
  the current Discriminator instance

### getMapping

Map<String,String> getMapping()
Returns the mapping property from a Discriminator instance.

Returns:
  a copy Map (potentially immutable) containing keys and schema names or references

### setMapping

void setMapping(Map<String,String> mapping)
Sets this Discriminator's mapping property to the given map object.

Parameters:
  `mapping` - a map containing keys and schema names or references