Skip to content

Explain how the documentaiton type option is matched to class names. Fix... #171

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

Merged
merged 2 commits into from
Dec 14, 2014

Conversation

jhollinger
Copy link
Contributor

... examples. Per issue #159.

@dblock
Copy link
Member

dblock commented Nov 12, 2014

I am confused, does type: API::Entities::Address not work? It should, ultimately it references the same type.

@jhollinger
Copy link
Contributor Author

I was surprised at the behavior as well. But here's a breakdown of a Cat entity:

expose :pajamas, using: API::Entities::Pajamas, documentation: {type: 'API::Pajamas', desc: "The cat's pajamas"}
shows this in Swagger UI:

{
  "id": 0,
  "name": "",
  "pajamas": {
    "id": 0,
    "color": ""
  }
}

expose :pajamas, using: API::Entities::Pajamas, documentation: {type: 'API::Entities::Pajamas', desc: "The cat's pajamas"} gives this:

{
  "id": 0,
  "name": "",
  "pajamas": "API::Entities::Pajamas"
}

expose :pajamas, using: API::Entities::Pajamas, documentation: {desc: "The cat's pajamas"} gives this:

{
  "id": 0,
  "name": "",
  "pajamas": null
}

expose :pajamas, using: API::Entities::Pajamas, documentation: {type: API::Entities::Pajamas, desc: "The cat's pajamas"} results in that endpoint returning nothing at all to Swagger UI.

@jhollinger
Copy link
Contributor Author

The sample app I was using to test is at https://gist.github.com/jhollinger/b1b64357a9fc8caec3c2 if you want to confirm or try some different options. But the only value in type I can find that works is "API::Pajamas".

@dblock
Copy link
Member

dblock commented Nov 12, 2014

Do you think you can turn that into a spec for grape-swagger? I will look at your example either way.

@jhollinger
Copy link
Contributor Author

Probably sometime in the next week, yes.

On Wed, Nov 12, 2014, 10:23 AM Daniel Doubrovkine (dB.) @dblockdotorg <
[email protected]> wrote:

Do you think you can turn that into a spec for grape-swagger? I will look
at your example either way.


Reply to this email directly or view it on GitHub
https://github.com/tim-vandecasteele/grape-swagger/pull/171#issuecomment-62734751
.

@dblock
Copy link
Member

dblock commented Nov 28, 2014

Bump.

@jhollinger
Copy link
Contributor Author

Got a bit preoccupied. Anyway, I changed an existing spec that was artificially hiding the top-level module with Grape::Entity.entity_name. I then added a few more checks to verify that all the types started with MyAPI::.

While overriding entity_name to get rid of a top-level module certain works, I think it's non-obvious, especially since it's missing from some of the examples in the README.

@dblock
Copy link
Member

dblock commented Dec 14, 2014

Thanks, merging.

dblock added a commit that referenced this pull request Dec 14, 2014
Explain how the documentaiton type option is matched to class names. Fix...
@dblock dblock merged commit 86ed8df into ruby-grape:master Dec 14, 2014
@jhollinger jhollinger deleted the explain-how-type-works branch December 15, 2014 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants