Class is a XML schema which prevents you for using <class> tag in a wrong way. Usually it is used during response/request generation (more info here).
XML describing is a way to get java class with specified fields, constructor, getters and setters fast.
First of all you need specify the name of the future class in attribute 'name' in <class> tag. Note, that it must match restrictions.
Good names: 'AddUserRequest', 'DeleteFirmRequest', 'CompanyResponse'.
Bad names: 'addUser', 'addFirmReq', 'Companyresponse'.
Then you should specify all required data for this class. There are many options for data types specifying. They are listed below
- <byte>
- <short>
- <integer>
- <long>
- <float>
- <double>
- <biginteger>
- <bigdecimal>
- <string>
- <boolean>
- <char>
- <localdate>
- <localtime>
- <localdatetime>
- <instant>
- <offsettime>
- <offsetdatetime>
- <zoneddatetime>
- <object>
- <enum>
- <array>
- <list>
- <set>
Note: you should fill attributes 'name' and 'description' for each tag! Also each of listed tags have attributes 'required', 'constraint' and 'defaultData', which are optional.
Also some tags have additional attributes. Let's take a look on them.
Tag <string> has attribute 'stubData'. It is used for placing StubData annotation which is used by StubFactory for creating different mock data. For more info read this one.
Tag <instant> has attribute 'pattern'. By default it is 'yyyy-MM-dd HH:mm:ss'.
Tag <object> (as <enum>) has required attribute 'ofType'. Since they are wrappers, you need to specify internal objects. You should pass to this attribute name of another class described using XML and <class> notation.
Tag <array> (as <list>, <set>) as described above has attribute 'ofType'. You get an array (list, set) of type which you put in 'ofType' attribute.
Though usually responses and requests are placed near to its endpoint, you also can place it in resources/spec/__def__/models.static. In such case you need to specify the name of the file in endpoint's 'include' attribute.