swagger-api / swagger-api/swagger-codegen

Rails5 Server: How to generate CRUD operations?

Open
#5,053 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Trying to generate RESTFUL CRUD operations that map to Rails 5 defaults. I see in the templates that it has accounted for it but it still generates controllers that only use the operationID field.

If I remove the operationId field then the method name is generated automatically but NOT to the CRUD operation. Is there another field to use? Is there something on generation?

I just assumed that GET /path; GET /path/{:id} would map to the RESTFUL CRUD methods index and show in a rails controller.

Swagger-codegen version

2.2.1

Swagger declaration file content or url
/payments:
    get:
      tags:
        - payment
      summary: List payments
      description: Get a list of payments.
      operationId: list_payments
      parameters:
        - name: page[number]
          in: query
          description: Page number
          required: false
          type: integer
          default: 1
        - name: page[size]
          in: query
          description: Page size
          required: false
          type: integer
          default: 10
          maximum: 50
      responses:
        200:
          description: OK
          schema:
            $ref: '#/definitions/GetPaymentsResponse'
        401:
          description: Unauthorized
          schema:
            $ref: '#/definitions/GetErrorResponse'
        403:
          description: Forbidden
          schema:
            $ref: '#/definitions/GetErrorResponse'
        409:
          description: Invalid Request
          schema:
            $ref: '#/definitions/GetErrorResponse'

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 with the Rails 5 server templates and the generated controller for the supplied /payments operation. Compare how operationId is used with the expected Rails index and show methods, then determine whether a generation option or template change is required; done means the supported behavior and required change are clearly established.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.