Carapacik / swagger_parser

Dart package that takes an OpenApi definition file and generates REST clients based on retrofit and data classes for your project.
https://pub.dev/packages/swagger_parser
MIT License
96 stars 43 forks source link

`Null check operator used on a null value` when run retrofit #110

Closed theoolee closed 7 months ago

theoolee commented 11 months ago

Failed to run retrofit_generator, here is the swagger.

Carapacik commented 11 months ago

@theoolee for temp solution use retrofit_generator 7.0.8

theoolee commented 11 months ago

@theoolee for temp solution use retrofit_generator 7.0.8

It works 👍🏻

Carapacik commented 11 months ago

@theoolee, you can upgrade the version to 8.0.2

theoolee commented 11 months ago

@theoolee, you can upgrade the version to 8.0.2

Nice work.

theoolee commented 11 months ago

Failed to run retrofit_generator, here is the swagger.

@Carapacik my swagger file still meets the same error.

iiba-itabashi commented 7 months ago

@Carapacik I faced the same error, too. Occurs when there is only one "type: object" field in the request body. The following is a concrete schema.

post:
  summary: Create a favorite_spot
  operationId: createFavoriteSpot
  tags:
    - favorite_spot
  security:
    - bearerAuth: []
  parameters:
    - in: path
      name: spot_id
      required: true
      schema:
        type: string
      description: ID of the spot
  requestBody:
    content:
      application/json:
        schema:
          type: object
          properties:
            user: # Perhaps this is not handled well.
              type: string
              description: User ID
              example: "user123"

  responses:
    "201":
      description: FavoriteSpot created
      content:
        application/json:
          schema:
            type: object
            properties:
              result:
                $ref: "../schema/favorite_spot.yaml#/favorite_spot"
              status:
                type: string
cl3m commented 6 months ago

Hi, I still have the same error with the following schema without properties:

"components": {
  "schemas": {
      "ApiResponseObject": {
          "type": "object",
          "additionalProperties": false
      }
}

I fixed my json by adding "properties": {}, but I would prefer to not modifing the json. Can you fix it ?