allow examples to be provided for each property in a typedef
See original GitHub issueWhen I’m defining a schema consisting of types containing properties, it would be handy to specify the example values which should appear in the request & response examples that reference that type.
Given a type:
/**
* A song
* @typedef {object} Song
* @property {string} title.required - The title
* @property {string} artist - The artist
* @property {number} year - The year - double
*/
I’d like some way (if it doesn’t already exist) to specify example values of “My Song”, “Artist X”, and “2021” for the 3 properties.
I may have an API GET /api/songs
would automatically have a sample response like
[
{
"song": "My Song",
"artist": "Artist X",
"year": 2021,
}
]
instead of
[
{
"song": "string",
"artist": "string",
"year": 0,
}
]
Other APIs GET /api/song/:name
and PUT /api/song
could each benefit from those example values without duplicating those sample values in @example request
and @example response
blocks.
Eventually, I’d like to have types derived from Song using anyOf which would inherit those sample values for each property.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:7 (4 by maintainers)
Top Results From Across the Web
typedef command - IBM
typedef command. Rational® Synergy supports type-dependent behaviors. For example, you can allow parallel versions for one type of object but not another.
Read more >How to use the typedef struct in C - Educative.io
The C language contains the typedef keyword to allow users to provide alternative names for the primitive (e.g., int) and user-defined (e.g struct)...
Read more >Documentation - Advanced Types - TypeScript
In a mapped type, the new type transforms each property in the old type in the same way. For example, you can make...
Read more >Typedef Task - Apache Ant
For property files each line defines a single data type in the format: ... or types that share the same classpath with multiple...
Read more >Learn JSON Typedef in 5 Minutes
JSON Type Definition (aka “JSON Typedef”, or just “JTD”) schemas are just JSON ... where each key has a separate type of value,...
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 FreeTop 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
Top GitHub Comments
With release 1.6.7 you can do it this way:
@param {string} page.query.required - Page number - json:{"minimum": 0, "example":2}
Hi @mmcfarland-novetta,
Yes, you are right 🤔 we still don’t have support for that. I will mark this as an enhancement to take a look at in future releases.