-
-
Notifications
You must be signed in to change notification settings - Fork 43
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Description of the bug
Generating the api code for the tictactoe example from OPENAPI generates broken code:
class Mark {
/// Returns a new [Mark] instance.
Mark({
});
@override
bool operator ==(Object other) => identical(this, other) || other is Mark &&
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
...
}
and
class Winner {
/// Returns a new [Winner] instance.
Winner({
});
@override
bool operator ==(Object other) => identical(this, other) || other is Winner &&
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
...
}
Steps to reproduce
@Openapi(
additionalProperties: AdditionalProperties(
pubName: 'tictactoe_api',
pubAuthor: 'Jon Doe',
pubAuthorEmail: "me@example.com"
),
inputSpecFile: 'tictactoe.yaml',
generatorName: Generator.dart,
outputDirectory: 'api/tictactoe_api')
class TicTacToe extends OpenapiGeneratorConfig {}
tictactoe.yaml
:
openapi: 3.1.0
info:
title: Tic Tac Toe
description: |
This API allows writing down marks on a Tic Tac Toe board
and requesting the state of the board or of individual squares.
version: 1.0.0
tags:
- name: Gameplay
paths:
# Whole board operations
/board:
get:
summary: Get the whole board
description: Retrieves the current state of the board and the winner.
tags:
- Gameplay
operationId: get-board
responses:
"200":
description: "OK"
content:
application/json:
schema:
$ref: "#/components/schemas/status"
# Single square operations
/board/{row}/{column}:
parameters:
- $ref: "#/components/parameters/rowParam"
- $ref: "#/components/parameters/columnParam"
get:
summary: Get a single board square
description: Retrieves the requested square.
tags:
- Gameplay
operationId: get-square
responses:
"200":
description: "OK"
content:
application/json:
schema:
$ref: "#/components/schemas/mark"
"400":
description: The provided parameters are incorrect
content:
text/html:
schema:
$ref: "#/components/schemas/errorMessage"
example: "Illegal coordinates"
put:
summary: Set a single board square
description: Places a mark on the board and retrieves the whole board and the winner (if any).
tags:
- Gameplay
operationId: put-square
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/mark"
responses:
"200":
description: "OK"
content:
application/json:
schema:
$ref: "#/components/schemas/status"
"400":
description: The provided parameters are incorrect
content:
text/html:
schema:
$ref: "#/components/schemas/errorMessage"
examples:
illegalCoordinates:
value: "Illegal coordinates."
notEmpty:
value: "Square is not empty."
invalidMark:
value: "Invalid Mark (X or O)."
components:
parameters:
rowParam:
description: Board row (vertical coordinate)
name: row
in: path
required: true
schema:
$ref: "#/components/schemas/coordinate"
columnParam:
description: Board column (horizontal coordinate)
name: column
in: path
required: true
schema:
$ref: "#/components/schemas/coordinate"
schemas:
errorMessage:
type: string
maxLength: 256
description: A text message describing an error
coordinate:
type: integer
minimum: 1
maximum: 3
example: 1
mark:
type: string
enum: [".", "X", "O"]
description: Possible values for a board square. `.` means empty square.
example: "."
board:
type: array
maxItems: 3
minItems: 3
items:
type: array
maxItems: 3
minItems: 3
items:
$ref: "#/components/schemas/mark"
winner:
type: string
enum: [".", "X", "O"]
description: Winner of the game. `.` means nobody has won yet.
example: "."
status:
type: object
properties:
winner:
$ref: "#/components/schemas/winner"
board:
$ref: "#/components/schemas/board"
Expected behavior
Non-broken code.
Logs
dart run build_runner build --delete-conflicting-outputs ✔
[INFO] Generating build script completed, took 248ms
[INFO] Reading cached asset graph completed, took 45ms
[INFO] Checking for updates since last build completed, took 423ms
[WARNING] openapi_generator on lib/openapi_test.dart:
OpenapiGenerator :: [generate -i tictactoe.yaml -g dart -o api/tictactoe_api --additional-properties=pubName=tictactoe_api,pubAuthor=Jon Doe,pubAuthorEmail=me@example.com]
[WARNING] openapi_generator on lib/openapi_test.dart:
------------------------------------------------------
| |
| Openapi generator for dart |
| |
| |
------------------------------------------------------
[WARNING] openapi_generator on lib/openapi_test.dart:
Executing command [generate -i tictactoe.yaml -g dart -o api/tictactoe_api --additional-properties=pubName=tictactoe_api,pubAuthor=Jon Doe,pubAuthorEmail=me@example.com]
[WARNING] openapi_generator on lib/openapi_test.dart:
[WARNING] openapi_generator on lib/openapi_test.dart:
OpenapiGenerator :: Codegen completed successfully
[WARNING] openapi_generator on lib/openapi_test.dart:
[WARNING] openapi_generator on lib/openapi_test.dart:
OpenapiGenerator :: Install exited with code 0
[WARNING] openapi_generator on lib/openapi_test.dart:
OpenapiGenerator :: skipping source gen because generator does not need it ::
[INFO] Running build completed, took 4.4s
[INFO] Caching finalized dependency graph completed, took 29ms
[INFO] Succeeded after 4.5s with 0 outputs (1 actions)
Screenshots
No response
Platform
Linux
Library version
4.10.0
dart version
3.0.1
Flutter channel
stable
Additional context
using build_runner: ^2.4.4
regen100
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working