grape-swagger
                                
                                 grape-swagger copied to clipboard
                                
                                    grape-swagger copied to clipboard
                            
                            
                            
                        Curly brackets in URLs
I am having trouble generating source code from documentation generated by this tool.
I opened a ticket with the codegen devs, but they are thinking this is an issue with the tool
https://github.com/swagger-api/swagger-codegen/issues/379#issuecomment-70694922
Basically, they don't think you should be using curly brackets in the urls.
Any thoughts?
I don't believe grape-swagger generates things like these or it shouldn't matter. Care to build a case that reproduces this problem?
I haven't used grape or grape-swagger, so I am kinda winging it here, but I see in one of your rspec tests, you are verifying that the outputted json has .{format} in it
https://github.com/tim-vandecasteele/grape-swagger/blob/e977feac26d2ba125d92067e3f6a433738415131/spec/simple_mounted_api_spec.rb#L77
Fair enough, but it hasn't been a problem for anybody, so why and how is it "not working"? With a repro we can take a look.
@dblock I have one of the swagger devs saying this is not best practice.
"using curly braces in actual URLs is... not recommended" -@webron from swagger.io https://github.com/swagger-api/swagger-codegen/issues/379#issuecomment-70694922
Have you had other people successfully use the swagger-codegen to generate code from documentation generated by this gem?
Best practice and bug are two different things. I think we should narrow down why it's not working first before we go changing things.
Haven't worked with swagger-codegen personally.
@KevinColemanInc trying to do that right now and hitting the exact same problem as you
ValidationError(articles:api/articles.json:get,responseClass is required,ERROR)
ValidationError(articles:api/articles/{id}.json:get,responseClass is required,ERROR)
ValidationError(articles:api/articles/{id}.json:put,responseClass is required,ERROR)
From RFC 1738 -
   Unsafe:
   Characters can be unsafe for a number of reasons.  The space
   character is unsafe because significant spaces may disappear and
   insignificant spaces may be introduced when URLs are transcribed or
   typeset or subjected to the treatment of word-processing programs.
   The characters "<" and ">" are unsafe because they are used as the
   delimiters around URLs in free text; the quote mark (""") is used to
   delimit URLs in some systems.  The character "#" is unsafe and should
   always be encoded because it is used in World Wide Web and in other
   systems to delimit a URL from a fragment/anchor identifier that might
   follow it.  The character "%" is unsafe because it is used for
   encodings of other characters.  **Other characters are unsafe because
   gateways and other transport agents are known to sometimes modify
   such characters. These characters are "{", "}", "|", "\", "^", "~",
   "[", "]", and "`".**
Can someone help me see the problem, maybe a test project?
I'm about to board a plane, but maybe we can set to talk sometime in our IRC channel? It may be easier to explain instead of going back and forth with comments. On Jan 30, 2015 6:38 AM, "Daniel Doubrovkine (dB.) @dblockdotorg" < [email protected]> wrote:
Can someone help me see the problem, maybe a test project?
— Reply to this email directly or view it on GitHub https://github.com/tim-vandecasteele/grape-swagger/issues/197#issuecomment-72188937 .
Someone who understands what/why/where should fix the problem in a way that works for everybody, really.
The solution should be simple. As far as I understand, the paths listed in the resource listing (that is, the api-docs) all have a .{format} extension and the api declarations themselves are hosted using the .json extension.
The solution can be one of two:
- Replace the .{format}extension with.jsonand that would be just fine.
- For consistency, remove the .{format}altogether and remove the.jsonextension as well from the hosted api declarations.
APIs that are JSON by default omit and no longer respond to .json btw.
Okay, but keep in mind I'm talking about the actual API operations but rather the the Swagger documentation endpoints produced by grape-swagger.
Yes. Either way I would take a PR that does this.
Wish I could help there, unfortunately my knowledge of ruby ends with about recognizing the file extension.
So just to clarify(or add more noise:))
We should not use {format} at all.
The main point:
- grape-swaggerroot response(- /swagger_docby default) includes resources listing(RL) paths
- grape-swaggerRL object('/swagger_doc/resource' for example) includes apis definition(AD) paths
Removing {format} from RL and AD paths should be separated.
- We already have formatoption ingrape-swaggerwhich applied for endpoints generated bygrape-swagger(RL endpoints) but it does not affect RL paths. We can use it to generate RL paths with/without extensions. As for me I would just a specify:jsonformat by default ingrape-swaggerand removeformatoption at all. Because it only used to generate proper RL path, so nevermind if extension applied or not.
- We should generate AD paths with/without .jsonextension usinggrapeapplication(API) format settings(not agrape-swagger).
am I right?
I think @dm1try is right.