Open ZdenekM opened 4 years ago
The following example:
from dataclasses import dataclass from typing import Set, Any from dataclasses_jsonschema import JsonSchemaMixin from apispec import APISpec # type: ignore from apispec_webframeworks.flask import FlaskPlugin # type: ignore from dataclasses_jsonschema.apispec import DataclassesPlugin @dataclass class ArbitraryValues(JsonSchemaMixin): arbitrary_value: Any set_of_arbitrary_values: Set[Any] spec = APISpec( title="Test", version="1.0.0", openapi_version="3.0.2", plugins=[FlaskPlugin(), DataclassesPlugin()], ) spec.components.schema(ArbitraryValues.__name__, schema=ArbitraryValues) print(spec.to_yaml())
generates invalid OpenAPI:
components: schemas: ArbitraryValues: description: 'ArbitraryValues(arbitrary_value: Any, set_of_arbitrary_values: Set[Any])' properties: arbitrary_value: {} set_of_arbitrary_values: type: array uniqueItems: true required: - arbitrary_value - set_of_arbitrary_values type: object info: title: Test version: 1.0.0 openapi: 3.0.2 paths: {}
The field items is missing for set_of_arbitrary_values. It should be like this:
items
set_of_arbitrary_values
set_of_arbitrary_values: type: array uniqueItems: true items: {}
The following example:
generates invalid OpenAPI:
The field
items
is missing forset_of_arbitrary_values
. It should be like this: