Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Example property to OpenApi attribute #589

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

PaulNieuwelaar
Copy link

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
Copy link
Author

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

@duncanworthy
Copy link

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.

@adrian-gheorghe
Copy link

Very much interested in this as well!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants