I have a generic Java type like this:
class Response<D> {
  List<D> data;
}
and want to create something similar with RAML 1.0 (where I am new to).
My first approach was
types:
  Response:
    type: object
    properties:
      data: object[]
and when using it
body:
  type: Response
    properties:
      data: MyDataType[]
From API-Workbench I always get an "Illegal override of property data inherited from Response".
The other idea would be to use repeat:
types:
  Response:
    type: object
    properties:
      data: object
      repeat: true
and respectively
body:
  type: Response
    properties:
      data: MyDataType
      repeat: true
Now the illegal override is gone but in the API-Console I now get an "Uncaught TypeError".
How to solve that? Or do I need a completely different approach? Any idea?
As I understand, Response is abstracting different types of data, but has similar format. One approach is to abstract the similarity in the response using resourceTypes and define your concrete data in types. 
#%RAML 1.0
title: New API
version: v1
baseUri: http://api.samplehost.com
mediaType: application/json
types:
  User:
    usage: A user in the system    
    properties:
      firstname:
        required: true
      lastname:
        required: true
  ArticleId:
    usage: An id of any article in the system
    type: number
  Article:
    usage: Pattern for any article in the system
    properties:
      id:
        type: ArticleId
        required: true
      created:
        type: date
        required: true
#######################################
# the following captures the similarity:
#######################################
resourceTypes:
  collection:
    get:
      responses:
        200:
          body:
            properties:
              data: <<typename>>[]
###############
# API:
############### 
/user:
  description: All the users
  type:
    collection:
      typename: User
/article:
  description: All the articles
  type:
    collection:
      typename: Article     
                        I see the following options in solving this issue:
List<MyDataType>, and revise the generated output. E.g. using the same raml-java-parser from point 1. type{} or the fact that exterior types might need an inclusion. Maybe this answer link helps on this behalf.I didn't knew anything about RAML 20 minutes ago, so don't treat this as a complete answer but a quick guess.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With