question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error building class name

See original GitHub issue

Parsing this schema:

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "JSON Schema for NVD Common Product Enumeration (CPE) Feed version 0.1 Beta",
    "id": "https://scap.nist.gov/schema/nvd/feed/1.0/nvd_cve_feed_json_1.0_beta.schema",
    "description": "NVD data feed of CPE",
    ...
}

raises black.InvalidInput: Cannot parse: 10:6: class 1 Beta(BaseModel):

The problem was settled by changing the schema’s title to Cpe.

Version:

  • OS: Windows
  • Python version: 3.7.7
  • datamodel-code-generator version: 0.6.0

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
nuno-andrecommented, Nov 21, 2020

Great. Thank you!

Moving forward to avoid dead spots can be a great improvement to generate models also dynamically. I’ll stay tuned.

0reactions
koxudaxicommented, Nov 11, 2020

@nuno-andre I have released a new version as 0.6.4

This release has two changes.

  1. add --class-name option sets the name of the root model.
  2. raise an error when the model name(title) is invalid and --class-name is not set.

I considered your approach that is below.

  1. use id and description as a model name.
  2. improve get_valid_name

I feel good about the approach. But, this is a breaking change. I don’t choose the breaking change in this release.

However, I want to implement these next major(1.x) or miner (0.7.x) version.

Thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

javac error: Class names are only accepted if annotation ...
The error "Class names are only accepted if annotation processing is explicitly requested" can be caused by one or more of the following:....
Read more >
[java] Some classes are causing Malformed class name errors
Issue appears specific to 1 project and only specific files within that project. Other project runs completely fine with no issues. BUILD FAILED ......
Read more >
errors when using class names locators Getting compound ...
I have written a method which will count the no of elements in <divs> and will return the number. Below is the error...
Read more >
"The type or namespace name 'ClassName' does not exist ...
FIX: "The type or namespace name 'ClassName' does not exist" error message when you try to build a Visual C# Windows Form solution...
Read more >
The Basics - Manual - PHP
Basic class definitions begin with the keyword class , followed by a class name, followed by a pair of curly braces which enclose...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found