Events: type: array minitems: 1 maxitems: 100 items: allOf: - $ref: OfferEvent - $ref: ReferAFriendEvent--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Events:
type: array
minitems: 1
maxitems: 100
items:
$ref: Event
Event:
discriminator: eventname
properties:
eventname:
type: string
required:
- eventname
ReferAFriendEvent:
allOf:
- $ref: Event
properties:
accountId:
type: integer
campaignName:
type: string
OfferEvent:
allOf:
- $ref: Event
properties:
accountId:
type: integer
offerName:
type: stringHope this helps.You can look at this example - https://github.com/swagger-api/swagger-spec/blob/master/fixtures/v2.0/json/models/modelWithComposition.json.Define the top model with the type discriminator and the sub models would inherit from it using `allOf`Swagger doesn't support non-deterministic APIs, which is why 'anyOf' is not supported.However, as long as you have one field that's common between the models, you can use model inheritance.
On 28 November 2014 at 18:33, Jeff Bannister wrote:
Hi,I have a use case where I want to describe using Swagger 2.0 a callback API. This API will POST an array of event objects to the registered callback URLs. Each one of these objects will only have a type name in common e.g. typeA, typeB etc.How would I define this in Swagger?I've tried the following….Events:type: arrayminitems: 1maxitems: 100items:allOf:- $ref: OfferEvent- $ref: ReferAFriendEvent
For the example above the Swagger editor just displays an empty array.Also I feel like a should be using anyOf not allOf (part of the JSON 4 schema - http://json-schema.org/latest/json-schema-validation.html#anchor82). Is there any reason why Swagger doesn't support anyOf - I am supposed to use the discriminator field instead?Regards,Jeff.
--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsubscri...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.