Support for "examples" field in "requestBody" for Open API 3 Swagger spec in NSwag core.
See original GitHub issueHi there, We are trying to upload a Open API 3 swagger spec using NSwag core. We are getting this error “Value cannot be null. [key]”.
After debugging, the following line doc.ToJson()
is where we are getting the error:
var doc = OpenApiYamlDocument.FromYamlAsync(sd.Json).Result;
sd.Json = doc.ToJson();
The error is as follows:
"Value cannot be null. (Parameter 'key')"
I am not sure if its Json serialisation issue.
{
"openapi": "3.0.1",
"paths": {
"/listener": {
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/listenerPrimary"
},
"examples": {
"creation-of-primary-mobileAccess": {
"$ref": "#/components/examples/serviceCreationNotification"
}
}
}
},
"description": "Notification Resource Models",
"required": true
}
}
},
"servers": {},
"components": {
"schemas": {},
"examples": {
"serviceCreationNotification": {
"value": {
"eventId": "6a51c8e5-2629-47ef-b562-288b5569ac56",
"eventTime": "string",
"eventType": "serviceCreationNotification",
}
}
}
}
Turns out if we remove “examples” field from the “requestBody” it works fine. Below works fine:
{
"openapi": "3.0.1",
"paths": {
"/listener": {
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/listenerPrimary"
},
}
},
"description": "Notification Resource Models",
"required": true
}
}
},
"servers": {},
"components": {
"schemas": {},
"examples": {
"serviceCreationNotification": {
"value": {
"eventId": "6a51c8e5-2629-47ef-b562-288b5569ac56",
"eventTime": "string",
"eventType": "serviceCreationNotification",
}
}
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
OpenAPI Specification - Version 3.0.3
The OpenAPI Specification defines a standard interface to RESTful APIs which allows both humans and computers to understand service capabilities without ...
Read more >Describing Request Body
Request bodies are typically used with “create” and “update” operations (POST, PUT, PATCH). For example, when creating a resource using POST or PUT,...
Read more >Get started with NSwag and ASP.NET Core
Install NSwag to: Generate the Swagger specification for the implemented web API. Serve the Swagger UI to browse and test the web API....
Read more >Using OpenAPI and Swagger UI
This guide explains how your Quarkus application can expose its API description through an OpenAPI specification and how you can test it via...
Read more >OpenAPI Specification v3.1.0 | Introduction, Definitions, & ...
The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Ok the JSON above was failing, now fixed.
Thanks @RicoSuter for the patch. I can confirm the file upload are working perfectly with the latest version 3.10.4. The team appreciates your help 👍 👏