-
Notifications
You must be signed in to change notification settings - Fork 10
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
Allow empty model objects in response example definitions #40
Comments
Is there any reason that the example list has to be empty - for instance is it the case that the type of object that goes into the list is dynamic? |
In the specific use-case I have it's complicated to initialize a valid value (there are a number of nested collection values there, and it just adds noise in the code). |
I took a quick look at defaulting the value instead of throwing the exception but that broke the model definition rendering (it lost the subsequent definitions), so I think this will require a larger change - possibly reworking the renderer algorithm.if you can spot an easy fix then please suggest :) |
I'll try looking into it when tackling #41, though since I'm new to the library, I'm not sure what I'll come up with... |
@ncreep One more thing that might help with regards to the "generating valid examples" problem - for our internal apps using fintrospect, we use Databob to generate valid random values for objects with no boilerplate. It works out of the box on everything we've tried, and you can provide generators for any other type that you might need: https://github.com/daviddenton/databob |
Thanks for the suggestion. Although I'm definitely in favor of generating randomized data (be it for tests or for the schema examples), sadly, our codebase is not there yet, it'll take non-trivial effort to get there. And some of the types that we are using are quite messy (as in, deeply nested multiple implementations of a unsealed trait), the problematic one that triggered this issue being one of them. |
I've found myself getting the same error. In my case, it's a recursive definition (a job that can have child jobs, that can have child jobs, etc...). So the list needs to be empty at some point. Is that not something that the JsonToJsonSchema could handle? |
Hi,
I'm trying to render an example value with the Swagger renderer. My example value contains an empty list and thus
JsonToJsonSchema
throws:In my case, it would still be useful to actually render the example value, despite not knowing the exact type of the array (I don't care if it's considered to be
Object
or something).Could it be possible to not throw the exception and have some fallback rendering of the example value without a schema?
Thanks
The text was updated successfully, but these errors were encountered: