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

#1570 Add Examples Support #2530

Merged

Conversation

jasouyris
Copy link
Contributor

Support ApiResponse examples.

Summary
Transforms @Example.value() (i.e. @ExampleProperty[]) into a List<Example> that then will be transformed into a Map<String, Object> that then will be used to populate the examples map in io.swagger.models.Response

Details

  1. Added a List<Example> to ResponseMessage
  2. Added a small block of code in SwaggerResponseMessageReader (where an ApiResponse is transformed into a ResponseMessage) that will transform an ExampleProperty into an Example and then add it to the ResponseMessage using the field above.
  3. Transform the List<Example> to a Map<String, Object> in ServiceModelToSwagger2Mapper, and populate the Response.examples with it.

Test

  1. Added additional UT to ResponseMessageSpec, ResponseMessageBuilderSpec and ServiceModelToSwagger2MapperSpec to cover newly added functionality.
  2. Added a ResponseExampleTestController that will be used by SwaggerResponseMessageReaderSpec to test examples support.
  3. Added UT for new ExamplesMapper class.
  4. Added a new endpoint in FeatureDemonstrationService (not sure if this is the right place), to test the contract using the contract tests.

@codecov
Copy link

codecov bot commented Jul 3, 2018

Codecov Report

Merging #2530 into master will decrease coverage by <.01%.
The diff coverage is 95.23%.

@@             Coverage Diff              @@
##             master    #2530      +/-   ##
============================================
- Coverage     95.03%   95.03%   -0.01%     
- Complexity     3057     3064       +7     
============================================
  Files           340      341       +1     
  Lines          7809     7828      +19     
  Branches        596      600       +4     
============================================
+ Hits           7421     7439      +18     
  Misses          240      240              
- Partials        148      149       +1

@jasouyris
Copy link
Contributor Author

Hi @dilipkrish, any news regarding this PR (or Q1nt's PR)?

Cheers!

@dilipkrish dilipkrish added the PR label Jul 13, 2018
@dilipkrish dilipkrish merged commit 9c0e920 into springfox:master Jul 13, 2018
@dilipkrish
Copy link
Member

@jasouyris thanks for the PR! 🤘

@dilipkrish dilipkrish added this to the 3.0 milestone Jul 13, 2018
@jasouyris
Copy link
Contributor Author

It's a pleasure! Thank you for all your time and work in this project, I don't know what'll do without it! 🤘

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants