-
-
Notifications
You must be signed in to change notification settings - Fork 148
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
YAML Mapper not quoting #
in cases where it should
#492
Comments
Which version? Also: are you having a problem here? My understanding of the behavior here is that quoting if the line starts with |
The problem is that I write an openapi file and there should be quotation in the ref. References are referenced using the hashtag With local references everything works, but with remote references that are in another file, the " are then deleted and the reference is therefore not valid. Version is 2.17.2 EDIT: Maybe this something special for open api, right? I tried to remove the feature, but then I have a lot of unnecessary quotes. So in general I like this feature Or here is the reason StringQuotingChecker#valueHasQuotableChar
EDIT EDIT: I solved it like this
|
@MelleD would you able to provide test code to show the issue? It sounds like |
Yes sure: Here is an small open api example in JSON
You see the critical point is the 400 status code with the reference. I read the json and would like to convert it to YAML Test case:
Outcome is:
You see on 400 there are the missing quotes With the YAMLFactory and this class is working, but not sure if this a general rule or is this related to the open api spec with the hashtag reference see: https://swagger.io/docs/specification/using-ref/
Maybe a solution is to create a new feature flag for OPEN_API
|
I am sorry -- I meant a smaller self-contained test case. Not an in-detail manual explanation. EDIT: I missed the reproduction that is in there. Although it does not use assertions (but "look, see what happens") so need clarification still. |
#
in cases where it should
(re-worded title based on my high-level understanding) |
He? Just execute the unit test and you see the issue? What is smaller than a unit test? |
Uh oh. Sorry. I missed the obvious one -- you did include it. N/m. :) |
@cowtowncoder ok :) . I tried to use a real and valid open api example. |
@MelleD much appreciated: and just to make sure, I don't mind explanations that complement reproduction. But occasionally I get only explanations so I ... jumped to conclusions here. |
@MelleD One more thing tho: I can see missing quotes (as per functionality) -- but is the actual problem that trying to re-read generated YAML will be missing content after I mean, not having quotes is intentional if BUT ONLY IF it does not result in problems parsing resulting YAML. On feature flag for Open API: no, I don't think that should be needed -- either output with URL anchors works in general or it doesn't. |
Ok. After adding a simple test for round-tripping, it looks like there IS NOT actual loss of content -- String value is retained and Now: if you do want to force quoting in this case, the use of custom Closing; may be re-opened if I misunderstood something, or new problems surface. |
@MelleD That is semantically equivalent: quoting is optional unless it affects decoding. If not, please show how is it different wrt deserialized content differing. Usage via Open API in itself is irrelevant, what matters is logical content, not physical encoding. Screenshot above does not show such problem. |
Also possible that the Editor have a bug, without quotes currently you cannot jump to the reference with quotes it’s working |
@MelleD yes, that sounds plausible. I would suggest you use the custom |
If I put a path in front of a hashtag, the Quotes is deleted every time. If there is nothing in front of the hashtag, the quotes are retained
This happens only with the feature
YAMLGenerator.Feature.MINIMIZE_QUOTES
Example
String yaml = new YAMLMapper().enable( YAMLGenerator.Feature.MINIMIZE_QUOTES ).writeValueAsString( json );
Path is
"#/components/responses/ClientError"
Out come is
If I put something in front of the hashtag the " are deleted
Path is
"core-api.yaml#/components/responses/ClientError"
Out come is which is invalid in open api. I would also expect the "
I this a bug or currently intended with the
YAMLGenerator.Feature.MINIMIZE_QUOTES
?The text was updated successfully, but these errors were encountered: