Open Nexushunter opened 1 year ago
I'm up to help out, but I have no idea where to start 😄
Can you please share a minimal reproducible openapi spec
Also when you run the build runner, the generated command is shown in the logs please share. Looks like generate -i ../openapi-spec.yaml -g dart-dio ...
The oas spec included above is public but here is a minimal example:
I pulled the spec down and updated my generator config:
inputSpecFile: './openapi.yaml'
As an aside: Is there a way to prevent the generation of tests?
openapi: 3.1.0
info:
title: Site
description: Test
version: 0.0.1
servers:
- url: "http://localhost:8080/dev"
components:
securitySchemes:
bearerAuth:
type: http
scheme: bearer
bearerFormat: JWT
tags:
- name: metadata
paths:
/url_metadata:
get:
tags:
- metadata
security:
- bearerAuth: []
summary: Get title/thumbnail from URL
parameters:
- name: url
in: query
description: URL of link
required: true
schema:
type:
- string
responses:
'200':
description: Successful operation
Logs:
Ah. Sorry, I didn't see you included the spec.
Any files you don't want to be generated should be added to .openapi-generator-ignore
. You can find this file in the root of your generated api. So just add the line test/*
to it so it doesn't generate tests.
No worries!
Thanks for the tip!
So, I just looked into this issue you are having with the JsonObject. First, import mappings are applied in the models not the api classes (the models are imported into the apis) that's why the mapping wasn't working.
The real problem is the generator is having trouble parsing the 3.1.0
spec that you have.
A way to work around the issue is download the spec from the url and modify the first line from openapi: 3.1.0
to openapi: 3.0.3
. This should resolve this JsonObject issue.
Now, the spec still has some other errors like defining a type as int64 instead of integer. You can use typeMappings to fix that.
Let me know if this is enough for you.
I noticed the type issues and am addressing those! Thanks for the quick turn around time. If you'd like some help LMK I'd love to assist
👋🏻 I'm also noticing that the return values are Future<Response<void>
which is causing type erasure. But the response definition looks something like:
(Regenerated with v3.0.3)
final _response = await _dio.request<Object>(
_path,
options: _options,
queryParameters: _queryParameters,
cancelToken: cancelToken,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress,
);
return _response;
This an issue with the spec as it does not define response types only response codes
Description of the bug
When using this config:
The resulting library produces incorrect artifacts. All of the
src/api/*_api.dart
files are missing theJsonObject
import which is imported frompackage:built_value/json_object.dart
Steps to reproduce
Run
dart run build_runner build --delete-conflicting-outputs
with this in thebuild.yml
and the contents of the config within
lib/client_generator_config.dart
Expected behavior
No missing imports in generated code.
Logs
No response
Screenshots
No response
Platform
Linux
Library version
4.11.0
Flutter version
3.0.5 - Dart
Flutter channel
stable
Additional context