Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Methods naming for non crud actions #144

Open
mtangoo opened this issue Apr 16, 2023 · 3 comments · Fixed by php-openapi/yii2-openapi#13
Open

Methods naming for non crud actions #144

mtangoo opened this issue Apr 16, 2023 · 3 comments · Fixed by php-openapi/yii2-openapi#13

Comments

@mtangoo
Copy link

mtangoo commented Apr 16, 2023

I have this OA file (top parts removed). I want Payments to do many things. for example /payments/invoice for paying invoices or payments/cash for non-credit payments. These takes different objects and are obviously non crud. I cannot get the library to generate correct methods for me. For example for the file below it creates PaymentsController/actionCreateinvoice .

Is there a way of setting my own naming and disable treating everything as CRUD?

tags:
  - name: Payments
    description: Pay or receive payments for your products from different channels
    externalDocs:
      description: Find out more
      url: http://developer.adiuta.com/book/payments
paths:
  /payments/invoice/{invoice}:
    post:
      summary: Pay Invoice
      description: Pay for Invoice with given invoice number
      requestBody:
        description: Record new payment for an invoice
        content:
          application/json:
            schema:  
              $ref: '#/components/schemas/Payments'   
        required: true
      responses:
        '200':
          description: Successfully paid the invoice
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Success'   

components:
  schemas:
    Payments:
      required:
        - reference  
        - amount
        - currency
      properties:
        invoice_number:
          type: string
        amount:
          type: integer
          format: int64
        currency:
          type: string  

    Success:
      required:
        - success  
        - message
      properties:
        success:
          type: boolean
        message:
          type: string  

    Error:
      required:
        - code
        - message
      properties:
        code:
          type: integer
          format: int32
        message:
          type: string
@mtangoo
Copy link
Author

mtangoo commented Apr 16, 2023

Addition:
I see it is spitting wrong names

/payments/invoice-payment produces actionCreateinvoicePayment instead of actionCreateInvoicePayment
wrong capitalization

@SOHELAHMED7
Copy link
Contributor

At this moment, there is no way to do that.

Loosely similar to #84

Work-around is

class PaymentController ... 
{
    public function actionCreateinvoice($invoice)
    {
        return $this->runAction('invoice', ['invoice' => $invoice]);
    }

    public function actionInvoice($invoice)
    {
        // TODO implement
    }
}

@mtangoo
Copy link
Author

mtangoo commented May 2, 2023

I just fell back to classic API/Code crafting.
hope to come back soon

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

Successfully merging a pull request may close this issue.

2 participants