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

Cannot nest embedded resource description #797

Open
notfelineit opened this issue Oct 19, 2022 · 3 comments
Open

Cannot nest embedded resource description #797

notfelineit opened this issue Oct 19, 2022 · 3 comments

Comments

@notfelineit
Copy link

notfelineit commented Oct 19, 2022

I can't nest an embedded resource description like so:

public_api :GET, "/users/:name/regions", "Get a user's regions"
param :name, String, desc: "Name of the user"
returns code: 200, desc: "Returns the user's regions" do
    property :data, Array, of: Region
end
def regions
    # some logic here
end

where Region is a model that has the self.describe_own_properties defined.

It only works if Region is returned at the top level of the returns block:

returns code: 200, array_of: Region, desc: "Returns the user's regions"

This is not ideal because we have some classes that we'd like to reuse across our controllers as resource descriptions.

@notfelineit
Copy link
Author

Accidentally closed this issue - this is still a feature we'd like.

@mathieujobin
Copy link
Collaborator

If you can try to implement it with tests, I will review and can incorporate. Unfortunately, I don't have time to work on feature requests.

Thank you for your understanding

@xaviertholot
Copy link

I'm very interested in this feature as well. ATM the only workaround I have is to do:

public_api :GET, "/users/:name/regions", "Get a user's regions"
param :name, String, desc: "Name of the user"
returns code: 200, desc: "Returns the user's regions" do
    property :data, array_of: Hash do
        param_group: Region
    end
end
def regions
    # some logic here
end

However what doesn't work is that on the open API documentation, it doesn't pass the param_group as a reference but spreads/duplicates the whole definition. It would be amazing to factorize it so that the param groups are defined only once and reused in all APIs they are used. This is especially useful when using Swagger clients with typescript definitions of an API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants