ruby-grape / ruby-grape/grape-swagger

Support for inheritance: subTypes and discriminator.

Open
#263 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

new feature swagger-1.2
Dominant language
Ruby
Stars
1.1k
Forks
479
Avg merge
2d 14h
Merged PRs (30d)
6

Description

Hello,
is there any support for describing inheritance in the generated swagger specification?
According to Swagger 1.2 specification, this should be possible through the use of subTypes and discriminator.

I have an API that retrieves/updates account information. The Account model is abstract and I have concrete BusinessAccount and IndividualAccount models (they have some of the fields in common).

What options do I have for achieving this? I would like input to be validated according to the type of account and output to only present the fields pertaining to the type of account at hand (for output I use grape-entity).

Regards,
Dan

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing how the generated Swagger specification represents the Account, BusinessAccount, and IndividualAccount models, then compare the required modelDiscriminator, subTypes, and validation behavior with the Swagger 1.2 specification. Check how grape-entity currently controls output fields; done means a documented approach or implementation that validates each account subtype and emits only its applicable fields.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, ruby
Domain
api, documentation
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.