I am trying to create one simple post API through python connexion. Here is my api yaml file:
swagger: "2.0"
info:
title: "My first API"
version: "1.0"
basePath: /v1.0
paths:
/potential:
post:
operationId: api.data.create_potential_data
summary: Create the potential data
parameters:
- name: alertCategory
in: body
required: True
description: The potential API request AlertCategoryDto object with settings of alert category (categorySystemName, alert Kpis etc.)
schema:
$ref: "#/definitions/alert"
responses:
201:
description: Successfully created potential data
definitions:
alert:
properties:
systemName:
type: string
name:
type: string
moduleSystemName:
type: string
But for one of the attributes name
we allow user to enter null
value. And if they really do this, we will get the error: None type is not of type 'string'
So is there anyway in swagger 2.0 to make the attributes nullable? Cannot find much information online. Thanks!
Thanks to @Danilo's help I found the answer from connexion's documentation here:
In a word, adding x-nullable = true
will resolve this issue.