Skip to content

Commit

Permalink
Version/2.1.0 prerelease.8 (#222)
Browse files Browse the repository at this point in the history
* Added dollars to all generated classes like mappings and jsonSerializable converter

* Fixed some things

* Updated changelog and pubspec

* Added example
Added generation of get hashCode

* Removed build_only_models parameter

* Fixed tests

Co-authored-by: uladzimir_paliukhovich <>
  • Loading branch information
Vovanella95 authored Aug 26, 2021
1 parent 3494b7d commit 74cb318
Show file tree
Hide file tree
Showing 17 changed files with 555 additions and 39 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# 2.1.0-prerelease.9

**BREAKING**: Removed build_only_models_parameter. Now it's always false

# 2.1.0-prerelease.8

* Fixed Issue ([#221](https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/issues/221))
* Added generation of int get hashCode
* Added example

# 2.1.0-prerelease.7

* Fixed Issue ([#186](https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/issues/186))
Expand Down
113 changes: 113 additions & 0 deletions example/lib/example_swagger.swagger
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
{
"openapi": "3.0.3",
"info": {
"title": "Generated API",
"version": "1.0"
},
"tags": [
{
"name": "tag1"
},
{
"name": "tag2"
}
],
"paths": {
"/rooms": {
"get": {
"operationId": "getRooms",
"parameters": [
{
"type": "string",
"description": "Rooms owner",
"name": "id",
"in": "query",
"required": true
}
],
"responses": {
"200": {
"description": "Loaded rooms",
"schema": {
"type": "array",
"items": {
"$ref": "#/definitions/room"
}
}
}
}
}
},
"/api/item/all": {
"get": {
"tags": [
"tag1"
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ListCustomItem"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"room": {
"type": "object",
"properties": {
"author": {
"description": "UUIDv4 of author of last message",
"type": "string"
},
"avatar": {
"description": "UUIDv4 of fake user as avatar of room",
"type": "string"
},
"id": {
"description": "UUIDv4 of room",
"type": "string"
},
"lastMessage": {
"description": "Last message payload",
"type": "string"
},
"name": {
"description": "Fake user name as room name",
"type": "string"
}
}
},
"CustomItem": {
"type": "object",
"properties": {
"available": {
"type": "boolean"
},
"description": {
"type": "string"
},
"id": {
"type": "string"
},
"name": {
"type": "string"
}
}
},
"ListCustomItem": {
"type": "array",
"items": {
"$ref": "#/components/schemas/CustomItem"
}
}
}
}
}
1 change: 1 addition & 0 deletions example/lib/swagger_generated_code/client_index.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export 'example_swagger.swagger.dart' show ExampleSwagger;
5 changes: 5 additions & 0 deletions example/lib/swagger_generated_code/client_mapping.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import 'example_swagger.swagger.dart';

final Map<Type, Object Function(Map<String, dynamic>)> generatedMapping = {
...ExampleSwaggerJsonDecoderMappings,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//Generated code

part of 'example_swagger.swagger.dart';

// **************************************************************************
// ChopperGenerator
// **************************************************************************

// ignore_for_file: always_put_control_body_on_new_line, always_specify_types, prefer_const_declarations
class _$ExampleSwagger extends ExampleSwagger {
_$ExampleSwagger([ChopperClient? client]) {
if (client == null) return;
this.client = client;
}

@override
final definitionType = ExampleSwagger;

@override
Future<Response<List<Room>>> roomsGet({required String? id}) {
final $url = '/rooms';
final $params = <String, dynamic>{'id': id};
final $request = Request('GET', $url, client.baseUrl, parameters: $params);
return client.send<List<Room>, Room>($request);
}

@override
Future<Response<ListCustomItem>> apiItemAllGet() {
final $url = '/api/item/all';
final $request = Request('GET', $url, client.baseUrl);
return client.send<ListCustomItem, ListCustomItem>($request);
}
}
Loading

0 comments on commit 74cb318

Please sign in to comment.