Swagger 3.0架构错误“不应该有其他属性”

时间:2018-01-16 14:43:28

标签: validation yaml swagger-editor openapi

下面的错误是什么意思? (在Swagger编辑器中运行)

  

架构错误不应该有其他属性additionalProperty:   / buildinfo,/ clearcache,   /国家/ {} countryId /影院/ {} theatreid /屏幕/ {} screenid /布局,   / countries / {countryId} / cinemas / {theatreid} / screens跳转到第0行

以下是我的yaml文件。

openapi: "3.0.1"
info:
  title: Mobile backend
  version: 1.0.0
  license:
    name: Apache 2.0
paths:
/buildinfo:
    get:
      description: Returns the build information (Version and Time stamp).
      operationId: getBuildInfo
      parameters:
        - name: LBPATH
          in: header
/clearcache:
    get:
      description: Clears the mobile backends cache (You need to be Admin to do this call)
      operationId: clearCache
      parameters:
        - name: LBPATH
          in: header
/countries/{countryId}/cinemas/{theatreid}/screens/{screenid}/layout:
    get:
      description: Returns a list of Auditoriums that is currently running in a specific city. Ordered by movie name in ascending order.
      operationId: getScreenLayout
      parameters:
        - name: theatreid
          in: path
        - name: screenid
          in: path
        - name: seatwidth
          in: query
        - name: seatheight
          in: query
        - name: Accept-Language
          in: header
        - name: LBPATH
          in: header
/countries/{countryId}/cinemas/{theatreid}/screens:
    get:
      description: Returns a list of Auditoriums that is currently running in a specific city. Ordered by movie name in ascending order.
      operationId: getAuditoriumsInTheatre
      parameters:
        - name: theatreid
          in: path
        - name: Accept-Language
          in: header
        - name: LBPATH
          in: header
