[Dart] Annotate required named parameters in model (#6798)

This commit is contained in:
agilob 2020-07-22 10:14:36 +01:00 committed by GitHub
parent 454ceb45fa
commit df2c927dcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 13 additions and 9 deletions

View File

@ -3,6 +3,7 @@ library {{pubName}}.api;
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'package:http/http.dart'; import 'package:http/http.dart';
import 'package:meta/meta.dart';
part 'api_client.dart'; part 'api_client.dart';
part 'api_helper.dart'; part 'api_helper.dart';

View File

@ -9,7 +9,7 @@ class {{classname}} {
{{classname}}({ {{classname}}({
{{#vars}} {{#vars}}
this.{{name}}, {{#required}}@required this.{{name}},{{/required}}{{^required}}this.{{name}},{{/required}}
{{/vars}} {{/vars}}
}); });

View File

@ -8,5 +8,6 @@ environment:
sdk: '>=2.0.0 <3.0.0' sdk: '>=2.0.0 <3.0.0'
dependencies: dependencies:
http: '>=0.12.0 <0.13.0' http: '>=0.12.0 <0.13.0'
meta: ^1.1.8
dev_dependencies: dev_dependencies:
test: ^1.3.0 test: ^1.3.0

View File

@ -28,11 +28,11 @@ void main() {
return Pet( return Pet(
id : id, id : id,
category: category, category: category,
tags: tags, name: name, //required field
name: name, photoUrls: ['https://petstore.com/sample/photo1.jpg'] //required field
) )
..status = status ..tags = tags
..photoUrls = ['https://petstore.com/sample/photo1.jpg']; ..status = '';
} }
group('Pet API with live client', () { group('Pet API with live client', () {

View File

@ -3,6 +3,7 @@ library openapi.api;
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'package:http/http.dart'; import 'package:http/http.dart';
import 'package:meta/meta.dart';
part 'api_client.dart'; part 'api_client.dart';
part 'api_helper.dart'; part 'api_helper.dart';

View File

@ -18,8 +18,8 @@ class Pet {
Pet({ Pet({
this.id, this.id,
this.category, this.category,
this.name, @required this.name,
this.photoUrls, @required this.photoUrls,
this.tags, this.tags,
this.status, this.status,
}); });

View File

@ -8,5 +8,6 @@ environment:
sdk: '>=2.0.0 <3.0.0' sdk: '>=2.0.0 <3.0.0'
dependencies: dependencies:
http: '>=0.12.0 <0.13.0' http: '>=0.12.0 <0.13.0'
meta: ^1.1.8
dev_dependencies: dev_dependencies:
test: ^1.3.0 test: ^1.3.0