Как дать Список объекта и другого объекта как ответ API - PullRequest
0 голосов
/ 04 июля 2019

Я хочу написать спецификации openapi для API, которые будут возвращать ответ в виде набора объекта или другого объекта.Я не уверен, как мне добиться того, что я пробовал много вещей, но когда я запускаю codegen для спецификаций, я получаю класс OneOfConnectionDTOConnectionPaginatedResponseDTO с ошибкой.

Я использую приведенный ниже код, и я хочу, чтобы Set или ConnectionPaginatedResponseDTO в 200ответ

openapi: 3.0.0
servers:
  - url: /
info:
  title: OIM Manage Connection
  version: '1.0'
paths:
  '/ManageConnection/viewUserConnection/{oimid}':
    get:
      tags:
        - View Connection
      parameters:
        - description: OIMID of user
          in: path
          name: oimid
          required: true
          schema:
            type: string
            example: 1234
        - description: content type
          in: header
          name: Content-Type
          required: true
          schema:
            type: string
            example: application/json
        - description: Start Index of records to be fetched
          in: query
          name: startIndex
          required: false
          schema:
            type: string
            example: 1
        - description: Start Index of records to be fetched
          in: query
          name: count
          required: false
          schema:
            type: string
            example: 5
      responses:
        '200':
          description: Connection list returned
          content:
            application/json:
              schema:
                oneOf:
                - $ref: '#/components/schemas/ConnectionDTO'
                - $ref: '#/components/schemas/ConnectionPaginatedResponseDTO'
        '401':
          $ref: '#/components/responses/UnAuthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '500':
          $ref: '#/components/responses/DataBaseError'
        '501':
          $ref: '#/components/responses/MethodError'
components:
  responses:
    UnAuthorized:
      description: Not authorized to access the specified resource
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/OIMException'
    MandatoryAttributeNotPassedException:
      description: Requested resource can't be accessed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/OIMException'
    Forbidden:
      description: Requested resource can't be accessed
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/OIMException'
    DataBaseError:
      description: Unable to connect to database
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/OIMException'
    MethodError:
      description: Method not implemented
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/OIMException'
  schemas:
    ConnectionDTO:
      required:
        - access_type
        - access_identifier
      properties:
        add_access_date:
          type: string
          format: date
        access_identifier:
          type: string
        access_type:
          type: string
        PIN:
          type: string
        is_primary_access:
          type: string
        valid_state:
          type: string
        friendly_name:
          type: string
        oimid:
          type: string
        auth_count:
          type: string
      type: object
    ConnectionPaginatedResponseDTO:
      properties:
        totalResults:
          type: integer
        itemsPerPage:
          type: integer
        startIndex:
          type: integer
        connections:
          $ref: '#/components/schemas/ConnectionDTO'
      type: object

    OIMException:
      properties:
        errorMessage:
          type: array
          items:
            type: string
        message:
          type: string
        httpStatus:
          type: string
        code:
          type: integer
      type: object

...