Describe the bug
When using an object with additionalProperties and an array of an item type, the resulting code doesn't reference the generated item type.
To Reproduce
Example schema:
openapi: "3.0.0"
info:
title: Sample API
description: API description in Markdown.
version: 1.0.0
servers: []
paths: {}
components:
schemas:
test:
type: object
properties:
broken:
type: object
additionalProperties:
type: array
items:
$ref: '#/components/schemas/broken'
broken:
type: object
properties:
foo:
type: string
bar:
type: integer
Results in the following generated file:
# generated by datamodel-codegen:
# filename: tmp.yml
# timestamp: 2020-09-30T13:47:06+00:00
from __future__ import annotations
from typing import Dict, Optional
from pydantic import BaseModel
class Broken(BaseModel):
foo: Optional[str] = None
bar: Optional[int] = None
class Test(BaseModel):
broken: Optional[Dict[str, Broken]] = None
Used commandline:
$ datamodel-codegen --input test.yml --input-file-type openapi --output test_model.py
Expected behavior
class Test(BaseModel):
broken: Optional[Dict[str, List[Broken]]] = None
Version:
@Echronix
Thank you for creating this issue.
OK, I will implement it.
I just hit this as well again
I have released a new version as 0.5.39 :rocket:
Most helpful comment
I have released a new version as
0.5.39:rocket: