Swagger 3.0 schema error “should NOT have additional properties”

一世执手 提交于 2019-12-23 01:35:22

问题


What does this error below mean? (Running in Swagger Editor)

Schema error should NOT have additional properties additionalProperty: /buildinfo, /clearcache, /countries/{countryId}/cinemas/{theatreid}/screens/{screenid}/layout, /countries/{countryId}/cinemas/{theatreid}/screens Jump to line 0

Below is my yaml file.

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:


The indentation of paths is wrong:

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

It should be:

paths:
  /buildinfo:
    get:

Your spec also has many other errors, such as missing schema for parameters, missing responses in operations, wrong type values in schemas, etc. Follow the hints in the Swagger Editor to fix the errors.


But I still get error I don't understand. "Schema error at paths" "should be array"

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

parameters is an array of parameters. In YAML, array items are formatted with the leading -. Also style is a parameter attribute, not schema attribute.

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

To learn more about OpenAPI 3.0 syntax and how to format things, check out this guide: https://swagger.io/docs/specification/basic-structure/



来源:https://stackoverflow.com/questions/48283801/swagger-3-0-schema-error-should-not-have-additional-properties

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!