Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

datamodel-codegen produces class with missing body parts #1901

Open
degenaro opened this issue Apr 3, 2024 · 0 comments
Open

datamodel-codegen produces class with missing body parts #1901

degenaro opened this issue Apr 3, 2024 · 0 comments

Comments

@degenaro
Copy link

degenaro commented Apr 3, 2024

Describe the bug

Within the OSCAL schema is:

"EmailAddressDatatype" : 
   { "description" : "An email address string formatted according to RFC 6531.",
    "allOf" : 
    [ 
     { "$ref" : "#/definitions/StringDatatype" },
     
     { "type" : "string",
      "format" : "email",
      "pattern" : "^.+@.+$" } ] },

An empty body is produced by datamodel-codegen:

class EmailAddressDatatype(OscalBaseModel):
    """
    An email address string formatted according to RFC 6531.
    """

To Reproduce

  1. download OSCAL schemas from here https://github.com/usnistgov/OSCAL/releases/tag/v1.1.2
  2. run datamodel-codegen (shown below)

Example schema (snippet):

"EmailAddressDatatype" : 
   { "description" : "An email address string formatted according to RFC 6531.",
    "allOf" : 
    [ 
     { "$ref" : "#/definitions/StringDatatype" },
     
     { "type" : "string",
      "format" : "email",
      "pattern" : "^.+@.+$" } ] },

Follow link above for full schema.

Used commandline:

datamodel-codegen --disable-timestamp --disable-appending-item-suffix --use-schema-description --input-file-type jsonschema --input release-1.1.2-schemas/oscal_assessment-plan_schema.json --base-class trestle.core.base_model.OscalBaseModel --output trestle/oscal/tmp/assessment_plan.py

Expected behavior
The generated code body should not be empty, but rather contain that which is found in the json schema.

Version:

  • OS: Red Hat Enterprise Linux release 8.9 (Ootpa)
  • Python version: 3.9.9
  • datamodel-code-generator version: 0.25.5

Additional context
NA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant