swagger-api / validator-badge

Validate your Swagger JSON/YAML today!
http://swagger.io
Apache License 2.0
208 stars 85 forks source link

OpenAPI v3 spec is failing validation but has always passed before #210

Closed CameronGo closed 1 year ago

CameronGo commented 1 year ago

My swagger UI references the online validator and is suddenly showing my spec as invalid. I don't know when this started, but the things it is complaining about have not changed. It is also not consistent in the things it is flagging as invalid.

Here is the URL that shows the invalid response: https://validator.swagger.io/validator/debug?url=https%3A%2F%2Fapi.pursuanthealth.com%2Fv3%2Fdocs%2Fopenapi.yaml

The messages it is reporting as invalid are all references from one object definition to a property of another. Here are the formatted results from that URL above:

{
    "messages": [
        "attribute components.parameters.session.uuid.[session.uuid].schemas.uuid is not of type `schema`",
        "attribute components.schemas.DeviceAuthRequest.client_id is not of type `schema`",
        "attribute components.parameters.program.id.[program.id].schemas.id is not of type `schema`",
        "attribute components.schemas.MemberSmall.href is not of type `schema`",
        "attribute components.schemas.MemberSmall.group is not of type `schema`",
        "attribute components.parameters.shorturl.short_code.[shorturl.short_code].schemas.short_code is not of type `schema`",
        "attribute components.schemas.SessionDataLabelValue.survey_path is not of type `schema`",
        "attribute components.schemas.RefreshTokenRequest.refresh_token is not of type `schema`",
        "attribute components.schemas.DeviceAccessTokenRequest.device_code is not of type `schema`",
        "attribute components.parameters.channel.name.[name].schemas.name is not of type `schema`",
        "attribute components.parameters.channel.version.id.[channel.version.id].schemas.channel_version_id is not of type `schema`",
        "attribute components.schemas.DeviceAuthRequest.scope is not of type `schema`",
        "attribute components.parameters.group.alt_id.[group_alt_id].schemas.alt_id is not of type `schema`",
        "attribute components.parameters.file.name.[file.name].schemas.file_name is not of type `schema`"
    ],
    "schemaValidationMessages": []
}

But, if you look at this excerpt for MemberSmall for example, the properties it is referencing are valid schema objects. Also, while it complains about MemberSmall.href for example, it does not complain about MemberSmall.uuid or MemberSmall.alt_id for example. See object models below:

MemberRef:
description: Provides basic ID info about a member with an href to the full object
type: object
properties:
  uuid:
    description: "Uniquely identifies a member across the entire platform"
    type: string
    format: uuid
    minLength: 36
    maxLength: 36
    example: "26a0bac8-5c37-4c54-b3b1-1ad4551db061"
  alt_id:
    description: "An ID defined for a member, typically provided by a customer during integration, which will be unique within a given group."
    type: string
    minLength: 1
    maxLength: 36
    example: "ABC-123"
  group:
    $ref: "#/components/schemas/MemberGroup"
  href:
    type: string
    format: uri
    readOnly: true
anyOf:
  - required: ["uuid"]
    properties:
      uuid:
        $ref: "#/components/schemas/MemberRef/properties/uuid"
      alt_id:
        $ref: "#/components/schemas/MemberRef/properties/alt_id"
      group:
        $ref: "#/components/schemas/MemberRef/properties/group"
      href:
        $ref: "#/components/schemas/MemberRef/properties/href"
  - required: ["alt_id", "group"]
    properties:
      uuid:
        $ref: "#/components/schemas/MemberRef/properties/uuid"
      alt_id:
        $ref: "#/components/schemas/MemberRef/properties/alt_id"
      group:
        $ref: "#/components/schemas/MemberRef/properties/group"
      href:
        $ref: "#/components/schemas/MemberRef/properties/href"
MemberSmall:
description: >-
  Provides abbreviated information about a member and is used when returning an array of members
readOnly: true
properties:
  uuid:
    $ref: "#/components/schemas/MemberRef/properties/uuid"
  alt_id:
    $ref: "#/components/schemas/MemberRef/properties/alt_id"
  group:
    $ref: "#/components/schemas/MemberRef/properties/group"
  href:
    $ref: "#/components/schemas/MemberRef/properties/href"
  activated:
    description: >-
      Indicates that the member has logged into their account
    type: boolean
    example: true
  disabled:
    description: >-
      Indicates that the member's account is disabled and they will no longer be able to login
    type: boolean
    example: false
frantuma commented 1 year ago

Thanks for reporting this, issue should be fixed in deployed version (v2.1.2), please reopen ticket if you are still experiencing issues.