swagger_parser icon indicating copy to clipboard operation
swagger_parser copied to clipboard

For the swagger 3.0, if we define requestBody with inline object schema, it will generate a object.dart file

Open SuicaLondon opened this issue 1 year ago • 0 comments

Steps to reproduce

  1. Copy this swagger snippet
  2. Run dart run swagger_parser
  3. Check the generated models folder

Expected results

Generate the anonymity request body, similar to how it would be created by JavaScript generators. Or from the current test case, it should generate the object with some index likes object0 or something else as default. Screenshot 2024-11-29 at 12 24 49 AM

Actual results

Generate a file named object.dart and a Object class with pets property without any identifier. Screenshot 2024-11-29 at 12 27 59 AM

Your OpenApi snippet

{
  "openapi": "3.0.0",
  "info": {
    "title": "Testing API",
    "description": "Description of the API",
    "version": "1.0"
  },
  "servers": [
    {
      "url": "https://api.server.test/v1"
    }
  ],
  "tags": [
    {
      "name": "Test",
      "description": "Testing endpoints"
    }
  ],
  "paths": {
    "/pet": {
      "post": {
        "operationId": "post pets",
        "tags": ["Test"],
        "summary": "Create pets",
        "description": "Create pets",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "pets": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": ["pets"]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Pets created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Code sample

Code sample
[Paste your code here]

Logs

Logs
[Paste your logs here]

Dart version and used packages versions

Dart version
Dart SDK version: 3.5.4 (stable) (Wed Oct 16 16:18:51 2024 +0000) on "macos_arm64"
Packages version
swagger_parser: ^1.19.2

SuicaLondon avatar Nov 29 '24 00:11 SuicaLondon