components:
  schemas:
    ProfileNotifications:
      properties:
        iWantEmails:
          type: boolean
        iWantSMS:
          type: boolean
        iWantPushNotifications:
          type: boolean
    OfferActivateRequest:
      properties:
        offerId:
          type: int64
        osType:
          $ref: '#/components/schemas/OSType'
        mobileId:
          type: string
        activationDate:
          type: date
    Customer:
      properties:
        type:
          $ref: '#/components/schemas/TicketType'
        count:
          type: int32
    Profile$ProfileStatus:
      properties:
    Booking:
      properties:
        profileId:
          type: string
        remoteEntityIds:
          type: array
          items:
            string
        customers:
          type: array
          items:
            $ref: '#/components/schemas/Customer'
        showId:
          type: string
        seatsUnnumberedCount:
          type: int32
    ProfileFriend:
      properties:
        name:
          type: string
        profileReferenceCode:
          type: string
    OfferConsumeRequest:
      properties:
        offerId:
          type: int64
        osType:
          $ref: '#/components/schemas/OSType'
        mobileId:
          type: string
    Profile:
      properties:
        language:
          type: string
        children:
          type: array
          items:
            int32
        city:
          type: string
        memberSince:
          type: date
        status:
          $ref: '#/components/schemas/Profile$ProfileStatus'
        firstName:
          type: string
        lastName:
          type: string
        phonenumber:
          type: string
        socialSecurityNumber:
          type: string
        acceptedTermsAndConditionsOn:
          type: date
        acceptedGeneralDataProtectionRegulationOn:
          type: date
        profileId:
          type: string
        currentLevelId:
          type: string
        aztecCode:
          type: string
        allowSfBioToSendNewsletters:
          type: boolean
        favoriteMovies:
          type: array
          items:
            string
        spendingPointsWillExpire:
          type: array
          items:
            $ref: '#/components/schemas/SpendingPoint'
        friends:
          type: array
          items:
            $ref: '#/components/schemas/ProfileFriend'
        userEmail:
          type: string
        providerId:
          type: int32
        providerToken:
          type: string
        memberNumber:
          type: string
        userHasVerifiedThisAccount:
          type: boolean
        loyaltyLevelId:
          type: string
        loyaltyLevelName:
          type: string
        loyaltyLevelSince:
          type: date
        loyaltyLevelExpiration:
          type: date
        loyaltyPointsAvailableForSpending:
          type: int32
        loyaltyMoviesLeftToTheNextLevel:
          type: int32
        loyaltyPointsLeftToTheNextLevel:
          type: int32
        loyaltyPointsLevelToGetGoldMember:
          type: int32
        loyaltyMovieLevelToGetGoldMember:
          type: int32
        loyaltySpendingPointsExpireDate:
          type: date
        loyaltySpendingPointsExpireAmount:
          type: int32
        oldClubCardNumber:
          type: string
        loyaltyEndDate:
          type: date
    CardType$Type:
      properties:
        purchaseCard:
          type: boolean
    Card:
      properties:
        type:
          $ref: '#/components/schemas/CardType$Type'
        number:
          type: string
        requestedAmount:
          type: int32
        deductedAmount:
          type: int32
        isUsed:
          type: boolean
        balance:
          type: int32
        errorCode:
          type: int32
    LockSeats:
      properties:
        seatKeys:
          type: array
          items:
            $ref: '#/components/schemas/SeatKey'
        auditoriumSys99Code:
          type: string
        dateTime:
          type: int64
    SeatKey:
      properties:
        seatRow:
          type: int32
        seatSection:
          type: string
        seatId:
          type: int32
    ShowKey:
      properties:
    Payment:
      properties:
        email:
          type: string
        profileId:
          type: string
        serialVersionUID:
          type: int64
        ticketTypes:
          type: array
          items:
            $ref: '#/components/schemas/TicketType'
        easyPayment:
          $ref: '#/components/schemas/EasyPayment'
        reservationPayment:
          type: boolean
        reservationNumber:
          type: string
        cards:
          type: array
          items:
            $ref: '#/components/schemas/Card'
        showKey:
          $ref: '#/components/schemas/ShowKey'
        bookingId:
          type: int32
        redirectUrl:
          type: string
        transactionId:
          type: string
        customers:
          type: array
          items:
            $ref: '#/components/schemas/Customer'
        goggleCount:
          type: int32
        paymentResponseCode:
          type: string
    Reservation:
      properties:
        email:
          type: string
        profileId:
          type: string
        cards:
          type: array
          items:
            $ref: '#/components/schemas/Card'
        bookingId:
          type: int32
        customers:
          type: array
          items:
            $ref: '#/components/schemas/Customer'
        msisdn:
          type: string
        showId:
          type: string
        goggleCount:
          type: int32
        totalFee:
          type: int32
        adultTicketCount:
          type: int32
        childTicketCount:
          type: int32
        pensionerTicketCount:
          type: int32
        plusAndVipTicketCount:
          type: int32
        totalPlusAndVipTicketCost:
          type: int32
    SpendingPoint:
      properties:
        expireDate:
          type: date
        amount:
          type: int32
    ProfileMovies:
      properties:
        movies:
          type: array
          items:
            string
    OSType:
      properties:
    ProfileCinemas:
      properties:
        cinemas:
          type: array
          items:
            string
    LockSeatsUnnumbered:
      properties:
        auditoriumSys99Code:
          type: string
        dateTime:
          type: int64
        nrOfSeats:
          type: int32
    TicketType:
      properties:
    EasyPayment:
      properties:
        panHash:
          type: string
        truncPan:
          type: string
        userAccept:
          type: boolean

1 个答案:

答案 0 :(得分:3)

路径的缩进是错误的:

paths:
/buildinfo: # <-----
    get:

应该是:

paths:
  /buildinfo:
    get:

您的规范还有许多其他错误,例如缺少参数schema,操作中缺少responses,模式中错误type等等。请按照Swagger编辑器中的提示操作修复错误。


  

但我仍然得到错误,我不明白。 &#34;路径上的模式错误&#34; &#34;应该是数组&#34;

     parameters:
       name: LBPATH
       in: header
       schema:
         type: string
         style: simple

parameters是一组参数。在YAML中,数组项的格式为前导-。另外style是参数属性,而不是架构属性。

      parameters:
        - name: LBPATH
          in: header
          schema:
            type: string
          style: simple

要详细了解OpenAPI 3.0语法以及如何设置格式,请查看本指南:https://swagger.io/docs/specification/basic-structure/