Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
SuicaLondon opened this issue Nov 29, 2024 · 0 comments

Comments

@SuicaLondon
Copy link

SuicaLondon commented Nov 29, 2024

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 SuicaLondon changed the title In the version of 3.0, if we define requestBody with inline object schema, it will generate a object.dart file For the swagger 3.0, if we define requestBody with inline object schema, it will generate a object.dart file Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant