Skip to content

Feature: allow type=object field overriding with type=array in Schema object using allOf #719

@mtovt

Description

@mtovt

Is your feature request related to a problem? Please describe.
There is a minimal example for described feature:

openapi: 3.0.1
info:
  title: example
  description: allOf example
  version: 0.1.0
servers:
  - url: 'https://example.com'
paths:
  '/foo':
    delete:
      responses:
        '200':
          description: OK
components:
  schemas:
    Foo:
      type: object
      properties: 
        property1: 
          type: object
    Bar:
      type: object
      properties:
        property1:
          type: array
          items:
            type: string
      allOf:
        - $ref: '#/components/schemas/Foo'

It seems OpenAPI refers JSON Schema Specification Wright Draft 00. Which one refers The JavaScript Object Notation (JSON) Data Interchange Format. Which says:

The terms "object" and "array" come from the conventions of JavaScript.
As I understand, array is a subtype of object in terms of JS. And seems object type may be overridden by array type.

Bar object does not generate due to a type mismatch. Seems, provided the specification is valid. Bar object should be generated with array type of property1 property.

Describe the solution you'd like
It seems another approach is required in function _process_properties. This place rejects several valid cases.

Describe alternatives you've considered

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions