Allow schema title to be used as class name (new useTitleAsClassname config option)
See original GitHub issueWhen having schemas where certain field names are repeated with different implementations the code currently generates unique class names such as Image__1
, etc. I would like to have a configuration to use the title
as class name instead.
So that
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "SchemaTest body",
"description": "Use title as class name.",
"type": "object",
"properties": {
"image": {
"type": "object",
"title": "MyImage"
}
}
}
would result in
public class SchemaTest {
private MyImage image;
public SchemaTest() {
}
public SchemaTest(MyImage image) {
super();
this.image = image;
}
public MyImage getImage() {
return image;
}
}
public class MyImage{
}
Thank you for your great library. I am using it successfully and really like the RuleFactory
design.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
json - How to change default OutputSchema.java class name ...
If you use this, the class name will be what you specified in the title attribute of your schema. https://github.com/joelittlejohn/ ...
Read more >Jsonschema2Pojo Task
Attribute Description Required
source The input JSON schema. Yes
useTitleAsClassname When set the title is used as classname. No (default false )
inclusionLevel Default value NON_NULL...
Read more >README.md - joelittlejohn/jsonschema2pojo - Sourcegraph
jsonschema2pojo generates a Java representation of your json schema. ... Whether to use the 'title' property of the schema to decide the class...
Read more >https://raw.githubusercontent.com/joelittlejohn/js...
Changelog ## 1.1.2 * Use LinkedHashMap for additional properties, ... Allow schema title to be used as class name (new useTitleAsClassname config option) ......
Read more >Generate Java Classes using JSON (text) - Docker Hub
Available options are: off, error, warn, info, debug, trace Default: info -ut, --use-title-as-classname, When set class names are generated from title ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Happy to accept a PR for this, as long as it is behind a configuration option, say,
useTitleAsClassname
. The default must befalse
.Thank you very much! It was fun working on this one.