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

How do we support polymorphic associations? #799

Open
notfelineit opened this issue Nov 1, 2022 · 2 comments
Open

How do we support polymorphic associations? #799

notfelineit opened this issue Nov 1, 2022 · 2 comments
Labels

Comments

@notfelineit
Copy link

Some of our APIs return polymorphic associations, as in, the return value could be one of a few different models.

It would be nice to be able to do some kind of "OR", "anyOf", or "oneOf" action, something like:

def_param_group :user do
    # some params here
end

def_param_group :robot do
   # some params here
end

# later on in in a returns block
property :entity, Hash, oneOf: [:user, :robot]

is that possible today?

@nathanpalmer
Copy link
Contributor

Did you ever find a good answer to this question? We have a similar situation where there is an array of items returned and based on the type they have a different structure. I'd like to document each structure separately.

@notfelineit
Copy link
Author

@nathanpalmer we did not! We ended up inserting our own code into Apipie in our codebase to support different cases. We haven't implemented a solution for this specific issue, however. Maybe soon!

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

No branches or pull requests

3 participants