Skip to content

Instantly share code, notes, and snippets.

@leonardehrenfried
Created July 3, 2018 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leonardehrenfried/6615e92e818e3f7b22690db7ad237137 to your computer and use it in GitHub Desktop.
Save leonardehrenfried/6615e92e818e3f7b22690db7ad237137 to your computer and use it in GitHub Desktop.
x-discriminator reproduction case
Transaction:
type: object
properties:
id:
type: string
example: A11234
pattern: '[A-Z][0-9]{1,32}'
readOnly: true
account_id:
type: string
example: 05a2106b-92a4-4ee3-a6a3-c32f8b609de1
format: uuid
readOnly: true
operation_type:
type: string
enum:
- payment
- refund
example: payment
payment_method:
$ref: '#/PaymentMethod'
PaymentMethod:
type: object
x-discriminator:
propertyName: type
mapping:
visa: "#/paymentMethodVisa"
mastercard: "#/paymentMethodMastercard"
amex: "#/paymentMethodAmex"
properties:
type:
description: The type of Payment Method used for Transaction
type: string
paymentMethodVisa:
description: A visa
allOf:
- $ref: '#/PaymentMethod'
- properties:
prop1:
type: string
description: A custom prop
enum:
- type1
- type2
- properties:
type:
type: string
enum:
- visa
paymentMethodMastercard:
description: A mastercard
allOf:
- $ref: '#/PaymentMethod'
- properties:
prop1:
type: string
description: A custom prop
enum:
- type3
- type4
- properties:
type:
type: string
enum:
- mastercard
paymentMethodAmex:
description: A amex
allOf:
- $ref: '#/PaymentMethod'
- properties:
prop1:
type: string
description: A custom prop
enum:
- type5
- properties:
type:
type: string
enum:
- amex
swagger: '2.0'
info:
version: 1.0.0
title: Test API
host: test.api.int.com
basePath: /v2
schemes:
- https
securityDefinitions:
basic:
type: basic
consumes:
- application/json
produces:
- application/json
paths:
'/transactions/{id}':
get:
summary: Get a transaction by ID
description: Get a `Transaction` object by ID
parameters:
- name: id
in: path
description: The transaction ID
required: true
type: string
format: uuid
responses:
'200':
description: The Transaction
schema:
$ref: 'defs.yml#/Transaction'
parameters:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment