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
94 stars 43 forks source link

Codegen issues with object response #98

Closed JasCodes closed 11 months ago

JasCodes commented 11 months ago
// coverage:ignore-file
// GENERATED CODE - DO NOT MODIFY BY HAND
// ignore_for_file: type=lint

import 'package:json_annotation/json_annotation.dart';

part 'object0_value.g.dart';

@JsonSerializable()
class Object0Value {
  const Object0Value({
    this.id,
    this.name,
  });

  factory Object0Value.fromJson(Map<String, Object?> json) =>
      _$Object0ValueFromJson(json);

  final String? id;
  final String? name;

  Map<String, Object?> toJson() => _$Object0ValueToJson(this);
}

Issue with code generation

OpenAPI

"/login": {
            "post": {
                "parameters": [],
                "responses": {
                    "200": {
                        "additionalProperties": false,
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "id": {
                                            "error": "id not found",
                                            "type": "string"
                                        },
                                        "name": {
                                            "error": "name not found",
                                            "type": "string"
                                        }
                                    },
                                    "required": [
                                        "id",
                                        "name"
                                    ]
                                }
                            },
                            "multipart/form-data": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "id": {
                                            "error": "id not found",
                                            "type": "string"
                                        },
                                        "name": {
                                            "error": "name not found",
                                            "type": "string"
                                        }
                                    },
                                    "required": [
                                        "id",
                                        "name"
                                    ]
                                }
                            },
                            "text/plain": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "id": {
                                            "error": "id not found",
                                            "type": "string"
                                        },
                                        "name": {
                                            "error": "name not found",
                                            "type": "string"
                                        }
                                    },
                                    "required": [
                                        "id",
                                        "name"
                                    ]
                                }
                            }
                        }
                    }
                },
                "operationId": "postLogin",
                "requestBody": {
                    "content": {
                        "application/json": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "username": {
                                        "error": "Username is required",
                                        "type": "string"
                                    }
                                },
                                "required": [
                                    "username"
                                ],
                                "additionalProperties": false
                            }
                        },
                        "multipart/form-data": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "username": {
                                        "error": "Username is required",
                                        "type": "string"
                                    }
                                },
                                "required": [
                                    "username"
                                ],
                                "additionalProperties": false
                            }
                        },
                        "text/plain": {
                            "schema": {
                                "type": "object",
                                "properties": {
                                    "username": {
                                        "error": "Username is required",
                                        "type": "string"
                                    }
                                },
                                "required": [
                                    "username"
                                ],
                                "additionalProperties": false
                            }
                        }
                    }
                }
            }
        },