Skip to content

Schema extends array item results in duplicate properties #1218

@peacefixation

Description

@peacefixation

Describe the bug

I have an OpenAPI spec that contains a response schema that inherits from GeoJSON Feature Collection and extends the items array to support custom items that inherit from GeoJSON Feature. When I render the docs for this API spec there are duplicate GeoJSON Feature properties: id, properties, geometry, bbox and type.

Expected behavior

I expect the docs to render GeoJSON Feature properties once.

Current behavior

The docs render GeoJSON Feature properties twice.

Possible solution

It seems that the docusaurus plugin can't merge the GeoJSON Feature Collection > items > GeoJSON Feature schema with the schema for my custom feature that inherits from GeoJSON Feature.

Steps to reproduce

This example Open API schema reproduces the bug.

openapi: 3.1.0

info:
  title: Custom Feature Collection API
  summary: API for managing custom feature collections
  description: |-
    This API allows clients to retrieve custom feature collections.
  version: 0.0.1

jsonSchemaDialect: https://spec.openapis.org/oas/3.1/dialect/base

servers:
  - url: https://api.example.com
    description: API server

paths:
  /custom-feature-collection/{id}:
    get:
      summary: Get custom feature collection
      description: >-
        This resource represents a custom feature collection.
      operationId: get-custom-feature-collection
      parameters:
        - in: path
          name: id
          description: The unique identifier of the custom feature collection
          schema:
            type: string
            format: uuid
            examples:
              - d290f1ee-6c54-4b01-90e6-d701748f0851
          required: true
      responses:
        '200':
          description: OK
          content:
            application/geo+json:
              schema:
                $ref: '#/components/schemas/custom-feature-collection'
        '404':
          description: Not Found

components:
  schemas:
    custom-feature-collection:
      title: Custom Feature Collection
      description: >-
        The custom feature collection represents a GeoJSON feature collection with
        some custom properties
      type: object
      allOf:
        - $ref: https://geojson.org/schema/FeatureCollection.json
        - type: object
          properties:
            features:
              items:
                oneOf:
                  # we use oneOf because we have a few different feature types (not shown in this example)
                  # this could be a schema that inherits from Feature, but trivially, referencing Feature directly will show the bug
                  - $ref: https://geojson.org/schema/Feature.json
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-Api-Key
      description: >-
        The API key is used to authenticate requests to the Custom Feature Collection API.
        It should be included in the header of each request.

security:
  - ApiKeyAuth: [ ]

Screenshots

Image

Context

We have an Open API schema to publish documentation for and we have to modify the version in the document repository fairly heavily to have it render correctly instead of referencing the original.

Your Environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions