-
Hi, eg: ---
"$schema": http://json-schema.org/draft-07/schema#
title: Person
type: object
properties:
firstName:
type: string
description: The person's first name.
Using this schema I generated models # generated by datamodel-codegen:
# filename: person.yaml
# timestamp: 2021-04-22T11:25:47+00:00
from __future__ import annotations
from typing import Optional
from pydantic import BaseModel, Field
class Person(BaseModel):
firstName: Optional[str] = Field(None, description="The person's first name.") Is there a way to specify key1, key2 and values in my schema so that the model is generated as below firstName: Optional[str] = Field(
None,
description="The person's first name.",
key1={"a":"a1", "b":"b1"},
key2="aaaa"
) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hi @gk12277
the short answer is no.
Where are key1, key2? "$schema": http://json-schema.org/draft-07/schema#
title: Person
type: object
properties:
firstName:
type: string
description: The person's first name.
key1:
a: a1
b: b1
key2: aaaa I can add an option of CLI to pass extra keys to the field. $ datamodel-codegen --input input.json --extra-keys key1 key2 What do you think about it? |
Beta Was this translation helpful? Give feedback.
Hi @gk12277
the short answer is no.
Where are key1, key2?
Did you expect this schema?
I can add an option of CLI to pass extra keys to the field.
For example
What do you think about it?