enunciate icon indicating copy to clipboard operation
enunciate copied to clipboard

xml schema support for bean validation annotations

Open laaksonel opened this issue 8 years ago • 2 comments

I see there's support for bean validation annotations in document constraints but not in schema generation. It would be nice if schema generation would take for example @Size annotation into account and generate restriction for that annotated field. For example if I have a field:

@Size(max = 10)
private String foo;

Then the generated schema would look like this:

<xs:element name="foo">
    <xs:simpleType>
        <xs:restriction base="xs:string">
            <xs:maxLength value="10" />
         </xs:restriction>
     </xs:simpleType>
</xs:element>

laaksonel avatar Nov 08 '16 19:11 laaksonel

I started looking into this.

It's a great idea, but it's quite a bit of work, so I'm pulling it off the release plan for now.

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

stoicflame avatar Dec 16 '16 21:12 stoicflame

We have the same issue in JAXB documentation. If a DTO has a field annotated @Size in the Data Type section there is no documentation. Looking where BeanValidationUtils is used:

  • Attribute.java in jaxb module documents use only required attribute. Anyway I do not have any evidence of this in the documentation, for example company is NotNull and Size annotated and the result is:
name    | data type   | type    | namespace | min/max occurs | description
company | string      | element |           | 0/1            | Gets company
  • ParameterImpl.java in jaxrs module documents also the annotation description

So if the annotation is on the signature of a REST method it is documented otherwise no

nfalco79 avatar Nov 14 '17 09:11 nfalco79