Annotation Type Produces


  • @Documented
    @Retention(RUNTIME)
    @Target({METHOD,TYPE})
    @Inherited
    public @interface Produces

    An annotation to indicate the MediaTypes produced by a particular component.

    Generally with controllers one can use the produces attribute of the Controller annotation, however this annotation is more generic and applies to any component

    Since:
    1.0
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      boolean single
      In the case of reactive types this member indicates whether only a single result is returned.
      java.lang.String[] value  
    • Element Detail

      • value

        java.lang.String[] value
        Returns:
        The MediaType values that this component is able to produce
        Default:
        {"application/json"}
      • single

        @AliasFor(annotation=io.micronaut.core.async.annotation.SingleResult.class,
                  member="value")
        boolean single

        In the case of reactive types this member indicates whether only a single result is returned. Normally this annotation is unnecessary unless the declared type doesn't indicate how many items are emitted.

        For JSON with single = false if an Reactive streams Publisher type is returned these will be automatically wrapped in an Array type to ensure valid JSON is returned.

        If single = true it is expected that only a single result will be emitted and the result will not be wrapped in a JSON array.

        Returns:
        True if only a single result is emitted
        Default:
        false