phoenixnap / springmvc-raml-plugin

Spring MVC - RAML Spec Synchroniser Plugin. A Maven plugin designed to Generate Server & Client code in Spring from a RAML API descriptor and conversely, a RAML API document from the SpringMVC Server implementation.
Apache License 2.0
136 stars 84 forks source link

Import Statement for BigDecimal/BigInteger not generated for responses #275

Closed peyerroger closed 5 years ago

peyerroger commented 5 years ago

Import Statement for BigDecimal not generated if return type number and useBigDecimal=true

Example: `#%RAML 1.0 title: Number as bigdecimal version: 1.0

/lucky-number: get: description: Returns the winning number. responses: 200: body: application/json: type: number`

Actual: `-----------------------------------com.gen.test.LuckyNumberClient.java-----------------------------------

package com.gen.test;

import org.springframework.http.ResponseEntity;

/**

} -----------------------------------com.gen.test.LuckyNumberClientImpl.java-----------------------------------

package com.gen.test;

import java.util.ArrayList; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; import org.springframework.web.util.UriComponents; import org.springframework.web.util.UriComponentsBuilder;

/**

} `

Expected: -----------------------------------com.gen.test.LuckyNumberClient.java-----------------------------------

package com.gen.test;

import java.math.BigDecimal; import org.springframework.http.ResponseEntity;

/**

} -----------------------------------com.gen.test.LuckyNumberClientImpl.java-----------------------------------

package com.gen.test;

import java.util.ArrayList; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpMethod; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; import org.springframework.web.util.UriComponents; import org.springframework.web.util.UriComponentsBuilder;

/**

}

stojsavljevic commented 5 years ago

Hi,

Thanks for reporting the bug. I believe I fixed the import.

Only thing that is unclear to me is Double object instead of BigDecimal in your actual results. I guess it's just misspelled.

In case that fix doesn't work as you expect please reopen the issue or create new one.

peyerroger commented 5 years ago

Hi Aleksander

Sorry, the double is a copy/paste error.

I already created a pull request for this issue. I used a different approach, which is most probably not as good as yours. BUT the tests can be reuses ;)

Would you mind to add the tests from my pull request to your commit?

Thanks, Roger

stojsavljevic commented 5 years ago

Hi @peyerroger

Thank you very much for your #280 PR. My original idea was to create generic solution. But after looking at your solution I realized it's actually better than mine. Your change is less intrusive - I was changing core object ApiBodyMetadata and this something I want to avoid. Also, my change there (name vs fullName) can be confusing.

Further, your change helped to discover and solve another bug - #281

I added 24 test cases to make sure we don't regress on this. They include your test cases too.

I will reject your PR since I resolved the bug using your idea but I added something more generic (RuleHelper for example). I hope you don't get mad at me for rejecting the PR :)

peyerroger commented 5 years ago

Hi Aleksander

Thanks for solving this issue so quickly.

Not at all! The important thing is solving the issue. Doesn't matter which pull request gets integrated ;)

Cheers, Roger