podhmo / swagger-marshmallow-codegen

generating marshmallow's schema from swagger definition file
MIT License
52 stars 10 forks source link

treating AdditionalProperties only schema as Dict field #64

Closed podhmo closed 3 years ago

podhmo commented 3 years ago
definitions:
  person:
    type: object
    properties:
      name:
        type: string
      x-data:
        additionalProperties:
          type: string
podhmo commented 3 years ago

currently,

from swagger_marshmallow_codegen.schema import AdditionalPropertiesSchema

class Person(Schema):
    name = fields.String()
    x_data = fields.Nested(lambda: PersonX_data, data_key='x-data')

class PersonX_data(AdditionalPropertiesSchema):

    class Meta:
        additional_field = fields.String()
podhmo commented 3 years ago

But, schema with properties, current implementation is correct answer.

(using Meta.unknown, additionalPropeties:true, current marshmallow not support validation for unknown field)