azure-functions-openapi-extension icon indicating copy to clipboard operation
azure-functions-openapi-extension copied to clipboard

Added Example property to OpenApi attribute

Open PaulNieuwelaar opened this issue 1 year ago • 3 comments

Added new Example property to the OpenApiPropertyAttribute. Allows settings an example value at an individual property level rather than only at the class/model. This is included in the OpenApi schema for the property and displays in the swagger schema and example.

Follows the same format as the Default property, i.e. allows string, number, boolean.

Example:

[OpenApiProperty(Description = "The name of the pet", Example = "Dog")]
public string Name { get; set; }

Property schema includes the example: example1

Model/schema example value also includes the property example: example2

PaulNieuwelaar avatar Jun 26 '23 22:06 PaulNieuwelaar

@microsoft-github-policy-service agree company="Magnetism"

PaulNieuwelaar avatar Jun 26 '23 22:06 PaulNieuwelaar

Is this PR likely to be reviewed any time soon? I have colleagues who would like to submit similar contributions for elements like "format", "minimum", "maximum", etc. At the moment there are too many things missing compared to what can be manually produced in SwaggerHub, and that feature gap is delaying our adoption of the APIM Developer Portal as a means of publishing APIs.

duncanworthy avatar Aug 22 '23 16:08 duncanworthy

Very much interested in this as well!

adrian-gheorghe avatar Nov 01 '23 16:11 adrian-gheorghe