-
Notifications
You must be signed in to change notification settings - Fork 78
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
application/vnd.api+json
in yml files loses the +
on resolve
#249
Comments
@langalex perhaps we can lose the Is your |
@MikeRalphson sorry I thought the package-lock might be important. will do. the |
Ok, thanks, will try and reproduce. |
wow, that was fast, thanks. let me know if I can help. |
@langalex I find pretty amazing that we found the same issue with a difference of 40 minutes xD I'm copying what I wrote in #243 for reference: Today I found I'm experiencing some issues when using response types that include Example: /foo:
get:
summary: Foo
operationId: foo
responses:
200:
$ref: "responses.yaml#/components/responses/Foo" components:
responses:
Foo:
description: Success, returning the root context and list of things
content:
application/ld+json:
schema:
$ref: "schemas.yaml#/components/schemas/Foo" When I try to responses:
'200':
description: 'Success, returning the root context and list of things'
content:
application/ld+json:
schema:
$ref: '#/paths/~1foo/get/responses/200/content/application~1ld%2Bjson/schema'
x-miro: 'schemas.yaml#/components/schemas/Foo'
application/ld json:
schema:
title: Thing Description graph
description: A Graph of Things in JSON-LD format.
type: object
... |
Just a note that if one key doesn't include the I'm adding some test cases over at |
Well yes, I didn't mean that they were the same key, just that the linter was trying to create the same entry twice with different values ;-) But I didn't know you could actually write a multi-word key without quoting, TIL, go figure xD |
Another note: in my tests, the curly braces are also being url-encoded in the generated
The swagger documentation actually shows a sample with this and they don't encode them, though I'm not sure which is right:
|
Curly braces definitely do need encoding in url fragment ids / json pointers. We discussed it on an OpenAPI-Specification TSC call. I don't think we've updated the spec examples yet. The documentation on swagger.io is useful, but not authorative. |
Fix and tests for the |
|
This will be fixed in v0.9.0 which will be out hopefully today. |
The fix is in #248 btw so if you can use docker or git to test that I'd appreciate it. |
To make testing easier, I have released v0.9.0-1:
Please confirm if its working for you. If not, we need more tests :D |
I have just tested master and got this, which is really not what i was expecting xD:
Just to be sure, I have just run the file through the python pyyaml module, and it didn't complain about the yaml syntax. :-? |
Can you share more details so we can look look into it? |
This is either an issue with pyaml, or an issue with js-yaml, so I'm not sure what we can do about it. There is a suggestion to switch from js-yaml to yaml which could help us skate around the issue if it is indeed a bug in js-yaml. |
@philsturgeon |
works for me now 👍 |
@pderaaij I'm sorry i can't disclose the whole file, it's part of an internal project which I'm not at liberty to share :-/ I managed to solve the issue with heavy refactoring, at least now the content type with What I can tell you is the behaviour I observed:
Let me know if I can help with anything else. Keep up the great work. |
Hmm, easier said than done, unless all your included files are structurally valid OAS 3 documents in and of themselves (i.e. include
Thanks for the kind words! |
It might also be worth bumping up the use of the |
@MikeRalphson I actually reformated the included files to be valid OAS 3 documents, that was the way I found what the issues with them were :-)
Do you mean that you need to improve the verbose option, or that I should be able to see where the problem was with |
Would be great if you can test that. My feeling is that speccy is not passing the verbose option correctly if I remember well from earlier tasks. If so I'll dive into that later this week. |
OK, so it sounds like we should definitely make that process simpler. And yes, it was using the |
I have just done some tests: Verbose output (a single The YAML error doesn't help much, because it gives back an escaped, single-line yaml string, and seems to point to the column where the error is, though I didn't have much luck finding exactly where the problem was in here (I even did some awk'ing to obtain the un-escaped version). The error reported is quite internal, such as:
What I have found is that the errors seem to be caused by indentation of comments, but only in some cases. Honestly, I don't know if this is yaml-compliant, but I had a couple of not indented at the same level as the parent element comments (typical IDE multiple lines comment). Other yaml parsers don't seem to have an issue with those, but the one used by speccy does. This seems to only happen on As an example, this works inside of a referenced file: ...
# Something else
# Indented not at the same level on top, works
200About:
description: Success, returning the about information
# Something else
... This doesn't: ...
# Something else
200About:
description: Success, returning the about information
# Indented not at the same level on the bottom, fails
# Something else
... |
Issue #243 would cover making I'm working on a PR for the |
I've created #265 to ensure speccy respects the verbosity levels passed on via the CLI. |
Running my openapi.yml file though
speccy resolve
creates invalid files when keys include a+
symbol.Detailed description
My openapi.yml file includes keys that contain a
+
(file abbreviated for clarity):When running this file through
speccy resolve
, the resolved file contains the originalapplication/vnd.api+json
plus another key on the same level where the plus has been replaced with a space (application/vnd.api json
) and the$ref
pointing (but incorrectly) to the newly inserted key.The
%2B
in the$ref
is actually a+
again when running it throughdecodeURIComponent
. It looks like somewhere these keys are www-form encoded back and forth and the created the wrong keys.When removing the
+
, everythung works as expected and there is no more duplicate key.I think this is a bug. Not sure if in speccy or one of the dependencies.
Your environment
The text was updated successfully, but these errors were encountered: