github.com/kaisawind/go-swagger@v0.19.0/docs/use/spec/allOf.md (about)

     1  # swagger:allOf
     2  
     3  Marks an embedded type as  a member for allOf
     4  
     5  <!--more-->
     6  
     7  ##### Syntax:
     8  
     9  ```
    10  swagger:allOf
    11  ```
    12  
    13  ##### Example:
    14  
    15  ```go
    16  // A SimpleOne is a model with a few simple fields
    17  type SimpleOne struct {
    18  	ID   int64  `json:"id"`
    19  	Name string `json:"name"`
    20  	Age  int32  `json:"age"`
    21  }
    22  
    23  // A Something struct is used by other structs
    24  type Something struct {
    25  	DID int64  `json:"did"`
    26  	Cat string `json:"cat"`
    27  }
    28  
    29  // Notable is a model in a transitive package.
    30  // it's used for embedding in another model
    31  //
    32  // swagger:model withNotes
    33  type Notable struct {
    34  	Notes string `json:"notes"`
    35  
    36  	Extra string `json:"extra"`
    37  }
    38  
    39  // An AllOfModel is composed out of embedded structs but it should build
    40  // an allOf property
    41  type AllOfModel struct {
    42  	// swagger:allOf
    43  	SimpleOne
    44  	// swagger:allOf
    45  	mods.Notable
    46  
    47  	Something // not annotated with anything, so should be included
    48  
    49  	CreatedAt strfmt.DateTime `json:"createdAt"`
    50  }
    51  ```
    52  
    53  ##### Result:
    54  
    55  ```yaml
    56  ---
    57  definitions:
    58    SimpleOne:
    59      title: A SimpleOne is a model with a few simple fields
    60      type: object
    61      properties:
    62        id:
    63          type: integer
    64          format: int64
    65        name:
    66          type: string
    67        age:
    68          type: integer
    69          format: int32
    70    Notable:
    71      title: "Notable is a model in a transitive package.\nit's used for embedding in another model"
    72      type: object
    73      properties:
    74        notes:
    75          type: string
    76        extra:
    77          type: string
    78    AllOfModel:
    79      title: "An AllOfModel is composed out of embedded structs but it should build\nan allOf property"
    80      allOf: 
    81        - $ref: "#/definitions/SimpleOne"
    82        - $ref: "#/definitions/Notable"
    83        - title: A Something struct is used by other structs
    84          type: object
    85          properties:
    86            did:
    87              type: integer
    88              format: int64
    89            cat:
    90              type: string
    91        - type: object
    92          properties:
    93            createdAt:
    94              type: string
    95              format: date-time
    96  ```