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

java.lang.IllegalStateException: Failed to convert JSON to YAML: when using @documentationExample #36

Open
jdimeo opened this issue Mar 18, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@jdimeo
Copy link

jdimeo commented Mar 18, 2021

It appears that whenever you use a @documentationExample, it gets written to the YAML improperly and causes a parse error. I tried with single quotes and double quotes neither fixed it.

For example, this bean:

public class ScoreResult {
    /**
     * The score code.
     * @documentationExample SCRCD
     */
    @Getter(onMethod_ = @Size(max = 32))
    private String scoreCode;
    ...

throws this error:

[ERROR] Failed to execute goal com.webcohesion.enunciate:enunciate-maven-plugin:2.12.1:docs (default) on project scoring-api-server: Error invoking Enunciate.: java.lang.IllegalStateException: Failed to convert JSON to YAML:
[ERROR] SCRCD: Unrecognized token 'SCRCD': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')
[ERROR]  at [Source: (byte[])"SCRCD"; line: 1, column: 6]
@stoicflame stoicflame added the bug Something isn't working label Mar 18, 2021
@jdimeo
Copy link
Author

jdimeo commented Mar 31, 2021

I've temporarily fixed this on our fork:
ElderResearch@8a61d00

However, I'm not opening a PR because I think this makes the wrong assumptions. Currently, it was expecting every example to be valid JSON. Now, I'm expecting it to never be JSON/an object, but rather a scalar value (like I have in my example above). This makes the most sense for field-level examples, but could break class-level examples.

Why is it using the ObjectTypeRenderer? do we need to annotate our method somehow to clue it in to the fact that it's a scalar value? perhaps this is a documentation and/or better stack trace issue rather than a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants