Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

@ResponseExample support #529

Closed
vguna opened this issue Oct 27, 2016 · 5 comments
Closed

@ResponseExample support #529

vguna opened this issue Oct 27, 2016 · 5 comments

Comments

@vguna
Copy link

vguna commented Oct 27, 2016

Hi.

Currently I use the auto-generated JSON response examples based on the returned types.
In 95% of the cases this is sufficient. But sometimes it would be great, if one could override the auto-generated ones, and specify custom ones via javadoc. E.g.

    /**
     * Returns the pet resource instance.
     * 
     * Maybe offer pretty printing? if so, should be an enunciate.xml option - for all examples.
     * @ResponseExample application/json { "id": 4, "name": "mypet" }
     * @ResponseExample application/xml {@code <pet><id>4</id><name>mypet</name></pet>}
     * 
     * OR
     * 
     * This could be hard to parse and to keep formatting.
     * @ResponseExample application/json    {
     *                                          "id": 4,
     *                                          "name": "mypet"
     *                                      }
     * OR
     * 
     * @ResponseExample application/json pet-example.json
     * @ResponseExample application/json relativepathonclasspath/pet-example.json
     * @ResponseExample application/json classpath:pet-example.json
     * @ResponseExample application/json file:///somepath/pet-example.json 
     * 
     * OR
     * 
     * Another idea: for some endpoints it would be enough to just exclude specific properties from auto-generated example (e.g. on PUT).
     * Although some say, one should use different models for this :).
     * @ExcludePropertiesFromResponse id someOtherProperty anotherProperty
     * 
     * @return the pet resource instance.
     */
    @GET
    @Produces({ MediaType.APPLICATION_JSON })
    Pet getPet();

WDYT?

@stoicflame
Copy link
Owner

It's a reasonable request.

@kingferiol
Copy link

This is really interesting. Is there possibility to have something similar for request examples

@stoicflame
Copy link
Owner

This enhancement is currently seeking a sponsor. If anybody is willing to sponsor the work, reach out to me and I'd be happy to pick it up.

@stoicflame
Copy link
Owner

Thanks to the support of a generous sponsor, this issue has been implemented and will be included in 2.9.

See Enunciate-Specific Annotations, @responseExample. See also @requestExample.

@stoicflame
Copy link
Owner

Enunciate 2.9.0 has been released.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

3 participants