A
A
Anton Ivanov2016-04-16 07:41:38
API
Anton Ivanov, 2016-04-16 07:41:38

How in RAML to remove some parameters from the type that is used for the request body?

Hello.
I use RAML 1.0
There is a type Orderwith some fields, including id.
There is a POST request to /orders, in the body of which the "Order" object is passed, but without the id field.
Is there any way to exclude this field from the list of type fields for the request body?
that is, this type is specified both as the type for the request body and as the type of the response structure. You don’t want to use 2 different types, or you don’t want an inline description, since the Order type has all fields with descriptions and this will be a duplication of 80% of the information. You can also create an OrderRequest type and inherit it in Orders, but this is also some kind of crutch ...
Is there any solution?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Stanislav Makarov, 2016-04-16
@Nipheris

create an OrderRequest type and inherit it in Orders, but this is also some kind of crutch ...

I agree. But why not both Order and OrderRequest inherit from OrderInfo, which will have all the common fields?

A
Alexander Malikov, 2017-01-06
@malikov_a

RAML 1.0 supports inheritance from several types:

#%RAML 1.0
title: Example API
version: v1

types: 
  Order:
    type: object
    properties: 
      id:
        type: integer
      date:
        type: integer

  Ext_type:
    type: object
    properties: 
      ext_type_property:
        type: string

  Order_ext:
    type: [Order,Ext_type]

API console processed correctly
What will happen when "mixing" different types did not check.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question