If we look at the message API (for example) I want it to be able
- create message
- get a message
- update message
The message contains an external link (unique identifier from the consumer)
- This external_file must be set when created using a POST request
- This external_id parameter cannot be changed using PATCH
What is the solution for its implementation?
API Example:
swagger: '2.0'
host: api.com
basePath: /v2
schemes:
- https
info:
title: dummy
version: 1.0.0
consumes:
- application/json
produces:
- application/json
paths:
/messages:
post:
summary: Create a message
parameters:
- name: message
in: body
required: true
schema:
$ref: '#/definitions/Message'
responses:
201:
description: Ok
schema:
$ref: '#/definitions/Message'
/messages/{id}:
get:
summary: "Get a message by ID"
parameters:
- name: id
in: path
description: The message ID
required: true
type: string
format: uuid
responses:
200:
description: OK - the message
schema:
$ref: '#/definitions/Message'
patch:
summary: Modify a message
parameters:
- name: id
in: path
description: The message ID
required: true
type: string
format: uuid
- name: message
in: body
required: true
schema:
$ref: '#/definitions/Message'
responses:
201:
description: Ok
schema:
$ref: '#/definitions/Message'
definitions:
Message:
type: object
required:
- id
- external_id
- title
- content
- created_at
properties:
id:
type: string
readOnly: true
external_id:
type: string
description: "Your own reference ID"
title:
type: string
content:
type: string
created_at:
type: string
format: date-time
readOnly: true
The only solutions I see:
- defining 2 definitions (Message and UpdateMessage) with allOf
- without using the definition in the PATCH method or in the GET / POST method
? , PATCH, ( ).
, .