opendata-for-all / wapiml

An OpenAPI round-trip tool that leverages model-driven techniques to create, visualize, manage, and generate OpenAPI definitions.
Eclipse Public License 2.0
69 stars 18 forks source link

Eclipse error converting model to YAML / JSON #45

Open mattadamson opened 1 year ago

mattadamson commented 1 year ago

Team

I found this error converting a model to either YAML or JSON

An internal error occurred during: "edu.uoc.som.wapiml.ui.popup.handlers.ConvertToYaml". Cannot invoke "edu.uoc.som.openapi2.API.getInfo()" because "this.openAPI2Model" is null

I saw this on a new model I created from scratch and also after reverse engineering the petstore.json open api spec into a model and then back out to a JSON file. The import of JSON to a model worked well its just the other way around that fails

Thanks

hamzaed commented 1 year ago

I think that the stereotype API is missing from your Model element. The tool expects a semantically correct model for the generation of the definition. This issue is mentioned in #37. In fact, the generation process fails in the presence of semantic errors (e.g. missing required elements). We were planning to add a validation step to validate the model before the generation process but unfortunately, we never had time to do it (see https://github.com/opendata-for-all/wapiml/issues/370. However, I don't understand why the generation fails for the petstore model since it's supposed to be correct and complete. When generating the class diagram, did you check "Apply the OpenAPI profile"? The generation fails without the profile and the applied stereotypes.

To create a model from scratch, I suggest that you first generate the class diagram from the pet store definition then remove the pet store classes and use this model as a template for your model.