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

References to other files are not properly mapped #120

Open theimmigrant-canada opened 10 months ago

theimmigrant-canada commented 10 months ago

Hi,

I have this environment with multiple json files that have parts of models (for example, various enumerations in one file, and the usage of those enumeration in another file). Those interfile references are not being mapped for json decoding.

Example enumeration file (service_enumerations.json):

{
    "openapi": "3.0.1",
    "info": {
      "title": "Service Enumerations",
      "version": "1.0"
    },
    "components": {
        "schemas": {          
          "LogLevel": {
            "type": "string",
            "enum": [
              "Trace",
              "Debug",
              "Information",
              "Warning",
              "Error",
              "Critical",
              "None"
            ]
          },
        }
      }
}

Example usage (service.json):

{
    "openapi": "3.0.1",
    "info": {
      "title": "Service",
      "version": "1.0"
    },
    "components": {
        "schemas": {          
          "CreateSessionParameters": {
            "required": [
              "sessionType"
            ],
            "type": "object",
            "properties": {
              "sessionType": {
                "$ref": "service_enumerations.json#/components/schemas/SessionTypes"
              }
            }
          }
        }
      }
}

I would expect the json encoding and decoding to be in the session_types.dart file but they are not there. Also the CreateSessionParameters doesn't seem to be able to create the fromJson for the SessionTypes