Empty object as response
See original GitHub issueI have a schema that is generating an empty object {}
in the response, but it has a targetSchema
defined. Here’s my schema:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "API",
"type": "object",
"definitions": {
"user": {
"title": "User",
"type": "object",
"properties": {
"id": {
"title": "User ID",
"type": "number"
},
"firstName": {
"title": "First Name",
"type": "string"
},
"lastName": {
"title": "Last Name",
"type": "string"
}
}
}
},
"links": [
{
"title": "Get User",
"rel": "item",
"type": "object",
"description": "Retrieve a user by ID",
"href": "/api/v1/users/{id}",
"method": "GET",
"targetSchema": {
"$ref": "#/definitions/user"
}
}
]
}
![screen shot 2017-06-13 at 12 38 48 pm](https://user-images.githubusercontent.com/1824185/27093595-574bc808-5035-11e7-9523-8ef312dfdfc2.png)
It seems it should be displaying a user object, or maybe I’m missing something.
Issue Analytics
- State:
- Created 6 years ago
- Comments:20 (10 by maintainers)
Top Results From Across the Web
What does an empty object API response mean? #420 - GitHub
The empty object is needed because a valid JSON response is needed. It's not to prevent something breaking in backbone specifically.
Read more >REST API Best practice ? return Empty object vs no object
The better practice is to send an empty array. The reason is when someone calls your API and expect expiring_credits ...
Read more >Returning empty response object - ServiceNow Community
I am trying to generate response object from a different function and return it back but it does return only empty "".
Read more >Handling JSON null and empty arrays and objects - IBM
Handling null and empty arrays and objects used in JSON data is described. JSON data has the concept of null and empty arrays...
Read more >5 Ways to Check If an Object Is Empty in JavaScript | Built In
5 Ways to Check If an Object Is Empty in JavaScript · 1. Use Object.keys · 2. Loop Over Object Properties With for…in...
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
@krystalmonolith I believe doca ignores anything without hyperschema
links
. It’s not intended as a data type documentation system, just an API documentation system. You could probably get it to work with non-API data types with a little tinkering, but it’s not in-scope for the project as it currently exists.@pr0digi
This set of packages is being deprecated in favor of the JSON Schema Tools monorepo. Contributions are still welcome here but most work will be done on the new packages.
One of the big reasons for rewriting the Doca suite into a new set of packages was to adhere closely to the JSON Hyper-Schema specification, and make it easier to support newer drafts. This should eliminate unexpected schema behavior (except possibly when using Cloudflare-defined extensions, but hopefully we can be more clear about how those work alongside of standard schema constructs).
The new UI is still being designed, but hopefully this should be handled in it. Feel free to file at cloudflare/json-schema-tools if you want to track this specifically.