Skip to content

danieltott/openapi-3.0-nullable-object-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

openapi-3.0-nullable-object-example

See full article here

Feel free to leave any questions or comments in the issues!

To use

pnpm install
pnpm start

Then make a request to http://localhost:3000/test

If your response matches the schema, you should see your expected JSON. If not, you'll get an error.

To see this in action, in index.js, uncomment the notActuallyNullableObjectWithAllOf line:

-     // notActuallyNullableObjectWithAllOf: null,
+     notActuallyNullableObjectWithAllOf: null,

Then after saving, you should see a response similar to this:

{
  "message": "/response/notActuallyNullableObjectWithAllOf must be object, /response/notActuallyNullableObjectWithAllOf must be object",
  "errors": [
    {
      "path": "/response/notActuallyNullableObjectWithAllOf",
      "message": "must be object",
      "errorCode": "type.openapi.validation"
    },
    {
      "path": "/response/notActuallyNullableObjectWithAllOf",
      "message": "must be object",
      "errorCode": "type.openapi.validation"
    }
  ]
}

About

Example of a nullable object using anyOf, oneOf, or allOf

Resources

License

Code of conduct

Stars

Watchers

Forks