mulesoft-labs / raml-for-jax-rs

This project is all about two way transformation of JAX-RS-annotated Java code to RAML API description and back.
Other
296 stars 181 forks source link

Error generating Java classes from raml-to-jaxrs-maven-plugin #405

Closed diggernet closed 4 years ago

diggernet commented 5 years ago

Version: 3.0.0 and later (worked in 2.1.1). Scenario: Define a type with a name ending with "Response", and containing a property with a type which is an object with a discriminator. Error: [ERROR] Failed to execute goal org.raml.jaxrs:raml-to-jaxrs-maven-plugin:3.0.5:generate (default) on project [projectName]: Error generating Java classes from: null: can't fetch type named [propertyName] (Where [projectName] is the name of the maven project, and [propertyName] is the name of the first property in the type which has a type with a discriminator.)

Changing the name of PetResponse to Petresponse or PetResponseType (or pretty much anything else) avoids the error. As does defining Animal without a discriminator.

test.raml:

#%RAML 1.0 Library

types:
  PetResponse:
    type: object
    properties:
      myPet:
        type: Animal

  Animal:
    type: object
    discriminator: animalType
    properties:
      animalType: string

  Cat:
    type: Animal
    discriminatorValue: CAT
    properties:
      legs: integer

  Fish:
    type: Animal
    discriminatorValue: FISH
    properties:
      fins: integer
jpbelang commented 5 years ago

Looking into it today.

Well, that's weird. raml-java-tools handles them properly. Hmmmmmm. It does not...it's the jackson plugin that causes problems.

I'm currently trying to figure out the bug. It's a weird one where type names are confused for property names. The parser model is not very helpful on this. Why it depends on the type name, I have no idea. I hope it's not the parser :-)

rspremulli-sf commented 4 years ago

This issue is impacting us as well. If there is any further progress you made debugging this, please share.

rspremulli-sf commented 4 years ago

We can work around it by using the Jaxb parser, it seems

diggernet commented 4 years ago

This was fixed in v3.0.7. Thanks!