Swagger 3.0 架构错误“不应具有附加属性" [英] Swagger 3.0 schema error "should NOT have additional properties"

查看:80
本文介绍了Swagger 3.0 架构错误“不应具有附加属性"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

架构错误不应具有附加属性 additionalProperty:/buildinfo,/clearcache,/countries/{countryId}/cinemas/{theatreid}/screens/{screenid}/layout,/countries/{countryId}/cinemas/{theatreid}/screens 跳到第 0 行

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

下面是我的 yaml 文件.

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

推荐答案

路径缩进不对:

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

应该是:

paths:
  /buildinfo:
    get:

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

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 是一个参数数组.在 YAML 中,数组项以 - 开头.另外 style 是一个参数属性,而不是架构属性.

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

要了解有关 OpenAPI 3.0 语法以及如何设置格式的更多信息,请查看本指南:https://swagger.io/docs/specification/basic-structure/

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

这篇关于Swagger 3.0 架构错误“不应具有附加属性"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