datamodel-code-generator icon indicating copy to clipboard operation
datamodel-code-generator copied to clipboard

YAML spec is correctly parsed with --input-file-type jsonschema

Open ck-on-github opened this issue 2 years ago • 3 comments

I have a YAML spec, for which datamodel-codegen was working fine until the release 0.18.0. With 0.18.0 I see some unexpected code generation when I do not specify any --input-file-type and when I specify --input-file-type yaml. I only get it to work (same code generated as before) if I specify --input-file-type jsonschema. But my input spec file is YAML and swagger 2.0, not jsonschema.

I can provide a sample yaml spec to reproduce this if needed. But I first wanted to make sure this is not an obvious bug.

ck-on-github avatar Aug 10 '23 17:08 ck-on-github

What problems do you have with --input-file-typ=jsonschema?

adaamz avatar Aug 14 '23 09:08 adaamz

@adaamz I do not have a problem in particular with --input-file-typ=jsonschema.

I would just like to understand if it is indeed the expected behavior to use --input-file-typ=jsonschema for a YAML file with a yaml format, but not --input-file-typ=yaml or if this is a bug.

When I use --input-file-typ=yaml for the YAML-formatted file, I see unexpected code generated, which is the unexpected behavior from my point of view.

ck-on-github avatar Aug 14 '23 12:08 ck-on-github

@ck-on-github I'm sorry my late reply.

I would just like to understand if it is indeed the expected behavior to use --input-file-typ=jsonschema for a YAML file with a yaml format, but not --input-file-typ=yaml or if this is a bug.

It's a good point. YAML is a raw data format type.

But my input spec file is YAML and Swagger 2.0, not jsonschema.

I don't know the hacky method exists .:sweat_smile: The code generator doesn't support swagger. But, I guess the CLI could parse swagger as jsonschema.

koxudaxi avatar Oct 04 '23 18:10 koxudaxi