-
-
Notifications
You must be signed in to change notification settings - Fork 34
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
Dio generator not correctly processing v3.1.0 spec (converts String to JsonObject) #94
Comments
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 |
The oas spec included above is public but here is a minimal example: I pulled the spec down and updated my generator config: 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:
[INFO] openapi_generator on lib/client_generator_config.dart:OpenapiGenerator :: [generate -i ./openapi.yaml -g dart-dio -o clients/dart --import-mappings=JsonObject=package:built_value/json_object.dart --additional-properties=pubName=tagmine_api,pubDescription=OAS generated dart api for tagmine.ca,useEnumExtension=true,sortPara[WARNING] openapi_generator on lib/client_generator_config.dart:
:: Install exited with code 0
[WARNING] No actions completed for 15.0s, waiting on:
[SEVERE] openapi_generator on lib/client_generator_config.dart: [INFO] Running build completed, took 23.9s |
Ah. Sorry, I didn't see you included the spec. Any files you don't want to be generated should be added to |
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 A way to work around the issue is download the spec from the url and modify the first line from 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 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
The text was updated successfully, but these errors were encountered: