swagger_parser
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
Steps to reproduce
- Copy this swagger snippet
- Run
dart run swagger_parser - 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.
Actual results
Generate a file named object.dart and a Object class with pets property without any identifier.
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