type: object
properties:
  id:
    type: string
    description: This stub mapping's unique identifier
  uuid:
    type: string
    description: Alias for the id
  name:
    type: string
    description: The stub mapping's name
  request:
    $ref: 'request-pattern.yaml'
  response:
    $ref: "response-definition.yaml"
  persistent:
    type: boolean
    description: Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default.
  priority:
    type: integer
    description: This stub mapping's priority relative to others. 1 is highest.
    minimum: 1
  scenarioName:
    type: string
    description: The name of the scenario that this stub mapping is part of
  requiredScenarioState:
    type: string
    description: The required state of the scenario in order for this stub to be matched.
  newScenarioState:
    type: string
    description: The new state for the scenario to be updated to after this stub is served.
  postServeActions:
    type: object
    description: A map of the names of post serve action extensions to trigger and their parameters.
  serveEventListeners:
    type: array
    description: The list of serve event listeners
    items:
      oneOf:
        - title: Dynamic State Operations
          description: Operations to alter the state of your mock API. More information on this feature can be found [here](../../dynamic-state/overview).
          type: object
          properties:
            name:
              type: string
              enum: ["change-state"]
            parameters:
              type: object
              properties:
                operations:
                  description: |
                    A set of state related operations to perform when the stub is matched.
                    Each operation can be one of the following type, dictated by the `operation` property:
                    * `SET` - set the value of a state item in the state cache.
                    * `DELETE` - delete a state item from the state cache.
                    * `DELETE_CONTEXT` - delete all state items within a context from the state cache.
                    * `REQUEST_VAR` - set a variable that will be available for the lifetime of the request.
                  type: array
                  items:
                    allOf:
                      - type: object
                        properties:
                          operation:
                            description: The operation to perform.
                            type: string
                            enum: [SET, DELETE, DELETE_CONTEXT, REQUEST_VAR]
                        required:
                          - operation
                      - oneOf:
                          - title: SET
                            type: object
                            properties:
                              operation:
                                enum: [ SET ]
                              context:
                                description: The context of the item to set the value of. Can be templated.
                                type: string
                              key:
                                description: The key of the item to set the value of. Can be templated.
                                type: string
                              value:
                                description: The value to set the item to. Can be templated.
                                type: string
                            required:
                              - context
                              - key
                              - value
                          - title: DELETE
                            type: object
                            properties:
                              operation:
                                enum: [ DELETE ]
                              context:
                                description: The context of the item to delete. Can be templated.
                                type: string
                              key:
                                description: The key of the item to delete. Can be templated.
                                type: string
                            required:
                              - context
                              - key
                          - title: DELETE_CONTEXT
                            type: object
                            properties:
                              operation:
                                enum: [ DELETE_CONTEXT ]
                              context:
                                description: The context to delete. Can be templated.
                                type: string
                            required:
                              - context
                          - title: REQUEST_VAR
                            type: object
                            properties:
                              operation:
                                enum: [ REQUEST_VAR ]
                              key:
                                description: The key of the variable to create. Cannot be templated.
                                type: string
                              value:
                                description: The value to set the variable to. Can be templated.
                                type: string
                            required:
                              - key
                              - value
              required:
                - operations
  metadata:
    type: object
    description: Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs.
additionalProperties: false
