[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:convert';
import 'package:http/http.dart';
import 'package:meta/meta.dart';
part 'api_client.dart';
part 'api_helper.dart';

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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