Does the schema support description of an object with dynamic name-value pairs?


#1

This is a question relating both to Spec and Generation:

If my json object looks as follows:

{ "rates": {
    "AUD": 1,
    "USD": 0.8,
    "EUR": 0.75
 ... any other currency here ...
   }
}

In JAX-RS generated code the pojo would likely be similar to this:

private Map<String, Double> rates = new HashMap<String,Double>();
// ... annotated getter and setter 

My questions are:

  1. Is there support for this in RAML? If not what’s the closest way to model it?
  2. Is there support for this in RAML to JAX-RS? If not is there a way to provide a generator for a custom type?

#2

1.Is there support for this in RAML? If not what’s the closest way to model it?

yes it is possible to model it with json schema and pattern properties.

2 Is there support for this in RAML to JAX-RS?

No we do not support it currently however nothing may prevent you from handling it inside of your stubs manually

No currently we do not support generators for custom types, If you have a vision how it might look please file a feature request into https://github.com/mulesoft/raml-for-jax-rs#

Regards,
Pavel