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

[BUG] Request body with type array, are not generated #493

Closed
mfrischbutter opened this issue Nov 11, 2022 · 0 comments · Fixed by #494
Closed

[BUG] Request body with type array, are not generated #493

mfrischbutter opened this issue Nov 11, 2022 · 0 comments · Fixed by #494
Assignees
Labels
bug Something isn't working Triage needed

Comments

@mfrischbutter
Copy link
Contributor

Describe the bug
If I have a RequestBody with a type array. In the call function the body is not passed as a parameter.

To Reproduce

openapi: 3.0.3
info:
  title: Swagger Petstore - OpenAPI 3.0
  description: Test
  termsOfService: http://swagger.io/terms/
  contact:
    email: [email protected]
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  version: 1.0.11
externalDocs:
  description: Find out more about Swagger
  url: http://swagger.io
servers:
  - url: https://petstore3.swagger.io/api/v3
paths:
  /api/contracts/{id}/not_accessible/:
    post:
      operationId: unit_not_accessible
      description: |-
        This endpoint enables you to mark the room as inaccessible. This will be shown in the app and the user will be able to report it as a problem.
        The request body should be an array of the unit ids that are not accessible.
      summary: Mark units as not accessible
      parameters:
        - in: path
          name: id
          schema:
            type: integer
          description: A unique integer value identifying this contract.
          required: true
      tags:
        - contracts
      requestBody:
        content:
          application/json:
            schema:
      # ---------------------------------
              type: array
              items:
                type: integer
      # ---------------------------------
        required: true
      responses:
        "201":
          content:
            application/json:
              schema:
                type: array
                items:
                  type: string
          description: ""

api.swagger.dart result:

///Mark units as not accessible
///@param id A unique integer value identifying this contract.
Future<chopper.Response<List<String>>> apiContractsIdNotAccessiblePost(
    {required int? id}) {
  return _apiContractsIdNotAccessiblePost(id: id);
}

Expected behavior

The request body should also be given as a parameter in the post function.
In my example line 38 from the yaml is missing in the function. I have defined the schema with the type array and the items at this point.

I expected something like this: :

///Mark units as not accessible
///@param id A unique integer value identifying this contract.
Future<chopper.Response<List<String>>> apiContractsIdNotAccessiblePost(
    {required int? id, required List<int> body}) {
  return _apiContractsIdNotAccessiblePost(id: id, body: body);
}

Library version used:
version: 2.8.5

@mfrischbutter mfrischbutter added bug Something isn't working Triage needed labels Nov 11, 2022
Vovanella95 pushed a commit that referenced this issue Nov 14, 2022
Fixed generatino of list request bodies #493
Vovanella95 added a commit that referenced this issue Nov 14, 2022
* Fixed generation of requestBodies in some border cases
Fix #489

* Updated changelog and pubspec

* Added 'Method' to key classes #492
Fixed generatino of list request bodies #493

Co-authored-by: Uladzimir Paliukhovich <[email protected]>
Vovanella95 added a commit that referenced this issue Nov 17, 2022
* Fixed generation of requestBodies in some border cases
Fix #489

* Updated changelog and pubspec

* Added 'Method' to key classes #492
Fixed generatino of list request bodies #493

* Fixed #491

* Fixed ticket number

Co-authored-by: Uladzimir Paliukhovich <[email protected]>
Vovanella95 added a commit that referenced this issue Nov 22, 2022
* Fixed generation of requestBodies in some border cases
Fix #489

* Updated changelog and pubspec

* Added 'Method' to key classes #492
Fixed generatino of list request bodies #493

* Fixed #491

* Fixed ticket number

* Fixed generation of basic types refs and lists of them #502

Co-authored-by: Uladzimir Paliukhovich <[email protected]>
Vovanella95 added a commit that referenced this issue Dec 1, 2022
* Fixed generation of requestBodies in some border cases
Fix #489

* Updated changelog and pubspec

* Added 'Method' to key classes #492
Fixed generatino of list request bodies #493

* Fixed #491

* Fixed ticket number

* Fixed generation of basic types refs and lists of them #502

* Fixed #507
Fixed generation of allOf properties with just properties

* Updated changelog

Co-authored-by: Uladzimir Paliukhovich <[email protected]>
Vovanella95 added a commit that referenced this issue Dec 2, 2022
* Fixed generation of requestBodies in some border cases
Fix #489

* Updated changelog and pubspec

* Added 'Method' to key classes #492
Fixed generatino of list request bodies #493

* Fixed #491

* Fixed ticket number

* Fixed generation of basic types refs and lists of them #502

* Fixed #507
Fixed generation of allOf properties with just properties

* Updated changelog

* Fixed issue with generation Lists models map

Co-authored-by: Uladzimir Paliukhovich <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Triage needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants