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

Support POJOs for request param mapping #24

Open
ashwini-desai opened this issue Aug 6, 2020 · 0 comments
Open

Support POJOs for request param mapping #24

ashwini-desai opened this issue Aug 6, 2020 · 0 comments
Labels
design discussion required Issue that needs discussion with maintainers for deciding on approach hacktoberfest

Comments

@ashwini-desai
Copy link
Collaborator

ashwini-desai commented Aug 6, 2020

Sample input:

paths:
  /pets:
    get:
      summary: get pets
      operationId: getPets
      tags:
        - pets
      requestBody:
        description: 'Fetch pets'
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PaginationCommand"
      responses:
         '200':
           description: Expected response to a valid request
           content:
             application/json:
               schema:
                 type: array
                 items:
                   $ref: "#/components/schemas/Pet"
components:
   schemas:
      PaginationCommand:
          type: object
          required:
            - offset
            - limit
          properties:
            offset:
              type: integer
              format: int64
              minimum: 0
            limit:
              type: integer
              format: int64
              minimum: 10

Sample output:

Controller method -

     @Get(value = "/pets{?paginationCommand*}")
     fun showPetById(paginationCommand: PaginationCommand): HttpResponse<Pet> {
        ....
    }

PaginationCommand class -

data class PaginationCommand(val offset: Int = 0, val limit: Int = 10)

We should be able to take default values from yaml. Also, micronaut needs default values for POJOs mapped from requests, so will have to be made mandatory in apifi for request param models to be mapped as POJOs.

@ashwini-desai ashwini-desai added design discussion required Issue that needs discussion with maintainers for deciding on approach hacktoberfest labels Sep 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design discussion required Issue that needs discussion with maintainers for deciding on approach hacktoberfest
Projects
None yet
Development

No branches or pull requests

1 participant