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
90 stars 38 forks source link

Empty return type should be Object or Map<String, dynamic> not void #99

Closed JasCodes closed 10 months ago

JasCodes commented 10 months ago
 "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "username": {
                                        "error": "Username is required",
                                        "type": "string"
                                    }
                                },
                                "required": [
                                    "username"
                                ],
                                "additionalProperties": false
                            }
                        },
  @MultiPart()
  @POST('/login')
  Future<void> postLogin({
    @Part(name: 'username') String? username,
  });
Carapacik commented 10 months ago

From the example, it is difficult to understand where the error is. And why, if the return type is not specified in the schema, should we specify, for example, Object?

JasCodes commented 10 months ago

Bescause take swagger code gen from example below

This is not uncommon practive using javascript pattern.

import { Elysia, t } from "elysia";

export const loginController = new Elysia().post( "/login", async ({ body }) => { return { "success": true } }, { body: t.Object({ username: t.String({ error: "Username is required" }), }), }, );



I have choosen not to describe return type. But in most cases will return something.