Skip to content

Commit 8b01ebb

Browse files
wing328epou
andauthored
[dart-dio][timemachine] Bugfix: saving offset_date_serializer instead of local_date_serialize (#21974)
* Bugfix: saving offset_date_serializer instead of local_date_serializer.dart * New config for dart-dio (timemachine) * test samples in github workflow * update workflow, samples * rename --------- Co-authored-by: Enric Pou <[email protected]>
1 parent 7dcef20 commit 8b01ebb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+4896
-1
lines changed

.github/workflows/samples-dart-build-test.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ on:
1010
- samples/openapi3/client/petstore/dart-dio/oneof/**
1111
- samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/**
1212
- samples/openapi3/client/petstore/dart-dio/binary_response/**
13+
- samples/openapi3/client/petstore/dart-dio/petstore-timemachine/**
1314
pull_request:
1415
paths:
1516
#- samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/**
@@ -18,6 +19,7 @@ on:
1819
- samples/openapi3/client/petstore/dart-dio/oneof/**
1920
- samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/**
2021
- samples/openapi3/client/petstore/dart-dio/binary_response/**
22+
- samples/openapi3/client/petstore/dart-dio/petstore-timemachine/**
2123

2224
jobs:
2325
test:
@@ -33,6 +35,7 @@ jobs:
3335
- samples/openapi3/client/petstore/dart-dio/oneof/
3436
- samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/
3537
- samples/openapi3/client/petstore/dart-dio/binary_response/
38+
- samples/openapi3/client/petstore/dart-dio/petstore-timemachine/
3639
steps:
3740
- uses: actions/checkout@v5
3841

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
generatorName: dart-dio
2+
outputDir: samples/openapi3/client/petstore/dart-dio/petstore-timemachine
3+
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
4+
templateDir: modules/openapi-generator/src/main/resources/dart/libraries/dio
5+
typeMappings:
6+
Client: "ModelClient"
7+
File: "ModelFile"
8+
EnumClass: "ModelEnumClass"
9+
additionalProperties:
10+
hideGenerationTimestamp: "true"
11+
enumUnknownDefaultCase: "true"
12+
dateLibrary: "timemachine"
13+
reservedWordsMappings:
14+
class: "classField"

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioClientCodegen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ private void configureDateLibrary(String srcFolder) {
317317
imports.put("OffsetDate", "package:time_machine/time_machine.dart");
318318
imports.put("OffsetDateTime", "package:time_machine/time_machine.dart");
319319
if (SERIALIZATION_LIBRARY_BUILT_VALUE.equals(library)) {
320-
supportingFiles.add(new SupportingFile("serialization/built_value/offset_date_serializer.mustache", srcFolder, "local_date_serializer.dart"));
320+
supportingFiles.add(new SupportingFile("serialization/built_value/offset_date_serializer.mustache", srcFolder, "offset_date_serializer.dart"));
321321
}
322322
break;
323323
default:
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# See https://dart.dev/guides/libraries/private-files
2+
3+
# Files and directories created by pub
4+
.dart_tool/
5+
.buildlog
6+
.packages
7+
.project
8+
.pub/
9+
build/
10+
**/packages/
11+
12+
# Files created by dart2js
13+
# (Most Dart developers will use pub build to compile Dart, use/modify these
14+
# rules if you intend to use dart2js directly
15+
# Convention is to use extension '.dart.js' for Dart compiled to Javascript to
16+
# differentiate from explicit Javascript files)
17+
*.dart.js
18+
*.part.js
19+
*.js.deps
20+
*.js.map
21+
*.info.json
22+
23+
# Directory created by dartdoc
24+
doc/api/
25+
26+
# Don't commit pubspec lock file
27+
# (Library packages only! Remove pattern if developing an application package)
28+
pubspec.lock
29+
30+
# Don’t commit files and directories created by other development environments.
31+
# For example, if your development environment creates any of the following files,
32+
# consider putting them in a global ignore file:
33+
34+
# IntelliJ
35+
*.iml
36+
*.ipr
37+
*.iws
38+
.idea/
39+
40+
# Mac
41+
.DS_Store
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
.gitignore
2+
README.md
3+
analysis_options.yaml
4+
doc/ApiResponse.md
5+
doc/Category.md
6+
doc/Order.md
7+
doc/Pet.md
8+
doc/PetApi.md
9+
doc/StoreApi.md
10+
doc/Tag.md
11+
doc/User.md
12+
doc/UserApi.md
13+
lib/openapi.dart
14+
lib/src/api.dart
15+
lib/src/api/pet_api.dart
16+
lib/src/api/store_api.dart
17+
lib/src/api/user_api.dart
18+
lib/src/api_util.dart
19+
lib/src/auth/api_key_auth.dart
20+
lib/src/auth/auth.dart
21+
lib/src/auth/basic_auth.dart
22+
lib/src/auth/bearer_auth.dart
23+
lib/src/auth/oauth.dart
24+
lib/src/model/api_response.dart
25+
lib/src/model/category.dart
26+
lib/src/model/order.dart
27+
lib/src/model/pet.dart
28+
lib/src/model/tag.dart
29+
lib/src/model/user.dart
30+
lib/src/offset_date_serializer.dart
31+
lib/src/serializers.dart
32+
pubspec.yaml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.16.0-SNAPSHOT
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# openapi (EXPERIMENTAL)
2+
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
3+
4+
This Dart package is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
5+
6+
- API version: 1.0.0
7+
- Generator version: 7.16.0-SNAPSHOT
8+
- Build package: org.openapitools.codegen.languages.DartDioClientCodegen
9+
10+
## Requirements
11+
12+
* Dart 2.15.0+ or Flutter 2.8.0+
13+
* Dio 5.0.0+ (https://pub.dev/packages/dio)
14+
* timemachine option currently **DOES NOT** support sound null-safety and may not work
15+
16+
## Installation & Usage
17+
18+
### pub.dev
19+
To use the package from [pub.dev](https://pub.dev), please include the following in pubspec.yaml
20+
```yaml
21+
dependencies:
22+
openapi: 1.0.0
23+
```
24+
25+
### Github
26+
If this Dart package is published to Github, please include the following in pubspec.yaml
27+
```yaml
28+
dependencies:
29+
openapi:
30+
git:
31+
url: https://github.com/GIT_USER_ID/GIT_REPO_ID.git
32+
#ref: main
33+
```
34+
35+
### Local development
36+
To use the package from your local drive, please include the following in pubspec.yaml
37+
```yaml
38+
dependencies:
39+
openapi:
40+
path: /path/to/openapi
41+
```
42+
43+
## Getting Started
44+
45+
Please follow the [installation procedure](#installation--usage) and then run the following:
46+
47+
```dart
48+
import 'package:openapi/openapi.dart';
49+
50+
51+
final api = Openapi().getPetApi();
52+
final Pet pet = ; // Pet | Pet object that needs to be added to the store
53+
54+
try {
55+
final response = await api.addPet(pet);
56+
print(response);
57+
} catch on DioException (e) {
58+
print("Exception when calling PetApi->addPet: $e\n");
59+
}
60+
61+
```
62+
63+
## Documentation for API Endpoints
64+
65+
All URIs are relative to *http://petstore.swagger.io/v2*
66+
67+
Class | Method | HTTP request | Description
68+
------------ | ------------- | ------------- | -------------
69+
[*PetApi*](doc/PetApi.md) | [**addPet**](doc/PetApi.md#addpet) | **POST** /pet | Add a new pet to the store
70+
[*PetApi*](doc/PetApi.md) | [**deletePet**](doc/PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet
71+
[*PetApi*](doc/PetApi.md) | [**findPetsByStatus**](doc/PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status
72+
[*PetApi*](doc/PetApi.md) | [**findPetsByTags**](doc/PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags
73+
[*PetApi*](doc/PetApi.md) | [**getPetById**](doc/PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID
74+
[*PetApi*](doc/PetApi.md) | [**updatePet**](doc/PetApi.md#updatepet) | **PUT** /pet | Update an existing pet
75+
[*PetApi*](doc/PetApi.md) | [**updatePetWithForm**](doc/PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data
76+
[*PetApi*](doc/PetApi.md) | [**uploadFile**](doc/PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image
77+
[*StoreApi*](doc/StoreApi.md) | [**deleteOrder**](doc/StoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID
78+
[*StoreApi*](doc/StoreApi.md) | [**getInventory**](doc/StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status
79+
[*StoreApi*](doc/StoreApi.md) | [**getOrderById**](doc/StoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID
80+
[*StoreApi*](doc/StoreApi.md) | [**placeOrder**](doc/StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet
81+
[*UserApi*](doc/UserApi.md) | [**createUser**](doc/UserApi.md#createuser) | **POST** /user | Create user
82+
[*UserApi*](doc/UserApi.md) | [**createUsersWithArrayInput**](doc/UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array
83+
[*UserApi*](doc/UserApi.md) | [**createUsersWithListInput**](doc/UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array
84+
[*UserApi*](doc/UserApi.md) | [**deleteUser**](doc/UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user
85+
[*UserApi*](doc/UserApi.md) | [**getUserByName**](doc/UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name
86+
[*UserApi*](doc/UserApi.md) | [**loginUser**](doc/UserApi.md#loginuser) | **GET** /user/login | Logs user into the system
87+
[*UserApi*](doc/UserApi.md) | [**logoutUser**](doc/UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session
88+
[*UserApi*](doc/UserApi.md) | [**updateUser**](doc/UserApi.md#updateuser) | **PUT** /user/{username} | Updated user
89+
90+
91+
## Documentation For Models
92+
93+
- [ApiResponse](doc/ApiResponse.md)
94+
- [Category](doc/Category.md)
95+
- [Order](doc/Order.md)
96+
- [Pet](doc/Pet.md)
97+
- [Tag](doc/Tag.md)
98+
- [User](doc/User.md)
99+
100+
101+
## Documentation For Authorization
102+
103+
104+
Authentication schemes defined for the API:
105+
### petstore_auth
106+
107+
- **Type**: OAuth
108+
- **Flow**: implicit
109+
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
110+
- **Scopes**:
111+
- **write:pets**: modify pets in your account
112+
- **read:pets**: read your pets
113+
114+
### api_key
115+
116+
- **Type**: API key
117+
- **API key parameter name**: api_key
118+
- **Location**: HTTP header
119+
120+
121+
## Author
122+
123+
124+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
analyzer:
2+
language:
3+
strict-inference: true
4+
strict-raw-types: true
5+
strict-casts: false
6+
exclude:
7+
- test/*.dart
8+
errors:
9+
deprecated_member_use_from_same_package: ignore
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# openapi.model.ApiResponse
2+
3+
## Load the model package
4+
```dart
5+
import 'package:openapi/api.dart';
6+
```
7+
8+
## Properties
9+
Name | Type | Description | Notes
10+
------------ | ------------- | ------------- | -------------
11+
**code** | **int** | | [optional]
12+
**type** | **String** | | [optional]
13+
**message** | **String** | | [optional]
14+
15+
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
16+
17+

0 commit comments

Comments
 (0)