Simplified Representations (v2 Draft)

Simplified profile urn:org.apache.causeway/v2

Draft

Response Contract

Table 1. Representation Types (Content-Type header attribute 'repr-type')
Type Description Http Return Code

object

when a domain object is rendered

  • 404: when null

  • 200: otherwise

object-collection

when a parented collection is rendered

  • 404: when null or empty

  • 200: otherwise

list

when a standalone collection is rendered

  • 404: when null or empty

  • 200: otherwise

value

when a single value is rendered

  • 404: when null

  • 200: otherwise

values

when a list of (nullable) values is rendered

  • 404: when null or empty

  • 200: otherwise

void

when a void action result is rendered

200

Scalar Value DTO

A generic scalar value wrapper, that supports representation of null references as required for rendering lists of values (repr-type=values).

ScalarValueDtoV2
@Data
class ScalarValueDtoV2 {

   private String type;
   private Object value;

}

Conversation Examples

Table 2. Autogenerated by RestServiceSimpifiedRepresentationTest
Action Request and Response
@Action
void voidResult() {
    /*...*/
}

REQUEST

{

}

RESPONSE

  • HTTP return code: 200

  • Representation Type: VOID

[]
@Action
String string() {
    /*...*/
}

REQUEST

{

}

RESPONSE

  • HTTP return code: 200

  • Representation Type: VALUE

{"type":"String","value":"aString"}
@Action
String stringNull() {
    /*...*/
}

REQUEST

{

}

RESPONSE

  • HTTP return code: 404

  • Representation Type: null

@Action
String[] stringArray() {
    /*...*/
}

REQUEST

{

}

RESPONSE

  • HTTP return code: 200

  • Representation Type: VALUES

[{"type":"String","value":"Hello"},{"type":"String","value":"World!"}]
@Action
String[] stringArrayEmpty() {
    /*...*/
}

REQUEST

{

}

RESPONSE

  • HTTP return code: 404

  • Representation Type: null

@Action
String[] stringArrayNull() {
    /*...*/
}

REQUEST

{

}

RESPONSE

  • HTTP return code: 404

  • Representation Type: null

@Action
List<String> stringList() {
    /*...*/
}

REQUEST

{

}

RESPONSE

  • HTTP return code: 200

  • Representation Type: VALUES

[{"type":"String","value":"Hello"},{"type":"String","value":"World!"}]
@Action
List<String> stringListEmpty() {
    /*...*/
}

REQUEST

{

}

RESPONSE

  • HTTP return code: 404

  • Representation Type: null

@Action
List<String> stringListNull() {
    /*...*/
}

REQUEST

{

}

RESPONSE

  • HTTP return code: 404

  • Representation Type: null

@Action
Integer integer() {
    /*...*/
}

REQUEST

{

}

RESPONSE

  • HTTP return code: 200

  • Representation Type: VALUE

{"type":"Integer","value":123}
@Action
Integer integerNull() {
    /*...*/
}

REQUEST

{

}

RESPONSE

  • HTTP return code: 404

  • Representation Type: null

@Action
int integerPrimitive() {
    /*...*/
}

REQUEST

{

}

RESPONSE

  • HTTP return code: 200

  • Representation Type: VALUE

{"type":"Integer","value":123}
@Action
BigInteger bigInteger() {
    /*...*/
}

REQUEST

{

}

RESPONSE

  • HTTP return code: 200

  • Representation Type: VALUE

{"type":"BigInteger","value":18446744073709551614}
@Action
BigInteger bigIntegerNull() {
    /*...*/
}

REQUEST

{

}

RESPONSE

  • HTTP return code: 404

  • Representation Type: null

@Action
List<BigInteger> bigIntegerList() {
    /*...*/
}

REQUEST

{

}

RESPONSE

  • HTTP return code: 200

  • Representation Type: VALUES

[{"type":"BigInteger","value":0},{"type":"BigInteger","value":18446744073709551614}]
@Action
Customer customer() {
    /*...*/
}

REQUEST

{

}

RESPONSE

  • HTTP return code: 200

  • Representation Type: OBJECT

{"age":22,"name":"Hello World!"}
@Action
Customer customerNull() {
    /*...*/
}

REQUEST

{

}

RESPONSE

  • HTTP return code: 404

  • Representation Type: null

@Action
List<Customer> customerList() {
    /*...*/
}

REQUEST

{

}

RESPONSE

  • HTTP return code: 200

  • Representation Type: LIST

[{"age":22,"name":"Alice"},{"age":33,"name":"Bob"}]
@Action
List<Customer> customerListEmpty() {
    /*...*/
}

REQUEST

{

}

RESPONSE

  • HTTP return code: 404

  • Representation Type: null

@Action
List<Customer> customerListNull() {
    /*...*/
}

REQUEST

{

}

RESPONSE

  • HTTP return code: 404

  • Representation Type: null

@Action
List<BigComplex> complexList() {
    /*...*/
}

REQUEST

{

}

RESPONSE

  • HTTP return code: 200

  • Representation Type: LIST

[{"im":"0","re":"0"},{"im":"-4.3","re":"2.1"}]
@Action
BigComplex complexAdd(
    String are,
    String aim,
    String bre,
    String bim) {
    /*...*/
}

REQUEST

{
   "are": {"value" : "1.0000000000000000000000000000000000000001"},
   "aim": {"value" : "-2.0000000000000000000000000000000000000002"},
   "bre": {"value" : "3"},
   "bim": {"value" : "4"}
}

RESPONSE

  • HTTP return code: 200

  • Representation Type: OBJECT

{"im":"1.9999999999999999999999999999999999999998","re":"4.0000000000000000000000000000000000000001"}