owen2jan's avatar

how to document 422 response (openapi)

What is the correct way to document errors. I have tried :

"responses": {
	"201": {
		"description": "Created successfully"
	},
	"422": {
		"description": "Unprocessable entity",
		"content": {
			"application/json": {
				"schema": {
					"type": "object",
					"properties": {
						"message": {
							"type": "string",
							"example": "<Field> required and 2 more errors."
						},
						"errors": {
							"type": "array",
							"items": {
								"type": "object",
								"properties": {
									"<field-name>": {
										"type": "string",
										"examlpe": "<Field> required"
}}}}}}}}}}
0 likes
0 replies

Please or to participate in this conversation.