-
Notifications
You must be signed in to change notification settings - Fork 677
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
Documentation of Enums #739
Comments
So, I've tried to make it work with an ISchemaFilter, but sadly this filter is called before the XML info is added, so everything gets overridden. In the end, I resorted to writing an IModelFilter and adding that via Reflection because all the ModelFilter methods are
When will the ModelFilter methods be opened up? |
Under the hood, IncludeXmlComments just wires up an operation filter and a schema filter. So, if you apply your Schema filter after that call, it should happen in the desired order. However, Schema Filters are currently only applied to "object" schema's and therefore won't execute against an "enum" schema. There is a PR that's close to being merged that will apply schema filters everywhere: #799 Once this is in place, your task should be fairly straightforward |
@LodewijkSioen Did you ever get an implementation working with ISchemaFilter? Would be interested to see your approach as I am facing a similar challenge. |
Well, I think we used the reflection as described above, but I would need to check this. Let me get back to you. |
We just used the code as above. The EnumFilter itself looks like this:
|
See PR #799 which adds support to apply schema filters on all schema types, including enums. This will make it very simple to resolve this issue with a simple Schema Filter that enhances all enum descriptions. It's worth noting that in this version of SB, you'll need explicitly opt in to this behavior with the ApplyFiltersToAllSchemas config settting. |
I'm unclear on if there now is a ("built-in") way in Swashbuckle to document enum descriptions or if I have to implement an ISchemaFilter. What would, currently, be the best way to get enum descriptions documented by Swashbuckle? And I'm assuming I would need to use the |
As a work-around, I was able to re-use the code here: |
I have a model with an enum.
This enum is annotated with xml-comments.
This results in the following json info:
I would like to see the annotations of the enumvalues in the swagger json. There is a proposal on the Open Spec to support this, but nothing official. For now I would be happy to have a way to add the descriptions of the enumvalues to the description of the model property. Like this, for example:
I've played around with all kinds of filters, but the only thing I can find to do something like this is using
MapType<>
for each enum individually. But that doesn't really scale.Am I missing something, or do you accept a pull request to add this?
The text was updated successfully, but these errors were encountered: