-
Notifications
You must be signed in to change notification settings - Fork 25
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
Autogenerate schema element titles #304
Conversation
Codecov Report
@@ Coverage Diff @@
## master #304 +/- ##
==========================================
+ Coverage 81.80% 82.03% +0.22%
==========================================
Files 54 54
Lines 4886 5014 +128
==========================================
+ Hits 3997 4113 +116
- Misses 889 901 +12
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
schema["title"] = name2title(schema["title"]) | ||
for name, prop in schema.get("properties", {}).items(): | ||
if prop.get("title") is None or prop["title"] == name.title(): | ||
prop["title"] = name2title(name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need a test for this. Please add a little test which would pretty much do what dandi/tools/pubschemata.py
does and ensure that we do get title
set as expected in at least one record
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test added.
LGTM - can we check that the generated json schema has the titles (especially for the enumerated types like |
@satra As I said above, there doesn't seem to be a way to autogenerate titles for enum types. |
) | ||
license: List[LicenseType] = Field(description="License of item.", nskey="schema") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jwodder - then we should not remove the title field that was added to enum types. There are a few of these.
AccessType = create_enum(AccessTypeDict)
RoleType = create_enum(RoleTypeDict)
RelationType = create_enum(RelationTypeDict)
LicenseType = create_enum(LicenseTypeDict)
IdentifierType = create_enum(IdentifierTypeDict)
DigestType = create_enum(DigestTypeDict)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, you mean the enum fields! No, those titles are autogenerated fine. It's the enum entries in the definitions
section that don't get titles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's proceed, and if anything -- fixup after! ;) "release is cheap" these days (and we do not need a release for this anyways) but it would avoid possible conflicts happen we decide to tune the schema |
Closes #301.
Note that there doesn't seem to be a way to apply this to enum types.