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

Produce Model JSON body #45

Open
max-moroz opened this issue Feb 23, 2021 · 1 comment
Open

Produce Model JSON body #45

max-moroz opened this issue Feb 23, 2021 · 1 comment

Comments

@max-moroz
Copy link

I'd like OpenAPI/Swagger module for Lagom to produce full model body instead of or in addition to $ref: "#/components/schemas/Model". I need it to be done automatically fetching actual Model properties, not manually put example. I found how to do it with @BeanProperty but I'm wondering if there is another way to do that?

What I have now is:

case class TransferType(@(Schema@field)
                        id: TransferTypeId,
                        @(Schema@field)
                        title: TransferTypeTitle,
                        @(Schema@field)
                        categories: Seq[Category],
                        @(Schema@field)
                        keywords: Seq[Keyword],
                        @(Schema@field)
                        fields: Seq[Field]) {

but it doesn't produce full json body. Just this one with $ref:

responses: {
  200: {
    description: "Returns all available Datasource Types.",
    content: {
      application/json: {
        schema: {
          type: "array",
            items: {
              $ref: "#/components/schemas/TransferType"
}
}
}
}
}
}

full json body returned when I add @BeanProperty to case class but I don't need this for my code, thus I believe this is not proper solution:

case class TransferType(@(Schema@field)
                        @BeanProperty id: TransferTypeId,
                        @(Schema@field)
                        @BeanProperty title: TransferTypeTitle,
                        @(Schema@field)
                        @BeanProperty categories: Seq[Category],
                        @(Schema@field)
                        @BeanProperty keywords: Seq[Keyword],
                        @(Schema@field)
                        @BeanProperty fields: Seq[Field]) {
@max-moroz max-moroz changed the title Produce Model JSON body instead of $ref Produce Model JSON body Feb 23, 2021
@ihostage
Copy link
Member

Hi, @max-moroz!
Scala case classes were discussed in #39
It's not a problem with Lagom OpenAPI. It's problem with the interop of Swagger (used Java reflection) and Scala. 🤷‍♂️

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

No branches or pull requests

2 participants