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

IllegalStateException when type is an array #5

Open
DavidMhn opened this issue Jan 27, 2021 · 0 comments
Open

IllegalStateException when type is an array #5

DavidMhn opened this issue Jan 27, 2021 · 0 comments

Comments

@DavidMhn
Copy link

When an object type is an array, for instance
"type": ["string","integer"]
The conversion fails with this stack

java.lang.IllegalStateException
	at com.google.gson.JsonArray.getAsString(JsonArray.java:226)
	at edu.uoc.som.jsonschematouml.generators.JSONSchemaToUML.analyzeProperty(JSONSchemaToUML.java:463)
	at edu.uoc.som.jsonschematouml.generators.JSONSchemaToUML.analyzeObject(JSONSchemaToUML.java:336)
	at edu.uoc.som.jsonschematouml.generators.JSONSchemaToUML.analyzeRootSchemaElement(JSONSchemaToUML.java:264)
	at edu.uoc.som.jsonschematouml.generators.JSONSchemaToUML.analyzeDefinitions(JSONSchemaToUML.java:754)
	at edu.uoc.som.jsonschematouml.generators.JSONSchemaToUML.analyzeRootSchemaElement(JSONSchemaToUML.java:269)
	at edu.uoc.som.jsonschematouml.generators.JSONSchemaToUML.analyzeSchema(JSONSchemaToUML.java:253)
	at edu.uoc.som.jsonschematouml.generators.JSONSchemaToUML.analyze(JSONSchemaToUML.java:219)
	at edu.uoc.som.jsonschematouml.generators.JSONSchemaToUML.launch(JSONSchemaToUML.java:171)
	at edu.uoc.som.jsonschematouml.ui.handlers.ConvertToClassDiagram$1.run(ConvertToClassDiagram.java:56)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)

This line doesn't handle the array case:

JSONSchemaToUML.java:463
 else if(itemsObject.has("type") && itemsObject.get("type").getAsString().equals("string")) { 

Note this case of type is conform to json schema type definition (at least in json schema draft v7):

"type": {
            "anyOf": [
                {"$ref": "#/definitions/simpleTypes"},
                {
                    "type": "array",
                    "items": {"$ref": "#/definitions/simpleTypes"},
                    "minItems": 1,
                    "uniqueItems": true
                }
            ],
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