rapi-doc / RapiDoc

RapiDoc -WebComponent for OpenAPI Spec
https://rapidocweb.com
MIT License
1.71k stars 285 forks source link

Rapidoc is unable to render the anyOf values #1052

Closed SowjanyaMN07 closed 1 month ago

SowjanyaMN07 commented 1 month ago

The values defined under the anyOf are not rendering correctly in the Rapidoc outputs. Instead of displaying the expected values, the output is showing {missing-type-info}. Please investigate and implement a fix to properly display the values defined in the anyOf sections.

Sample snippet:

openapi: 3.0.0
servers:
  - url: 'https://example.com/dev'

info:
  title: Test title
  description: |
    # This is a demo description
  version: 7.17.0

paths:
  '/test/{testName}':
    get:
      summary: Retrieves a Test name
      description: This is a sample description
      operationId: getTest
      tags:
        - TestTag
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Rule'
        '404':
          description: Resource Not Found
          content:
            application/problem+json:
              schema:
                type: string
        '414':
          description: URI too long
          content:
            application/problem+json:
              schema:
                type: string
        '500':
          description: Internal Database error
          content:
            application/problem+json:
              schema:
                type: string
        '503':
          description: Service Unavailable
          content:
            application/problem+json:
              schema:
                type: string
        default:
          description: Unexpected error

components:
  schemas:
    # Base data types
    Rule:
      description: Rule definition
      type: object
      additionalProperties: false
      anyOf:
        - required:
            - ruleName
            - condition
        - required:
            - ruleName
            - outputAttributes
      properties:
        ruleName:
          $ref: '#/components/schemas/Id'
          minLength: 1
        condition:
          description: >-
            This is a sample description
          type: string
        outputAttributes:
          $ref: '#/components/schemas/OutputAttributeList'

Screenshot image

mrin9 commented 1 month ago

The provided spec is invalid. contains non-existing refs and additionally anyOf should use a $ref pointer to point to a schema not just a field-name if you just provide the field-name without any type info it will show {missing-type-info}

validate ur spec against an editor and re-open the issue if needed

SowjanyaMN07 commented 1 month ago

Provided the type info along with filed-name but still facing same issue in Rapidoc. Please check this. Corrected snippet:

servers:
  - url: https://example.com/dev
info:
  title: Test title
  description: |
    # This is a demo description
  version: 7.17.0
paths:
  /test:
    get:
      summary: Retrieves a Test name
      description: This is a sample description
      operationId: getTest
      tags:
        - TestTag
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Rule'
        '404':
          description: Resource Not Found
          content:
            application/problem+json:
              schema:
                type: string
        '414':
          description: URI too long
          content:
            application/problem+json:
              schema:
                type: string
        '500':
          description: Internal Database error
          content:
            application/problem+json:
              schema:
                type: string
        '503':
          description: Service Unavailable
          content:
            application/problem+json:
              schema:
                type: string
        default:
          description: Unexpected error
components:
  schemas:
    Rule:
      description: Rule definition
      type: object
      additionalProperties: false
      required:
        - unrelatedA
      properties:
        unrelatedA:
            type: string
        fileNames:
            type: array
        copyAll:
            type: boolean
        matchesFiles:
            type: array
        doesntMatchFiles:
            type: array
      oneOf:
        - required:
            - copyAll
        - required:
            - fileNames
        - anyOf:
            - required:
                - matchesFiles
            - required:
                - doesntMatchFiles

image image