diff --git a/bin/dart-petstore.sh b/bin/dart-petstore.sh index 466a27b657bb..587ab1757d76 100755 --- a/bin/dart-petstore.sh +++ b/bin/dart-petstore.sh @@ -27,12 +27,21 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -t modules/swagger-codegen/src/main/resources/dart -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l dart -o samples/client/petstore/dart/swagger -DhideGenerationTimestamp=true" +# Generate non-browserClient +ags="$@ generate -t modules/swagger-codegen/src/main/resources/dart -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l dart -o samples/client/petstore/dart/swagger -DhideGenerationTimestamp=true -DbrowserClient=false" # then options to generate the library for vm would be: #ags="$@ generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l dart -o samples/client/petstore/dart/swagger_vm -DbrowserClient=false -DpubName=swagger_vm" java $JAVA_OPTS -jar $executable $ags +# Generate browserClient +ags="$@ generate -t modules/swagger-codegen/src/main/resources/dart -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l dart -o samples/client/petstore/dart/swagger-browser-client -DhideGenerationTimestamp=true -DbrowserClient=true" +java $JAVA_OPTS -jar $executable $ags + +# Generate non-browserClient and put it to the flutter sample app +ags="$@ generate -t modules/swagger-codegen/src/main/resources/dart -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l dart -o samples/client/petstore/dart/flutter_petstore/swagger -DhideGenerationTimestamp=true -DbrowserClient=false" +java $JAVA_OPTS -jar $executable $ags + # There is a proposal to allow importing different libraries depending on the environment: # https://github.com/munificent/dep-interface-libraries # When this is implemented there will only be one library. diff --git a/bin/windows/dart-petstore.bat b/bin/windows/dart-petstore.bat index 07ef13f6e387..d4c3c8cba0c8 100755 --- a/bin/windows/dart-petstore.bat +++ b/bin/windows/dart-petstore.bat @@ -5,6 +5,11 @@ If Not Exist %executable% ( ) REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties -set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -l dart -o samples\client\petstore\dart +set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -l dart -o samples\client\petstore\dart\swagger -DhideGenerationTimestamp=true -DbrowserClient=false +java %JAVA_OPTS% -jar %executable% %ags% + +set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -l dart -o samples\client\petstore\dart\swagger-browser-client -DhideGenerationTimestamp=true -DbrowserClient=true +java %JAVA_OPTS% -jar %executable% %ags% +set ags=generate -i modules\swagger-codegen\src\test\resources\2_0\petstore.yaml -l dart -o samples\client\petstore\dart\flutter_petstore\swagger -DhideGenerationTimestamp=true -DbrowserClient=false java %JAVA_OPTS% -jar %executable% %ags% diff --git a/modules/swagger-codegen/src/main/resources/dart/README.mustache b/modules/swagger-codegen/src/main/resources/dart/README.mustache index c6620349a4a6..50c40a4d6dac 100644 --- a/modules/swagger-codegen/src/main/resources/dart/README.mustache +++ b/modules/swagger-codegen/src/main/resources/dart/README.mustache @@ -19,7 +19,7 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}}) ## Requirements -Dart 1.20.0 and later +Dart 1.20.0 or later OR Flutter 0.0.20 or later ## Installation & Usage diff --git a/modules/swagger-codegen/src/main/resources/dart/api.mustache b/modules/swagger-codegen/src/main/resources/dart/api.mustache index dfeb6995f674..4717508cd378 100644 --- a/modules/swagger-codegen/src/main/resources/dart/api.mustache +++ b/modules/swagger-codegen/src/main/resources/dart/api.mustache @@ -54,7 +54,7 @@ class {{classname}} { {{#formParams}}{{#notFile}} if ({{paramName}} != null) { hasFields = true; - mp.fields['{{baseName}}'] = apiClient.parameterToString({{paramName}}); + mp.fields['{{baseName}}'] = parameterToString({{paramName}}); } {{/notFile}}{{#isFile}} if ({{paramName}} != null) { @@ -68,7 +68,7 @@ class {{classname}} { } else { {{#formParams}}{{#notFile}}if ({{paramName}} != null) - formParams['{{baseName}}'] = apiClient.parameterToString({{paramName}});{{/notFile}} + formParams['{{baseName}}'] = parameterToString({{paramName}});{{/notFile}} {{/formParams}} } diff --git a/modules/swagger-codegen/src/main/resources/dart/api_client.mustache b/modules/swagger-codegen/src/main/resources/dart/api_client.mustache index f35db7dbaed8..7ab9ae90c710 100644 --- a/modules/swagger-codegen/src/main/resources/dart/api_client.mustache +++ b/modules/swagger-codegen/src/main/resources/dart/api_client.mustache @@ -15,16 +15,6 @@ class ApiClient { Map _defaultHeaderMap = {}; Map _authentications = {}; - final dson = new Dartson.JSON() - {{#models}} - {{#model}} - {{#isEnum}} - ..addTransformer(new {{classname}}TypeTransformer(), {{classname}}) - {{/isEnum}} - {{/model}} - {{/models}} - ..addTransformer(new DateTimeParser(), DateTime); - final _RegList = new RegExp(r'^List<(.*)>$'); final _RegMap = new RegExp(r'^Map$'); @@ -61,7 +51,7 @@ class ApiClient { return listResult[0]; {{/isEnum}} {{^isEnum}} - return dson.map(value, new {{classname}}()); + return new {{classname}}.fromJson(value); {{/isEnum}} {{/model}} {{/models}} @@ -100,10 +90,8 @@ class ApiClient { String serialized = ''; if (obj == null) { serialized = ''; - } else if (obj is String) { - serialized = obj; } else { - serialized = dson.encode(obj); + serialized = JSON.encode(obj); } return serialized; } diff --git a/modules/swagger-codegen/src/main/resources/dart/api_helper.mustache b/modules/swagger-codegen/src/main/resources/dart/api_helper.mustache index 48de5ab24b0f..3929fa2b7628 100644 --- a/modules/swagger-codegen/src/main/resources/dart/api_helper.mustache +++ b/modules/swagger-codegen/src/main/resources/dart/api_helper.mustache @@ -11,7 +11,7 @@ Iterable _convertParametersForCollectionFormat( if (name == null || name.isEmpty || value == null) return params; if (value is! List) { - params.add(new QueryParam(name, _parameterToString(value))); + params.add(new QueryParam(name, parameterToString(value))); return params; } @@ -23,17 +23,17 @@ Iterable _convertParametersForCollectionFormat( : collectionFormat; // default: csv if (collectionFormat == "multi") { - return values.map((v) => new QueryParam(name, _parameterToString(v))); + return values.map((v) => new QueryParam(name, parameterToString(v))); } String delimiter = _delimiters[collectionFormat] ?? ","; - params.add(new QueryParam(name, values.map((v)=>_parameterToString(v)).join(delimiter))); + params.add(new QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter))); return params; } /// Format the given parameter object into string. -String _parameterToString(dynamic value) { +String parameterToString(dynamic value) { if (value == null) { return ''; } else if (value is DateTime) { diff --git a/modules/swagger-codegen/src/main/resources/dart/apilib.mustache b/modules/swagger-codegen/src/main/resources/dart/apilib.mustache index 8782ce2236d8..818f878c6174 100644 --- a/modules/swagger-codegen/src/main/resources/dart/apilib.mustache +++ b/modules/swagger-codegen/src/main/resources/dart/apilib.mustache @@ -4,9 +4,6 @@ import 'dart:async'; import 'dart:convert';{{#browserClient}} import 'package:http/browser_client.dart';{{/browserClient}} import 'package:http/http.dart'; -import 'package:dartson/dartson.dart'; -import 'package:dartson/transformers/date_time.dart'; -import 'package:dartson/type_transformer.dart'; part 'api_client.dart'; part 'api_helper.dart'; diff --git a/modules/swagger-codegen/src/main/resources/dart/auth/api_key_auth.mustache b/modules/swagger-codegen/src/main/resources/dart/auth/api_key_auth.mustache index 7f3ac22ecd85..86bde8a90f54 100644 --- a/modules/swagger-codegen/src/main/resources/dart/auth/api_key_auth.mustache +++ b/modules/swagger-codegen/src/main/resources/dart/auth/api_key_auth.mustache @@ -24,4 +24,4 @@ class ApiKeyAuth implements Authentication { headerParams[paramName] = value; } } -} \ No newline at end of file +} diff --git a/modules/swagger-codegen/src/main/resources/dart/auth/oauth.mustache b/modules/swagger-codegen/src/main/resources/dart/auth/oauth.mustache index 24413b9c3da8..4b26a7a8ddf9 100644 --- a/modules/swagger-codegen/src/main/resources/dart/auth/oauth.mustache +++ b/modules/swagger-codegen/src/main/resources/dart/auth/oauth.mustache @@ -6,4 +6,4 @@ class OAuth implements Authentication { void applyToParams(List queryParams, Map headerParams) { // TODO: support oauth } -} \ No newline at end of file +} diff --git a/modules/swagger-codegen/src/main/resources/dart/class.mustache b/modules/swagger-codegen/src/main/resources/dart/class.mustache index d92258c484fa..83e04bba4f20 100644 --- a/modules/swagger-codegen/src/main/resources/dart/class.mustache +++ b/modules/swagger-codegen/src/main/resources/dart/class.mustache @@ -1,14 +1,54 @@ -@Entity() class {{classname}} { {{#vars}}{{#description}}/* {{{description}}} */{{/description}} - @Property(name: '{{baseName}}') {{{datatype}}} {{name}} = {{{defaultValue}}}; {{#allowableValues}}{{#min}} // range from {{min}} to {{max}}{{/min}}//{{^min}}enum {{name}}Enum { {{#values}} {{.}}, {{/values}} };{{/min}}{{/allowableValues}} {{/vars}} {{classname}}(); @override - String toString() { + String toString() { return '{{classname}}[{{#vars}}{{name}}=${{name}}, {{/vars}}]'; } + + {{classname}}.fromJson(Map json) { + if (json == null) return; + {{#vars}} + {{#isDateTime}} + {{name}} = json['{{name}}'] == null ? null : DateTime.parse(json['{{name}}']); + {{/isDateTime}} + {{^isDateTime}} + {{name}} = + {{#complexType}} + {{#isListContainer}}{{complexType}}.listFromJson(json['{{name}}']){{/isListContainer}}{{^isListContainer}} + {{#isMapContainer}}{{complexType}}.mapFromJson(json['{{name}}']){{/isMapContainer}} + {{^isMapContainer}}new {{complexType}}.fromJson(json['{{name}}']){{/isMapContainer}}{{/isListContainer}} + {{/complexType}} + {{^complexType}}json['{{name}}']{{/complexType}}; + {{/isDateTime}} + {{/vars}} + } + + Map toJson() { + return { + {{#vars}} + {{#isDateTime}}'{{name}}': {{name}} == null ? '' : {{name}}.toUtc().toIso8601String(){{^-last}},{{/-last}}{{/isDateTime}}{{^isDateTime}}'{{name}}': {{name}}{{^-last}},{{/-last}}{{/isDateTime}} + {{/vars}} + }; + } + + static List<{{classname}}> listFromJson(List> json) { + var list = new List<{{classname}}>(); + if (json != null && json.length > 0) { + json.forEach((Map value) => list.add(new {{classname}}.fromJson(value))); + } + return list; + } + + static Map mapFromJson(Map> json) { + var map = new Map(); + if (json != null && json.length > 0) { + json.forEach((String key, Map value) => map[key] = new {{classname}}.fromJson(value)); + } + return map; + } } diff --git a/modules/swagger-codegen/src/main/resources/dart/pubspec.mustache b/modules/swagger-codegen/src/main/resources/dart/pubspec.mustache index 5a580b2696d7..a338854b7485 100644 --- a/modules/swagger-codegen/src/main/resources/dart/pubspec.mustache +++ b/modules/swagger-codegen/src/main/resources/dart/pubspec.mustache @@ -3,11 +3,3 @@ version: {{pubVersion}} description: {{pubDescription}} dependencies: http: '>=0.11.1 <0.12.0' - dartson: "^0.2.4" - -dev_dependencies: - guinness: '^0.1.17' - browser: any - -transformers: - - dartson diff --git a/samples/client/petstore/dart/flutter_petstore/.gitignore b/samples/client/petstore/dart/flutter_petstore/.gitignore new file mode 100644 index 000000000000..eb15c3d27cab --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/.gitignore @@ -0,0 +1,10 @@ +.DS_Store +.atom/ +.idea +.packages +.pub/ +build/ +ios/.generated/ +packages +pubspec.lock +.flutter-plugins diff --git a/samples/client/petstore/dart/flutter_petstore/.metadata b/samples/client/petstore/dart/flutter_petstore/.metadata new file mode 100644 index 000000000000..a700013d0b75 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/.metadata @@ -0,0 +1,8 @@ +# This file tracks properties of this Flutter project. +# Used by Flutter tool to assess capabilities and perform upgrades etc. +# +# This file should be version controlled and should not be manually edited. + +version: + revision: 8f65fec5f5f7d7afbb0965f4a44bdb330a28fb19 + channel: alpha diff --git a/samples/client/petstore/dart/flutter_petstore/README.md b/samples/client/petstore/dart/flutter_petstore/README.md new file mode 100644 index 000000000000..bfad735663d2 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/README.md @@ -0,0 +1,8 @@ +# flutter_petstore + +Swagger petstore sample flutter + +## Getting Started + +For help getting started with Flutter, view our online +[documentation](http://flutter.io/). diff --git a/samples/client/petstore/dart/flutter_petstore/android/.gitignore b/samples/client/petstore/dart/flutter_petstore/android/.gitignore new file mode 100644 index 000000000000..1658458c9245 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/android/.gitignore @@ -0,0 +1,9 @@ +*.iml +.gradle +/local.properties +/.idea/workspace.xml +/.idea/libraries +.DS_Store +/build +/captures +GeneratedPluginRegistrant.java diff --git a/samples/client/petstore/dart/flutter_petstore/android/app/build.gradle b/samples/client/petstore/dart/flutter_petstore/android/app/build.gradle new file mode 100644 index 000000000000..535c29bb3893 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/android/app/build.gradle @@ -0,0 +1,52 @@ +def localProperties = new Properties() +def localPropertiesFile = rootProject.file('local.properties') +if (localPropertiesFile.exists()) { + localPropertiesFile.withInputStream { stream -> + localProperties.load(stream) + } +} + +def flutterRoot = localProperties.getProperty('flutter.sdk') +if (flutterRoot == null) { + throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") +} + +apply plugin: 'com.android.application' +apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" + +android { + compileSdkVersion 25 + buildToolsVersion '25.0.3' + + lintOptions { + disable 'InvalidPackage' + } + + defaultConfig { + // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). + applicationId "com.yourcompany.flutterpetstore" + minSdkVersion 16 + targetSdkVersion 25 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + + buildTypes { + release { + // TODO: Add your own signing config for the release build. + // Signing with the debug keys for now, so `flutter run --release` works. + signingConfig signingConfigs.debug + } + } +} + +flutter { + source '../..' +} + +dependencies { + androidTestCompile 'com.android.support:support-annotations:25.4.0' + androidTestCompile 'com.android.support.test:runner:0.5' + androidTestCompile 'com.android.support.test:rules:0.5' +} diff --git a/samples/client/petstore/dart/flutter_petstore/android/app/src/main/AndroidManifest.xml b/samples/client/petstore/dart/flutter_petstore/android/app/src/main/AndroidManifest.xml new file mode 100644 index 000000000000..4532f5399883 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/android/app/src/main/AndroidManifest.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + diff --git a/samples/client/petstore/dart/flutter_petstore/android/app/src/main/java/com/yourcompany/flutterpetstore/MainActivity.java b/samples/client/petstore/dart/flutter_petstore/android/app/src/main/java/com/yourcompany/flutterpetstore/MainActivity.java new file mode 100644 index 000000000000..5c99c848d539 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/android/app/src/main/java/com/yourcompany/flutterpetstore/MainActivity.java @@ -0,0 +1,14 @@ +package com.yourcompany.flutterpetstore; + +import android.os.Bundle; + +import io.flutter.app.FlutterActivity; +import io.flutter.plugins.GeneratedPluginRegistrant; + +public class MainActivity extends FlutterActivity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + GeneratedPluginRegistrant.registerWith(this); + } +} diff --git a/samples/client/petstore/dart/flutter_petstore/android/app/src/main/res/drawable/launch_background.xml b/samples/client/petstore/dart/flutter_petstore/android/app/src/main/res/drawable/launch_background.xml new file mode 100644 index 000000000000..304732f88420 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/android/app/src/main/res/drawable/launch_background.xml @@ -0,0 +1,12 @@ + + + + + + + + diff --git a/samples/client/petstore/dart/flutter_petstore/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/samples/client/petstore/dart/flutter_petstore/android/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 000000000000..db77bb4b7b09 Binary files /dev/null and b/samples/client/petstore/dart/flutter_petstore/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/samples/client/petstore/dart/flutter_petstore/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/samples/client/petstore/dart/flutter_petstore/android/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 000000000000..17987b79bb8a Binary files /dev/null and b/samples/client/petstore/dart/flutter_petstore/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/samples/client/petstore/dart/flutter_petstore/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/samples/client/petstore/dart/flutter_petstore/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 000000000000..09d4391482be Binary files /dev/null and b/samples/client/petstore/dart/flutter_petstore/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/samples/client/petstore/dart/flutter_petstore/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/samples/client/petstore/dart/flutter_petstore/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 000000000000..d5f1c8d34e7a Binary files /dev/null and b/samples/client/petstore/dart/flutter_petstore/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/samples/client/petstore/dart/flutter_petstore/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/samples/client/petstore/dart/flutter_petstore/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 000000000000..4d6372eebdb2 Binary files /dev/null and b/samples/client/petstore/dart/flutter_petstore/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/samples/client/petstore/dart/flutter_petstore/android/app/src/main/res/values/styles.xml b/samples/client/petstore/dart/flutter_petstore/android/app/src/main/res/values/styles.xml new file mode 100644 index 000000000000..00fa4417cfbe --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/android/app/src/main/res/values/styles.xml @@ -0,0 +1,8 @@ + + + + diff --git a/samples/client/petstore/dart/flutter_petstore/android/build.gradle b/samples/client/petstore/dart/flutter_petstore/android/build.gradle new file mode 100644 index 000000000000..77cbd091409d --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/android/build.gradle @@ -0,0 +1,31 @@ +buildscript { + repositories { + jcenter() + maven { + url "https://maven.google.com" + } + } + + dependencies { + classpath 'com.android.tools.build:gradle:2.3.3' + } +} + +allprojects { + repositories { + jcenter() + maven { + url "https://maven.google.com" + } + } +} + +rootProject.buildDir = '../build' +subprojects { + project.buildDir = "${rootProject.buildDir}/${project.name}" + project.evaluationDependsOn(':app') +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/samples/client/petstore/dart/flutter_petstore/android/gradle.properties b/samples/client/petstore/dart/flutter_petstore/android/gradle.properties new file mode 100644 index 000000000000..8bd86f680510 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/android/gradle.properties @@ -0,0 +1 @@ +org.gradle.jvmargs=-Xmx1536M diff --git a/samples/client/petstore/dart/flutter_petstore/android/gradle/wrapper/gradle-wrapper.jar b/samples/client/petstore/dart/flutter_petstore/android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000000..13372aef5e24 Binary files /dev/null and b/samples/client/petstore/dart/flutter_petstore/android/gradle/wrapper/gradle-wrapper.jar differ diff --git a/samples/client/petstore/dart/flutter_petstore/android/gradle/wrapper/gradle-wrapper.properties b/samples/client/petstore/dart/flutter_petstore/android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000000..45e7f14e952d --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Jun 23 08:50:38 CEST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip diff --git a/samples/client/petstore/dart/flutter_petstore/android/gradlew b/samples/client/petstore/dart/flutter_petstore/android/gradlew new file mode 100755 index 000000000000..9d82f7891513 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/android/gradlew @@ -0,0 +1,160 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/samples/client/petstore/dart/flutter_petstore/android/gradlew.bat b/samples/client/petstore/dart/flutter_petstore/android/gradlew.bat new file mode 100644 index 000000000000..8a0b282aa688 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/android/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/samples/client/petstore/dart/flutter_petstore/android/settings.gradle b/samples/client/petstore/dart/flutter_petstore/android/settings.gradle new file mode 100644 index 000000000000..115da6cb4f4d --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/android/settings.gradle @@ -0,0 +1,15 @@ +include ':app' + +def flutterProjectRoot = rootProject.projectDir.parentFile.toPath() + +def plugins = new Properties() +def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins') +if (pluginsFile.exists()) { + pluginsFile.withInputStream { stream -> plugins.load(stream) } +} + +plugins.each { name, path -> + def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile() + include ":$name" + project(":$name").projectDir = pluginDirectory +} diff --git a/samples/client/petstore/dart/flutter_petstore/ios/.gitignore b/samples/client/petstore/dart/flutter_petstore/ios/.gitignore new file mode 100644 index 000000000000..38864eed23ef --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/ios/.gitignore @@ -0,0 +1,41 @@ +.idea/ +.vagrant/ +.sconsign.dblite +.svn/ + +.DS_Store +*.swp +profile + +DerivedData/ +build/ +GeneratedPluginRegistrant.h +GeneratedPluginRegistrant.m + +*.pbxuser +*.mode1v3 +*.mode2v3 +*.perspectivev3 + +!default.pbxuser +!default.mode1v3 +!default.mode2v3 +!default.perspectivev3 + +xcuserdata + +*.moved-aside + +*.pyc +*sync/ +Icon? +.tags* + +/Flutter/app.flx +/Flutter/app.zip +/Flutter/App.framework +/Flutter/Flutter.framework +/Flutter/Generated.xcconfig +/ServiceDefinitions.json + +Pods/ diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Flutter/AppFrameworkInfo.plist b/samples/client/petstore/dart/flutter_petstore/ios/Flutter/AppFrameworkInfo.plist new file mode 100644 index 000000000000..6c2de8086bcd --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/ios/Flutter/AppFrameworkInfo.plist @@ -0,0 +1,30 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + App + CFBundleIdentifier + io.flutter.flutter.app + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + App + CFBundlePackageType + FMWK + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1.0 + UIRequiredDeviceCapabilities + + arm64 + + MinimumOSVersion + 8.0 + + diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Flutter/Debug.xcconfig b/samples/client/petstore/dart/flutter_petstore/ios/Flutter/Debug.xcconfig new file mode 100644 index 000000000000..592ceee85b89 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/ios/Flutter/Debug.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Flutter/Release.xcconfig b/samples/client/petstore/dart/flutter_petstore/ios/Flutter/Release.xcconfig new file mode 100644 index 000000000000..592ceee85b89 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/ios/Flutter/Release.xcconfig @@ -0,0 +1 @@ +#include "Generated.xcconfig" diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner.xcodeproj/project.pbxproj b/samples/client/petstore/dart/flutter_petstore/ios/Runner.xcodeproj/project.pbxproj new file mode 100644 index 000000000000..9b2e4b7cda85 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/ios/Runner.xcodeproj/project.pbxproj @@ -0,0 +1,436 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; + 3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; }; + 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; }; + 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB21CF90195004384FC /* Debug.xcconfig */; }; + 9740EEB51CF90195004384FC /* Generated.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB31CF90195004384FC /* Generated.xcconfig */; }; + 9740EEBB1CF902C7004384FC /* app.flx in Resources */ = {isa = PBXBuildFile; fileRef = 9740EEB71CF902C7004384FC /* app.flx */; }; + 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; + 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXCopyFilesBuildPhase section */ + 9705A1C41CF9048500538489 /* Embed Frameworks */ = { + isa = PBXCopyFilesBuildPhase; + buildActionMask = 2147483647; + dstPath = ""; + dstSubfolderSpec = 10; + files = ( + 3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */, + 9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */, + ); + name = "Embed Frameworks"; + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXCopyFilesBuildPhase section */ + +/* Begin PBXFileReference section */ + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; + 3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = ""; }; + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; + 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; + 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; + 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; + 9740EEB71CF902C7004384FC /* app.flx */ = {isa = PBXFileReference; lastKnownFileType = file; name = app.flx; path = Flutter/app.flx; sourceTree = ""; }; + 9740EEBA1CF902C7004384FC /* Flutter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Flutter.framework; path = Flutter/Flutter.framework; sourceTree = ""; }; + 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 97C146F21CF9000F007C117D /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; + 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 97C146EB1CF9000F007C117D /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */, + 3B80C3941E831B6300D905FE /* App.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 9740EEB11CF90186004384FC /* Flutter */ = { + isa = PBXGroup; + children = ( + 9740EEB71CF902C7004384FC /* app.flx */, + 3B80C3931E831B6300D905FE /* App.framework */, + 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, + 9740EEBA1CF902C7004384FC /* Flutter.framework */, + 9740EEB21CF90195004384FC /* Debug.xcconfig */, + 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, + 9740EEB31CF90195004384FC /* Generated.xcconfig */, + ); + name = Flutter; + sourceTree = ""; + }; + 97C146E51CF9000F007C117D = { + isa = PBXGroup; + children = ( + 9740EEB11CF90186004384FC /* Flutter */, + 97C146F01CF9000F007C117D /* Runner */, + 97C146EF1CF9000F007C117D /* Products */, + CF3B75C9A7D2FA2A4C99F110 /* Frameworks */, + ); + sourceTree = ""; + }; + 97C146EF1CF9000F007C117D /* Products */ = { + isa = PBXGroup; + children = ( + 97C146EE1CF9000F007C117D /* Runner.app */, + ); + name = Products; + sourceTree = ""; + }; + 97C146F01CF9000F007C117D /* Runner */ = { + isa = PBXGroup; + children = ( + 7AFFD8ED1D35381100E5BB4D /* AppDelegate.h */, + 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */, + 97C146FA1CF9000F007C117D /* Main.storyboard */, + 97C146FD1CF9000F007C117D /* Assets.xcassets */, + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, + 97C147021CF9000F007C117D /* Info.plist */, + 97C146F11CF9000F007C117D /* Supporting Files */, + 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, + 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, + ); + path = Runner; + sourceTree = ""; + }; + 97C146F11CF9000F007C117D /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 97C146F21CF9000F007C117D /* main.m */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 97C146ED1CF9000F007C117D /* Runner */ = { + isa = PBXNativeTarget; + buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; + buildPhases = ( + 9740EEB61CF901F6004384FC /* Run Script */, + 97C146EA1CF9000F007C117D /* Sources */, + 97C146EB1CF9000F007C117D /* Frameworks */, + 97C146EC1CF9000F007C117D /* Resources */, + 9705A1C41CF9048500538489 /* Embed Frameworks */, + 3B06AD1E1E4923F5004D2608 /* Thin Binary */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Runner; + productName = Runner; + productReference = 97C146EE1CF9000F007C117D /* Runner.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 97C146E61CF9000F007C117D /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0910; + ORGANIZATIONNAME = "The Chromium Authors"; + TargetAttributes = { + 97C146ED1CF9000F007C117D = { + CreatedOnToolsVersion = 7.3.1; + }; + }; + }; + buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 97C146E51CF9000F007C117D; + productRefGroup = 97C146EF1CF9000F007C117D /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 97C146ED1CF9000F007C117D /* Runner */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 97C146EC1CF9000F007C117D /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 9740EEBB1CF902C7004384FC /* app.flx in Resources */, + 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, + 9740EEB51CF90195004384FC /* Generated.xcconfig in Resources */, + 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, + 9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */, + 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, + 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXShellScriptBuildPhase section */ + 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Thin Binary"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" thin"; + }; + 9740EEB61CF901F6004384FC /* Run Script */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputPaths = ( + ); + name = "Run Script"; + outputPaths = ( + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; + }; +/* End PBXShellScriptBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 97C146EA1CF9000F007C117D /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */, + 97C146F31CF9000F007C117D /* main.m in Sources */, + 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 97C146FA1CF9000F007C117D /* Main.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C146FB1CF9000F007C117D /* Base */, + ); + name = Main.storyboard; + sourceTree = ""; + }; + 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 97C147001CF9000F007C117D /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 97C147031CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 97C147041CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; + MTL_ENABLE_DEBUG_INFO = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 97C147061CF9000F007C117D /* Debug */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; + buildSettings = { + ARCHS = arm64; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.flutterPetstore; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Debug; + }; + 97C147071CF9000F007C117D /* Release */ = { + isa = XCBuildConfiguration; + baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; + buildSettings = { + ARCHS = arm64; + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ENABLE_BITCODE = NO; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + INFOPLIST_FILE = Runner/Info.plist; + LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Flutter", + ); + PRODUCT_BUNDLE_IDENTIFIER = com.yourcompany.flutterPetstore; + PRODUCT_NAME = "$(TARGET_NAME)"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147031CF9000F007C117D /* Debug */, + 97C147041CF9000F007C117D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 97C147061CF9000F007C117D /* Debug */, + 97C147071CF9000F007C117D /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 97C146E61CF9000F007C117D /* Project object */; +} diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/samples/client/petstore/dart/flutter_petstore/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000000..1d526a16ed0f --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/samples/client/petstore/dart/flutter_petstore/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme new file mode 100644 index 000000000000..1263ac84b105 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner.xcworkspace/contents.xcworkspacedata b/samples/client/petstore/dart/flutter_petstore/ios/Runner.xcworkspace/contents.xcworkspacedata new file mode 100644 index 000000000000..1d526a16ed0f --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/ios/Runner.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,7 @@ + + + + + diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/AppDelegate.h b/samples/client/petstore/dart/flutter_petstore/ios/Runner/AppDelegate.h new file mode 100644 index 000000000000..cf210d213f27 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/ios/Runner/AppDelegate.h @@ -0,0 +1,6 @@ +#import +#import + +@interface AppDelegate : FlutterAppDelegate + +@end diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/AppDelegate.m b/samples/client/petstore/dart/flutter_petstore/ios/Runner/AppDelegate.m new file mode 100644 index 000000000000..112becd13b36 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/ios/Runner/AppDelegate.m @@ -0,0 +1,12 @@ +#include "AppDelegate.h" +#include "GeneratedPluginRegistrant.h" + +@implementation AppDelegate + +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { + [GeneratedPluginRegistrant registerWithRegistry:self]; + // Override point for customization after application launch. + return [super application:application didFinishLaunchingWithOptions:launchOptions]; +} + +@end diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json new file mode 100644 index 000000000000..d22f10b2ab63 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -0,0 +1,116 @@ +{ + "images" : [ + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "20x20", + "idiom" : "iphone", + "filename" : "Icon-App-20x20@3x.png", + "scale" : "3x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "iphone", + "filename" : "Icon-App-29x29@3x.png", + "scale" : "3x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "iphone", + "filename" : "Icon-App-40x40@3x.png", + "scale" : "3x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@2x.png", + "scale" : "2x" + }, + { + "size" : "60x60", + "idiom" : "iphone", + "filename" : "Icon-App-60x60@3x.png", + "scale" : "3x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@1x.png", + "scale" : "1x" + }, + { + "size" : "20x20", + "idiom" : "ipad", + "filename" : "Icon-App-20x20@2x.png", + "scale" : "2x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@1x.png", + "scale" : "1x" + }, + { + "size" : "29x29", + "idiom" : "ipad", + "filename" : "Icon-App-29x29@2x.png", + "scale" : "2x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@1x.png", + "scale" : "1x" + }, + { + "size" : "40x40", + "idiom" : "ipad", + "filename" : "Icon-App-40x40@2x.png", + "scale" : "2x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@1x.png", + "scale" : "1x" + }, + { + "size" : "76x76", + "idiom" : "ipad", + "filename" : "Icon-App-76x76@2x.png", + "scale" : "2x" + }, + { + "size" : "83.5x83.5", + "idiom" : "ipad", + "filename" : "Icon-App-83.5x83.5@2x.png", + "scale" : "2x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png new file mode 100644 index 000000000000..28c6bf03016f Binary files /dev/null and b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png new file mode 100644 index 000000000000..2ccbfd967d96 Binary files /dev/null and b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png new file mode 100644 index 000000000000..f091b6b0bca8 Binary files /dev/null and b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png new file mode 100644 index 000000000000..4cde12118dda Binary files /dev/null and b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png new file mode 100644 index 000000000000..d0ef06e7edb8 Binary files /dev/null and b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png new file mode 100644 index 000000000000..dcdc2306c285 Binary files /dev/null and b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png new file mode 100644 index 000000000000..2ccbfd967d96 Binary files /dev/null and b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png new file mode 100644 index 000000000000..c8f9ed8f5cee Binary files /dev/null and b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png new file mode 100644 index 000000000000..a6d6b8609df0 Binary files /dev/null and b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png new file mode 100644 index 000000000000..a6d6b8609df0 Binary files /dev/null and b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png new file mode 100644 index 000000000000..75b2d164a5a9 Binary files /dev/null and b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png new file mode 100644 index 000000000000..c4df70d39da7 Binary files /dev/null and b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png new file mode 100644 index 000000000000..6a84f41e14e2 Binary files /dev/null and b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png new file mode 100644 index 000000000000..d0e1f5853602 Binary files /dev/null and b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json new file mode 100644 index 000000000000..0bedcf2fd467 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json @@ -0,0 +1,23 @@ +{ + "images" : [ + { + "idiom" : "universal", + "filename" : "LaunchImage.png", + "scale" : "1x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@2x.png", + "scale" : "2x" + }, + { + "idiom" : "universal", + "filename" : "LaunchImage@3x.png", + "scale" : "3x" + } + ], + "info" : { + "version" : 1, + "author" : "xcode" + } +} diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png new file mode 100644 index 000000000000..9da19eacad3b Binary files /dev/null and b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png differ diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png new file mode 100644 index 000000000000..9da19eacad3b Binary files /dev/null and b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png differ diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png new file mode 100644 index 000000000000..9da19eacad3b Binary files /dev/null and b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png differ diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md new file mode 100644 index 000000000000..89c2725b70f1 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md @@ -0,0 +1,5 @@ +# Launch Screen Assets + +You can customize the launch screen with your own desired assets by replacing the image files in this directory. + +You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. \ No newline at end of file diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/Base.lproj/LaunchScreen.storyboard b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Base.lproj/LaunchScreen.storyboard new file mode 100644 index 000000000000..f2e259c7c939 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Base.lproj/LaunchScreen.storyboard @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/Base.lproj/Main.storyboard b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Base.lproj/Main.storyboard new file mode 100644 index 000000000000..f3c28516fb38 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Base.lproj/Main.storyboard @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/Info.plist b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Info.plist new file mode 100644 index 000000000000..b5a04ef774f2 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/ios/Runner/Info.plist @@ -0,0 +1,49 @@ + + + + + CFBundleDevelopmentRegion + en + CFBundleExecutable + $(EXECUTABLE_NAME) + CFBundleIdentifier + $(PRODUCT_BUNDLE_IDENTIFIER) + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + flutter_petstore + CFBundlePackageType + APPL + CFBundleShortVersionString + 1.0 + CFBundleSignature + ???? + CFBundleVersion + 1 + LSRequiresIPhoneOS + + UILaunchStoryboardName + LaunchScreen + UIMainStoryboardFile + Main + UIRequiredDeviceCapabilities + + arm64 + + UISupportedInterfaceOrientations + + UIInterfaceOrientationPortrait + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UISupportedInterfaceOrientations~ipad + + UIInterfaceOrientationPortrait + UIInterfaceOrientationPortraitUpsideDown + UIInterfaceOrientationLandscapeLeft + UIInterfaceOrientationLandscapeRight + + UIViewControllerBasedStatusBarAppearance + + + diff --git a/samples/client/petstore/dart/flutter_petstore/ios/Runner/main.m b/samples/client/petstore/dart/flutter_petstore/ios/Runner/main.m new file mode 100644 index 000000000000..0ccc450011c4 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/ios/Runner/main.m @@ -0,0 +1,9 @@ +#import +#import +#import "AppDelegate.h" + +int main(int argc, char * argv[]) { + @autoreleasepool { + return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); + } +} diff --git a/samples/client/petstore/dart/flutter_petstore/lib/main.dart b/samples/client/petstore/dart/flutter_petstore/lib/main.dart new file mode 100644 index 000000000000..969e33354f3a --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/lib/main.dart @@ -0,0 +1,164 @@ +import 'package:flutter/material.dart'; +import 'package:swagger/api.dart'; + +void main() => runApp(new MyApp()); + +class MyApp extends StatelessWidget { + // This widget is the root of your application. + @override + Widget build(BuildContext context) { + return new MaterialApp( + title: 'Flutter Demo', + theme: new ThemeData( + // This is the theme of your application. + // + // Try running your application with "flutter run". You'll see the + // application has a blue toolbar. Then, without quitting the app, try + // changing the primarySwatch below to Colors.green and then invoke + // "hot reload" (press "r" in the console where you ran "flutter run", + // or press Run > Flutter Hot Reload in IntelliJ). Notice that the + // counter didn't reset back to zero; the application is not restarted. + primarySwatch: Colors.blue, + ), + home: new MyHomePage(title: 'Flutter Demo Home Page'), + ); + } +} + +class MyHomePage extends StatefulWidget { + MyHomePage({Key key, this.title}) : super(key: key); + + // This widget is the home page of your application. It is stateful, meaning + // that it has a State object (defined below) that contains fields that affect + // how it looks. + + // This class is the configuration for the state. It holds the values (in this + // case the title) provided by the parent (in this case the App widget) and + // used by the build method of the State. Fields in a Widget subclass are + // always marked "final". + + final String title; + + @override + _MyHomePageState createState() => new _MyHomePageState(); +} + +class _MyHomePageState extends State { + int _counter = 0; + + void _incrementCounter() { + setState(() { + // This call to setState tells the Flutter framework that something has + // changed in this State, which causes it to rerun the build method below + // so that the display can reflect the updated values. If we changed + // _counter without calling setState(), then the build method would not be + // called again, and so nothing would appear to happen. + _counter++; + }); + } + + @override + void initState() { + super.initState(); + fetchPets(); + fetchStoreInventory(); + fetchUser(); + } + + void fetchPets() { + print('fetching pets by status...'); + var statuses = new List(); + statuses.add('available'); + new PetApi(defaultApiClient).findPetsByStatus(statuses) + .then((List pets) { + print('pets received: '); + print(pets); + var order = new Order(); + order.petId = pets[0].id; + order.quantity = 1; + new StoreApi(defaultApiClient).placeOrder(order) + .then((Order order) => print(order)); + }).catchError((error) { + print('error fetching pets'); + print(error); + }); + } + + void fetchStoreInventory() { + print('fetching inventory...'); + new StoreApi(defaultApiClient).getInventory() + .then((Map inventory) { + print('inventory received: '); + print(inventory); + }).catchError((error) { + print('error fetching inventory'); + print(error); + }); + } + + void fetchUser() { + print('fetching user1...'); + new UserApi(defaultApiClient).getUserByName('user1') + .then((User user) { + print('user received: '); + print(user); + }).catchError((error) { + print('error fetching user'); + print(error); + }); + } + + @override + Widget build(BuildContext context) { + // This method is rerun every time setState is called, for instance as done + // by the _incrementCounter method above. + // + // The Flutter framework has been optimized to make rerunning build methods + // fast, so that you can just rebuild anything that needs updating rather + // than having to individually change instances of widgets. + return new Scaffold( + appBar: new AppBar( + // Here we take the value from the MyHomePage object that was created by + // the App.build method, and use it to set our appbar title. + title: new Text(widget.title), + ), + body: new Center( + // Center is a layout widget. It takes a single child and positions it + // in the middle of the parent. + child: new Column( + // Column is also layout widget. It takes a list of children and + // arranges them vertically. By default, it sizes itself to fit its + // children horizontally, and tries to be as tall as its parent. + // + // Invoke "debug paint" (press "p" in the console where you ran + // "flutter run", or select "Toggle Debug Paint" from the Flutter tool + // window in IntelliJ) to see the wireframe for each widget. + // + // Column has various properties to control how it sizes itself and + // how it positions its children. Here we use mainAxisAlignment to + // center the children vertically; the main axis here is the vertical + // axis because Columns are vertical (the cross axis would be + // horizontal). + mainAxisAlignment: MainAxisAlignment.center, + children: [ + new Text( + 'You have pushed the button this many times:', + ), + new Text( + '$_counter', + style: Theme + .of(context) + .textTheme + .display1, + ), + ], + ), + ), + floatingActionButton: new FloatingActionButton( + onPressed: _incrementCounter, + tooltip: 'Increment', + child: new Icon(Icons.add), + ), // This trailing comma makes auto-formatting nicer for build methods. + ); + } +} diff --git a/samples/client/petstore/dart/flutter_petstore/pubspec.yaml b/samples/client/petstore/dart/flutter_petstore/pubspec.yaml new file mode 100644 index 000000000000..b5ff79c337ab --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/pubspec.yaml @@ -0,0 +1,59 @@ +name: flutter_petstore +description: Swagger petstore sample flutter + +dependencies: + flutter: + sdk: flutter + swagger: + path: ./swagger + + # The following adds the Cupertino Icons font to your application. + # Use with the CupertinoIcons class for iOS style icons. + cupertino_icons: ^0.1.0 + +dev_dependencies: + flutter_test: + sdk: flutter + + +# For information on the generic Dart part of this file, see the +# following page: https://www.dartlang.org/tools/pub/pubspec + +# The following section is specific to Flutter. +flutter: + + # The following line ensures that the Material Icons font is + # included with your application, so that you can use the icons in + # the material Icons class. + uses-material-design: true + + # To add assets to your application, add an assets section, like this: + # assets: + # - images/a_dot_burr.jpeg + # - images/a_dot_ham.jpeg + + # An image asset can refer to one or more resolution-specific "variants", see + # https://flutter.io/assets-and-images/#resolution-aware. + + # For details regarding adding assets from package dependencies, see + # https://flutter.io/assets-and-images/#from-packages + + # To add custom fonts to your application, add a fonts section here, + # in this "flutter" section. Each entry in this list should have a + # "family" key with the font family name, and a "fonts" key with a + # list giving the asset and other descriptors for the font. For + # example: + # fonts: + # - family: Schyler + # fonts: + # - asset: fonts/Schyler-Regular.ttf + # - asset: fonts/Schyler-Italic.ttf + # style: italic + # - family: Trajan Pro + # fonts: + # - asset: fonts/TrajanPro.ttf + # - asset: fonts/TrajanPro_Bold.ttf + # weight: 700 + # + # For details regarding fonts from package dependencies, + # see https://flutter.io/custom-fonts/#from-packages diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/.analysis_options b/samples/client/petstore/dart/flutter_petstore/swagger/.analysis_options new file mode 100644 index 000000000000..518eb901a6ff --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/.analysis_options @@ -0,0 +1,2 @@ +analyzer: + strong-mode: true \ No newline at end of file diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/.gitignore b/samples/client/petstore/dart/flutter_petstore/swagger/.gitignore new file mode 100644 index 000000000000..7c2804416498 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/.gitignore @@ -0,0 +1,27 @@ +# See https://www.dartlang.org/tools/private-files.html + +# Files and directories created by pub +.buildlog +.packages +.project +.pub/ +build/ +**/packages/ + +# Files created by dart2js +# (Most Dart developers will use pub build to compile Dart, use/modify these +# rules if you intend to use dart2js directly +# Convention is to use extension '.dart.js' for Dart compiled to Javascript to +# differentiate from explicit Javascript files) +*.dart.js +*.part.js +*.js.deps +*.js.map +*.info.json + +# Directory created by dartdoc +doc/api/ + +# Don't commit pubspec lock file +# (Library packages only! Remove pattern if developing an application package) +pubspec.lock diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/.swagger-codegen-ignore b/samples/client/petstore/dart/flutter_petstore/swagger/.swagger-codegen-ignore new file mode 100644 index 000000000000..c5fa491b4c55 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/.swagger-codegen-ignore @@ -0,0 +1,23 @@ +# Swagger Codegen Ignore +# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/.swagger-codegen/VERSION b/samples/client/petstore/dart/flutter_petstore/swagger/.swagger-codegen/VERSION new file mode 100644 index 000000000000..a6254504e401 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/.swagger-codegen/VERSION @@ -0,0 +1 @@ +2.3.1 \ No newline at end of file diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/README.md b/samples/client/petstore/dart/flutter_petstore/swagger/README.md new file mode 100644 index 000000000000..7244e3f3b944 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/README.md @@ -0,0 +1,121 @@ +# swagger +This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + +This Dart package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: + +- API version: 1.0.0 +- Build package: io.swagger.codegen.languages.DartClientCodegen + +## Requirements + +Dart 1.20.0 or later OR Flutter 0.0.20 or later + +## Installation & Usage + +### Github +If this Dart package is published to Github, please include the following in pubspec.yaml +``` +name: swagger +version: 1.0.0 +description: Swagger API client +dependencies: + swagger: + git: https://github.com/GIT_USER_ID/GIT_REPO_ID.git + version: 'any' +``` + +### Local +To use the package in your local drive, please include the following in pubspec.yaml +``` +dependencies: + swagger: + path: /path/to/swagger +``` + +## Tests + +TODO + +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: + +```dart +import 'package:swagger/api.dart'; + +// TODO Configure OAuth2 access token for authorization: petstore_auth +//swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; + +var api_instance = new PetApi(); +var body = new Pet(); // Pet | Pet object that needs to be added to the store + +try { + api_instance.addPet(body); +} catch (e) { + print("Exception when calling PetApi->addPet: $e\n"); +} + +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*PetApi* | [**addPet**](docs//PetApi.md#addpet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**deletePet**](docs//PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**findPetsByStatus**](docs//PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**findPetsByTags**](docs//PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**getPetById**](docs//PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**updatePet**](docs//PetApi.md#updatepet) | **PUT** /pet | Update an existing pet +*PetApi* | [**updatePetWithForm**](docs//PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data +*PetApi* | [**uploadFile**](docs//PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**deleteOrder**](docs//StoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**getInventory**](docs//StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**getOrderById**](docs//StoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**placeOrder**](docs//StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet +*UserApi* | [**createUser**](docs//UserApi.md#createuser) | **POST** /user | Create user +*UserApi* | [**createUsersWithArrayInput**](docs//UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**createUsersWithListInput**](docs//UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**deleteUser**](docs//UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user +*UserApi* | [**getUserByName**](docs//UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name +*UserApi* | [**loginUser**](docs//UserApi.md#loginuser) | **GET** /user/login | Logs user into the system +*UserApi* | [**logoutUser**](docs//UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**updateUser**](docs//UserApi.md#updateuser) | **PUT** /user/{username} | Updated user + + +## Documentation For Models + + - [ApiResponse](docs//ApiResponse.md) + - [Category](docs//Category.md) + - [Order](docs//Order.md) + - [Pet](docs//Pet.md) + - [Tag](docs//Tag.md) + - [User](docs//User.md) + + +## Documentation For Authorization + + +## api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + +## petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - **write:pets**: modify pets in your account + - **read:pets**: read your pets + + +## Author + +apiteam@swagger.io + + diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/docs/ApiResponse.md b/samples/client/petstore/dart/flutter_petstore/swagger/docs/ApiResponse.md new file mode 100644 index 000000000000..7bc0c834d782 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/docs/ApiResponse.md @@ -0,0 +1,17 @@ +# swagger.model.ApiResponse + +## Load the model package +```dart +import 'package:swagger/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **int** | | [optional] [default to null] +**type** | **String** | | [optional] [default to null] +**message** | **String** | | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/docs/Category.md b/samples/client/petstore/dart/flutter_petstore/swagger/docs/Category.md new file mode 100644 index 000000000000..3f5d01c5e1ce --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/docs/Category.md @@ -0,0 +1,16 @@ +# swagger.model.Category + +## Load the model package +```dart +import 'package:swagger/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] [default to null] +**name** | **String** | | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/docs/Order.md b/samples/client/petstore/dart/flutter_petstore/swagger/docs/Order.md new file mode 100644 index 000000000000..c076322a76e3 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/docs/Order.md @@ -0,0 +1,20 @@ +# swagger.model.Order + +## Load the model package +```dart +import 'package:swagger/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] [default to null] +**petId** | **int** | | [optional] [default to null] +**quantity** | **int** | | [optional] [default to null] +**shipDate** | [**DateTime**](DateTime.md) | | [optional] [default to null] +**status** | **String** | Order Status | [optional] [default to null] +**complete** | **bool** | | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/docs/Pet.md b/samples/client/petstore/dart/flutter_petstore/swagger/docs/Pet.md new file mode 100644 index 000000000000..3f8629fbd43e --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/docs/Pet.md @@ -0,0 +1,20 @@ +# swagger.model.Pet + +## Load the model package +```dart +import 'package:swagger/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] [default to null] +**category** | [**Category**](Category.md) | | [optional] [default to null] +**name** | **String** | | [default to null] +**photoUrls** | **List<String>** | | [default to []] +**tags** | [**List<Tag>**](Tag.md) | | [optional] [default to []] +**status** | **String** | pet status in the store | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/docs/PetApi.md b/samples/client/petstore/dart/flutter_petstore/swagger/docs/PetApi.md new file mode 100644 index 000000000000..8832e57f4ab6 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/docs/PetApi.md @@ -0,0 +1,389 @@ +# swagger.api.PetApi + +## Load the API package +```dart +import 'package:swagger/api.dart'; +``` + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store +[**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet +[**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status +[**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags +[**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID +[**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet +[**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image + + +# **addPet** +> addPet(body) + +Add a new pet to the store + + + +### Example +```dart +import 'package:swagger/api.dart'; +// TODO Configure OAuth2 access token for authorization: petstore_auth +//swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; + +var api_instance = new PetApi(); +var body = new Pet(); // Pet | Pet object that needs to be added to the store + +try { + api_instance.addPet(body); +} catch (e) { + print("Exception when calling PetApi->addPet: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **deletePet** +> deletePet(petId, apiKey) + +Deletes a pet + + + +### Example +```dart +import 'package:swagger/api.dart'; +// TODO Configure OAuth2 access token for authorization: petstore_auth +//swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; + +var api_instance = new PetApi(); +var petId = 789; // int | Pet id to delete +var apiKey = apiKey_example; // String | + +try { + api_instance.deletePet(petId, apiKey); +} catch (e) { + print("Exception when calling PetApi->deletePet: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **int**| Pet id to delete | + **apiKey** | **String**| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **findPetsByStatus** +> List findPetsByStatus(status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example +```dart +import 'package:swagger/api.dart'; +// TODO Configure OAuth2 access token for authorization: petstore_auth +//swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; + +var api_instance = new PetApi(); +var status = []; // List | Status values that need to be considered for filter + +try { + var result = api_instance.findPetsByStatus(status); + print(result); +} catch (e) { + print("Exception when calling PetApi->findPetsByStatus: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | + +### Return type + +[**List**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **findPetsByTags** +> List findPetsByTags(tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example +```dart +import 'package:swagger/api.dart'; +// TODO Configure OAuth2 access token for authorization: petstore_auth +//swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; + +var api_instance = new PetApi(); +var tags = []; // List | Tags to filter by + +try { + var result = api_instance.findPetsByTags(tags); + print(result); +} catch (e) { + print("Exception when calling PetApi->findPetsByTags: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**List<String>**](String.md)| Tags to filter by | + +### Return type + +[**List**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **getPetById** +> Pet getPetById(petId) + +Find pet by ID + +Returns a single pet + +### Example +```dart +import 'package:swagger/api.dart'; +// TODO Configure API key authorization: api_key +//swagger.api.Configuration.apiKey{'api_key'} = 'YOUR_API_KEY'; +// uncomment below to setup prefix (e.g. Bearer) for API key, if needed +//swagger.api.Configuration.apiKeyPrefix{'api_key'} = "Bearer"; + +var api_instance = new PetApi(); +var petId = 789; // int | ID of pet to return + +try { + var result = api_instance.getPetById(petId); + print(result); +} catch (e) { + print("Exception when calling PetApi->getPetById: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **int**| ID of pet to return | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **updatePet** +> updatePet(body) + +Update an existing pet + + + +### Example +```dart +import 'package:swagger/api.dart'; +// TODO Configure OAuth2 access token for authorization: petstore_auth +//swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; + +var api_instance = new PetApi(); +var body = new Pet(); // Pet | Pet object that needs to be added to the store + +try { + api_instance.updatePet(body); +} catch (e) { + print("Exception when calling PetApi->updatePet: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **updatePetWithForm** +> updatePetWithForm(petId, name, status) + +Updates a pet in the store with form data + + + +### Example +```dart +import 'package:swagger/api.dart'; +// TODO Configure OAuth2 access token for authorization: petstore_auth +//swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; + +var api_instance = new PetApi(); +var petId = 789; // int | ID of pet that needs to be updated +var name = name_example; // String | Updated name of the pet +var status = status_example; // String | Updated status of the pet + +try { + api_instance.updatePetWithForm(petId, name, status); +} catch (e) { + print("Exception when calling PetApi->updatePetWithForm: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **int**| ID of pet that needs to be updated | + **name** | **String**| Updated name of the pet | [optional] + **status** | **String**| Updated status of the pet | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **uploadFile** +> ApiResponse uploadFile(petId, additionalMetadata, file) + +uploads an image + + + +### Example +```dart +import 'package:swagger/api.dart'; +// TODO Configure OAuth2 access token for authorization: petstore_auth +//swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; + +var api_instance = new PetApi(); +var petId = 789; // int | ID of pet to update +var additionalMetadata = additionalMetadata_example; // String | Additional data to pass to server +var file = /path/to/file.txt; // MultipartFile | file to upload + +try { + var result = api_instance.uploadFile(petId, additionalMetadata, file); + print(result); +} catch (e) { + print("Exception when calling PetApi->uploadFile: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **int**| ID of pet to update | + **additionalMetadata** | **String**| Additional data to pass to server | [optional] + **file** | **MultipartFile**| file to upload | [optional] + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/docs/StoreApi.md b/samples/client/petstore/dart/flutter_petstore/swagger/docs/StoreApi.md new file mode 100644 index 000000000000..b2615f0d4f56 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/docs/StoreApi.md @@ -0,0 +1,188 @@ +# swagger.api.StoreApi + +## Load the API package +```dart +import 'package:swagger/api.dart'; +``` + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status +[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID +[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet + + +# **deleteOrder** +> deleteOrder(orderId) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example +```dart +import 'package:swagger/api.dart'; + +var api_instance = new StoreApi(); +var orderId = orderId_example; // String | ID of the order that needs to be deleted + +try { + api_instance.deleteOrder(orderId); +} catch (e) { + print("Exception when calling StoreApi->deleteOrder: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **String**| ID of the order that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **getInventory** +> Map getInventory() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```dart +import 'package:swagger/api.dart'; +// TODO Configure API key authorization: api_key +//swagger.api.Configuration.apiKey{'api_key'} = 'YOUR_API_KEY'; +// uncomment below to setup prefix (e.g. Bearer) for API key, if needed +//swagger.api.Configuration.apiKeyPrefix{'api_key'} = "Bearer"; + +var api_instance = new StoreApi(); + +try { + var result = api_instance.getInventory(); + print(result); +} catch (e) { + print("Exception when calling StoreApi->getInventory: $e\n"); +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**Map** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **getOrderById** +> Order getOrderById(orderId) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example +```dart +import 'package:swagger/api.dart'; + +var api_instance = new StoreApi(); +var orderId = 789; // int | ID of pet that needs to be fetched + +try { + var result = api_instance.getOrderById(orderId); + print(result); +} catch (e) { + print("Exception when calling StoreApi->getOrderById: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **int**| ID of pet that needs to be fetched | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **placeOrder** +> Order placeOrder(body) + +Place an order for a pet + + + +### Example +```dart +import 'package:swagger/api.dart'; + +var api_instance = new StoreApi(); +var body = new Order(); // Order | order placed for purchasing the pet + +try { + var result = api_instance.placeOrder(body); + print(result); +} catch (e) { + print("Exception when calling StoreApi->placeOrder: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Order**](Order.md)| order placed for purchasing the pet | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/docs/Tag.md b/samples/client/petstore/dart/flutter_petstore/swagger/docs/Tag.md new file mode 100644 index 000000000000..c644f1e826ae --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/docs/Tag.md @@ -0,0 +1,16 @@ +# swagger.model.Tag + +## Load the model package +```dart +import 'package:swagger/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] [default to null] +**name** | **String** | | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/docs/User.md b/samples/client/petstore/dart/flutter_petstore/swagger/docs/User.md new file mode 100644 index 000000000000..d49bb37d96c5 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/docs/User.md @@ -0,0 +1,22 @@ +# swagger.model.User + +## Load the model package +```dart +import 'package:swagger/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] [default to null] +**username** | **String** | | [optional] [default to null] +**firstName** | **String** | | [optional] [default to null] +**lastName** | **String** | | [optional] [default to null] +**email** | **String** | | [optional] [default to null] +**password** | **String** | | [optional] [default to null] +**phone** | **String** | | [optional] [default to null] +**userStatus** | **int** | User Status | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/docs/UserApi.md b/samples/client/petstore/dart/flutter_petstore/swagger/docs/UserApi.md new file mode 100644 index 000000000000..2c14f3508d48 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/docs/UserApi.md @@ -0,0 +1,359 @@ +# swagger.api.UserApi + +## Load the API package +```dart +import 'package:swagger/api.dart'; +``` + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**createUser**](UserApi.md#createUser) | **POST** /user | Create user +[**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array +[**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array +[**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user +[**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name +[**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system +[**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session +[**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user + + +# **createUser** +> createUser(body) + +Create user + +This can only be done by the logged in user. + +### Example +```dart +import 'package:swagger/api.dart'; + +var api_instance = new UserApi(); +var body = new User(); // User | Created user object + +try { + api_instance.createUser(body); +} catch (e) { + print("Exception when calling UserApi->createUser: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**User**](User.md)| Created user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **createUsersWithArrayInput** +> createUsersWithArrayInput(body) + +Creates list of users with given input array + + + +### Example +```dart +import 'package:swagger/api.dart'; + +var api_instance = new UserApi(); +var body = [new List<User>()]; // List | List of user object + +try { + api_instance.createUsersWithArrayInput(body); +} catch (e) { + print("Exception when calling UserApi->createUsersWithArrayInput: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**List<User>**](User.md)| List of user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **createUsersWithListInput** +> createUsersWithListInput(body) + +Creates list of users with given input array + + + +### Example +```dart +import 'package:swagger/api.dart'; + +var api_instance = new UserApi(); +var body = [new List<User>()]; // List | List of user object + +try { + api_instance.createUsersWithListInput(body); +} catch (e) { + print("Exception when calling UserApi->createUsersWithListInput: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**List<User>**](User.md)| List of user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **deleteUser** +> deleteUser(username) + +Delete user + +This can only be done by the logged in user. + +### Example +```dart +import 'package:swagger/api.dart'; + +var api_instance = new UserApi(); +var username = username_example; // String | The name that needs to be deleted + +try { + api_instance.deleteUser(username); +} catch (e) { + print("Exception when calling UserApi->deleteUser: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The name that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **getUserByName** +> User getUserByName(username) + +Get user by user name + + + +### Example +```dart +import 'package:swagger/api.dart'; + +var api_instance = new UserApi(); +var username = username_example; // String | The name that needs to be fetched. Use user1 for testing. + +try { + var result = api_instance.getUserByName(username); + print(result); +} catch (e) { + print("Exception when calling UserApi->getUserByName: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **loginUser** +> String loginUser(username, password) + +Logs user into the system + + + +### Example +```dart +import 'package:swagger/api.dart'; + +var api_instance = new UserApi(); +var username = username_example; // String | The user name for login +var password = password_example; // String | The password for login in clear text + +try { + var result = api_instance.loginUser(username, password); + print(result); +} catch (e) { + print("Exception when calling UserApi->loginUser: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The user name for login | + **password** | **String**| The password for login in clear text | + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **logoutUser** +> logoutUser() + +Logs out current logged in user session + + + +### Example +```dart +import 'package:swagger/api.dart'; + +var api_instance = new UserApi(); + +try { + api_instance.logoutUser(); +} catch (e) { + print("Exception when calling UserApi->logoutUser: $e\n"); +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **updateUser** +> updateUser(username, body) + +Updated user + +This can only be done by the logged in user. + +### Example +```dart +import 'package:swagger/api.dart'; + +var api_instance = new UserApi(); +var username = username_example; // String | name that need to be deleted +var body = new User(); // User | Updated user object + +try { + api_instance.updateUser(username, body); +} catch (e) { + print("Exception when calling UserApi->updateUser: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| name that need to be deleted | + **body** | [**User**](User.md)| Updated user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/git_push.sh b/samples/client/petstore/dart/flutter_petstore/swagger/git_push.sh new file mode 100644 index 000000000000..ae01b182ae9e --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/lib/api.dart b/samples/client/petstore/dart/flutter_petstore/swagger/lib/api.dart new file mode 100644 index 000000000000..6853e7c628f6 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/lib/api.dart @@ -0,0 +1,27 @@ +library swagger.api; + +import 'dart:async'; +import 'dart:convert'; +import 'package:http/http.dart'; + +part 'api_client.dart'; +part 'api_helper.dart'; +part 'api_exception.dart'; +part 'auth/authentication.dart'; +part 'auth/api_key_auth.dart'; +part 'auth/oauth.dart'; +part 'auth/http_basic_auth.dart'; + +part 'api/pet_api.dart'; +part 'api/store_api.dart'; +part 'api/user_api.dart'; + +part 'model/api_response.dart'; +part 'model/category.dart'; +part 'model/order.dart'; +part 'model/pet.dart'; +part 'model/tag.dart'; +part 'model/user.dart'; + + +ApiClient defaultApiClient = new ApiClient(); diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/lib/api/pet_api.dart b/samples/client/petstore/dart/flutter_petstore/swagger/lib/api/pet_api.dart new file mode 100644 index 000000000000..1d7c37382c77 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/lib/api/pet_api.dart @@ -0,0 +1,449 @@ +part of swagger.api; + + + +class PetApi { + final ApiClient apiClient; + + PetApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient; + + /// Add a new pet to the store + /// + /// + Future addPet(Pet body) async { + Object postBody = body; + + // verify required params are set + if(body == null) { + throw new ApiException(400, "Missing required param: body"); + } + + // create path and map variables + String path = "/pet".replaceAll("{format}","json"); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = ["application/json","application/xml"]; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = ["petstore_auth"]; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return ; + } else { + return ; + } + } + /// Deletes a pet + /// + /// + Future deletePet(int petId, { String apiKey }) async { + Object postBody = null; + + // verify required params are set + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); + } + + // create path and map variables + String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + headerParams["api_key"] = apiKey; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = ["petstore_auth"]; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return ; + } else { + return ; + } + } + /// Finds Pets by status + /// + /// Multiple status values can be provided with comma separated strings + Future> findPetsByStatus(List status) async { + Object postBody = null; + + // verify required params are set + if(status == null) { + throw new ApiException(400, "Missing required param: status"); + } + + // create path and map variables + String path = "/pet/findByStatus".replaceAll("{format}","json"); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + queryParams.addAll(_convertParametersForCollectionFormat("csv", "status", status)); + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = ["petstore_auth"]; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return apiClient.deserialize(response.body, 'List') as List ; + } else { + return null; + } + } + /// Finds Pets by tags + /// + /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + Future> findPetsByTags(List tags) async { + Object postBody = null; + + // verify required params are set + if(tags == null) { + throw new ApiException(400, "Missing required param: tags"); + } + + // create path and map variables + String path = "/pet/findByTags".replaceAll("{format}","json"); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + queryParams.addAll(_convertParametersForCollectionFormat("csv", "tags", tags)); + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = ["petstore_auth"]; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return apiClient.deserialize(response.body, 'List') as List ; + } else { + return null; + } + } + /// Find pet by ID + /// + /// Returns a single pet + Future getPetById(int petId) async { + Object postBody = null; + + // verify required params are set + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); + } + + // create path and map variables + String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = ["api_key"]; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return apiClient.deserialize(response.body, 'Pet') as Pet ; + } else { + return null; + } + } + /// Update an existing pet + /// + /// + Future updatePet(Pet body) async { + Object postBody = body; + + // verify required params are set + if(body == null) { + throw new ApiException(400, "Missing required param: body"); + } + + // create path and map variables + String path = "/pet".replaceAll("{format}","json"); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = ["application/json","application/xml"]; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = ["petstore_auth"]; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'PUT', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return ; + } else { + return ; + } + } + /// Updates a pet in the store with form data + /// + /// + Future updatePetWithForm(int petId, { String name, String status }) async { + Object postBody = null; + + // verify required params are set + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); + } + + // create path and map variables + String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = ["application/x-www-form-urlencoded"]; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = ["petstore_auth"]; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if (name != null) { + hasFields = true; + mp.fields['name'] = parameterToString(name); + } + + if (status != null) { + hasFields = true; + mp.fields['status'] = parameterToString(status); + } + + if(hasFields) + postBody = mp; + } + else { + if (name != null) + formParams['name'] = parameterToString(name); +if (status != null) + formParams['status'] = parameterToString(status); + } + + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return ; + } else { + return ; + } + } + /// uploads an image + /// + /// + Future uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async { + Object postBody = null; + + // verify required params are set + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); + } + + // create path and map variables + String path = "/pet/{petId}/uploadImage".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = ["multipart/form-data"]; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = ["petstore_auth"]; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if (additionalMetadata != null) { + hasFields = true; + mp.fields['additionalMetadata'] = parameterToString(additionalMetadata); + } + + if (file != null) { + hasFields = true; + mp.fields['file'] = file.field; + mp.files.add(file); + } + + if(hasFields) + postBody = mp; + } + else { + if (additionalMetadata != null) + formParams['additionalMetadata'] = parameterToString(additionalMetadata); + + } + + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return apiClient.deserialize(response.body, 'ApiResponse') as ApiResponse ; + } else { + return null; + } + } +} diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/lib/api/store_api.dart b/samples/client/petstore/dart/flutter_petstore/swagger/lib/api/store_api.dart new file mode 100644 index 000000000000..9b1c4d6b6e9e --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/lib/api/store_api.dart @@ -0,0 +1,211 @@ +part of swagger.api; + + + +class StoreApi { + final ApiClient apiClient; + + StoreApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient; + + /// Delete purchase order by ID + /// + /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + Future deleteOrder(String orderId) async { + Object postBody = null; + + // verify required params are set + if(orderId == null) { + throw new ApiException(400, "Missing required param: orderId"); + } + + // create path and map variables + String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString()); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = []; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return ; + } else { + return ; + } + } + /// Returns pet inventories by status + /// + /// Returns a map of status codes to quantities + Future> getInventory() async { + Object postBody = null; + + // verify required params are set + + // create path and map variables + String path = "/store/inventory".replaceAll("{format}","json"); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = ["api_key"]; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return apiClient.deserialize(response.body, 'Map') as Map ; + } else { + return null; + } + } + /// Find purchase order by ID + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + Future getOrderById(int orderId) async { + Object postBody = null; + + // verify required params are set + if(orderId == null) { + throw new ApiException(400, "Missing required param: orderId"); + } + + // create path and map variables + String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString()); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = []; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return apiClient.deserialize(response.body, 'Order') as Order ; + } else { + return null; + } + } + /// Place an order for a pet + /// + /// + Future placeOrder(Order body) async { + Object postBody = body; + + // verify required params are set + if(body == null) { + throw new ApiException(400, "Missing required param: body"); + } + + // create path and map variables + String path = "/store/order".replaceAll("{format}","json"); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = []; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return apiClient.deserialize(response.body, 'Order') as Order ; + } else { + return null; + } + } +} diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/lib/api/user_api.dart b/samples/client/petstore/dart/flutter_petstore/swagger/lib/api/user_api.dart new file mode 100644 index 000000000000..3632422fecdf --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/lib/api/user_api.dart @@ -0,0 +1,423 @@ +part of swagger.api; + + + +class UserApi { + final ApiClient apiClient; + + UserApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient; + + /// Create user + /// + /// This can only be done by the logged in user. + Future createUser(User body) async { + Object postBody = body; + + // verify required params are set + if(body == null) { + throw new ApiException(400, "Missing required param: body"); + } + + // create path and map variables + String path = "/user".replaceAll("{format}","json"); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = []; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return ; + } else { + return ; + } + } + /// Creates list of users with given input array + /// + /// + Future createUsersWithArrayInput(List body) async { + Object postBody = body; + + // verify required params are set + if(body == null) { + throw new ApiException(400, "Missing required param: body"); + } + + // create path and map variables + String path = "/user/createWithArray".replaceAll("{format}","json"); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = []; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return ; + } else { + return ; + } + } + /// Creates list of users with given input array + /// + /// + Future createUsersWithListInput(List body) async { + Object postBody = body; + + // verify required params are set + if(body == null) { + throw new ApiException(400, "Missing required param: body"); + } + + // create path and map variables + String path = "/user/createWithList".replaceAll("{format}","json"); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = []; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return ; + } else { + return ; + } + } + /// Delete user + /// + /// This can only be done by the logged in user. + Future deleteUser(String username) async { + Object postBody = null; + + // verify required params are set + if(username == null) { + throw new ApiException(400, "Missing required param: username"); + } + + // create path and map variables + String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString()); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = []; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return ; + } else { + return ; + } + } + /// Get user by user name + /// + /// + Future getUserByName(String username) async { + Object postBody = null; + + // verify required params are set + if(username == null) { + throw new ApiException(400, "Missing required param: username"); + } + + // create path and map variables + String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString()); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = []; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return apiClient.deserialize(response.body, 'User') as User ; + } else { + return null; + } + } + /// Logs user into the system + /// + /// + Future loginUser(String username, String password) async { + Object postBody = null; + + // verify required params are set + if(username == null) { + throw new ApiException(400, "Missing required param: username"); + } + if(password == null) { + throw new ApiException(400, "Missing required param: password"); + } + + // create path and map variables + String path = "/user/login".replaceAll("{format}","json"); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + queryParams.addAll(_convertParametersForCollectionFormat("", "username", username)); + queryParams.addAll(_convertParametersForCollectionFormat("", "password", password)); + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = []; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return apiClient.deserialize(response.body, 'String') as String ; + } else { + return null; + } + } + /// Logs out current logged in user session + /// + /// + Future logoutUser() async { + Object postBody = null; + + // verify required params are set + + // create path and map variables + String path = "/user/logout".replaceAll("{format}","json"); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = []; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return ; + } else { + return ; + } + } + /// Updated user + /// + /// This can only be done by the logged in user. + Future updateUser(String username, User body) async { + Object postBody = body; + + // verify required params are set + if(username == null) { + throw new ApiException(400, "Missing required param: username"); + } + if(body == null) { + throw new ApiException(400, "Missing required param: body"); + } + + // create path and map variables + String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString()); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = []; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'PUT', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return ; + } else { + return ; + } + } +} diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/lib/api_client.dart b/samples/client/petstore/dart/flutter_petstore/swagger/lib/api_client.dart new file mode 100644 index 000000000000..a13a8218c65c --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/lib/api_client.dart @@ -0,0 +1,152 @@ +part of swagger.api; + +class QueryParam { + String name; + String value; + + QueryParam(this.name, this.value); +} + +class ApiClient { + + String basePath; + var client = new Client(); + + Map _defaultHeaderMap = {}; + Map _authentications = {}; + + final _RegList = new RegExp(r'^List<(.*)>$'); + final _RegMap = new RegExp(r'^Map$'); + + ApiClient({this.basePath: "http://petstore.swagger.io/v2"}) { + // Setup authentications (key: authentication name, value: authentication). + _authentications['api_key'] = new ApiKeyAuth("header", "api_key"); + _authentications['petstore_auth'] = new OAuth(); + } + + void addDefaultHeader(String key, String value) { + _defaultHeaderMap[key] = value; + } + + dynamic _deserialize(dynamic value, String targetType) { + try { + switch (targetType) { + case 'String': + return '$value'; + case 'int': + return value is int ? value : int.parse('$value'); + case 'bool': + return value is bool ? value : '$value'.toLowerCase() == 'true'; + case 'double': + return value is double ? value : double.parse('$value'); + case 'ApiResponse': + return new ApiResponse.fromJson(value); + case 'Category': + return new Category.fromJson(value); + case 'Order': + return new Order.fromJson(value); + case 'Pet': + return new Pet.fromJson(value); + case 'Tag': + return new Tag.fromJson(value); + case 'User': + return new User.fromJson(value); + default: + { + Match match; + if (value is List && + (match = _RegList.firstMatch(targetType)) != null) { + var newTargetType = match[1]; + return value.map((v) => _deserialize(v, newTargetType)).toList(); + } else if (value is Map && + (match = _RegMap.firstMatch(targetType)) != null) { + var newTargetType = match[1]; + return new Map.fromIterables(value.keys, + value.values.map((v) => _deserialize(v, newTargetType))); + } + } + } + } catch (e, stack) { + throw new ApiException.withInner(500, 'Exception during deserialization.', e, stack); + } + throw new ApiException(500, 'Could not find a suitable class for deserialization'); + } + + dynamic deserialize(String json, String targetType) { + // Remove all spaces. Necessary for reg expressions as well. + targetType = targetType.replaceAll(' ', ''); + + if (targetType == 'String') return json; + + var decodedJson = JSON.decode(json); + return _deserialize(decodedJson, targetType); + } + + String serialize(Object obj) { + String serialized = ''; + if (obj == null) { + serialized = ''; + } else { + serialized = JSON.encode(obj); + } + return serialized; + } + + // We don't use a Map for queryParams. + // If collectionFormat is 'multi' a key might appear multiple times. + Future invokeAPI(String path, + String method, + Iterable queryParams, + Object body, + Map headerParams, + Map formParams, + String contentType, + List authNames) async { + + _updateParamsForAuth(authNames, queryParams, headerParams); + + var ps = queryParams.where((p) => p.value != null).map((p) => '${p.name}=${p.value}'); + String queryString = ps.isNotEmpty ? + '?' + ps.join('&') : + ''; + + String url = basePath + path + queryString; + + headerParams.addAll(_defaultHeaderMap); + headerParams['Content-Type'] = contentType; + + if(body is MultipartRequest) { + var request = new MultipartRequest(method, Uri.parse(url)); + request.fields.addAll(body.fields); + request.files.addAll(body.files); + request.headers.addAll(body.headers); + request.headers.addAll(headerParams); + var response = await client.send(request); + return Response.fromStream(response); + } else { + var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body); + switch(method) { + case "POST": + return client.post(url, headers: headerParams, body: msgBody); + case "PUT": + return client.put(url, headers: headerParams, body: msgBody); + case "DELETE": + return client.delete(url, headers: headerParams); + case "PATCH": + return client.patch(url, headers: headerParams, body: msgBody); + default: + return client.get(url, headers: headerParams); + } + } + } + + /// Update query and header parameters based on authentication settings. + /// @param authNames The authentications to apply + void _updateParamsForAuth(List authNames, List queryParams, Map headerParams) { + authNames.forEach((authName) { + Authentication auth = _authentications[authName]; + if (auth == null) throw new ArgumentError("Authentication undefined: " + authName); + auth.applyToParams(queryParams, headerParams); + }); + } +} diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/lib/api_exception.dart b/samples/client/petstore/dart/flutter_petstore/swagger/lib/api_exception.dart new file mode 100644 index 000000000000..b861591bec01 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/lib/api_exception.dart @@ -0,0 +1,23 @@ +part of swagger.api; + +class ApiException implements Exception { + int code = 0; + String message = null; + Exception innerException = null; + StackTrace stackTrace = null; + + ApiException(this.code, this.message); + + ApiException.withInner(this.code, this.message, this.innerException, this.stackTrace); + + String toString() { + if (message == null) return "ApiException"; + + if (innerException == null) { + return "ApiException $code: $message"; + } + + return "ApiException $code: $message (Inner exception: ${innerException})\n\n" + + stackTrace.toString(); + } +} diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/lib/api_helper.dart b/samples/client/petstore/dart/flutter_petstore/swagger/lib/api_helper.dart new file mode 100644 index 000000000000..82eb1f3fb36a --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/lib/api_helper.dart @@ -0,0 +1,44 @@ +part of swagger.api; + +const _delimiters = const {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'}; + +// port from Java version +Iterable _convertParametersForCollectionFormat( + String collectionFormat, String name, dynamic value) { + var params = []; + + // preconditions + if (name == null || name.isEmpty || value == null) return params; + + if (value is! List) { + params.add(new QueryParam(name, parameterToString(value))); + return params; + } + + List values = value as List; + + // get the collection format + collectionFormat = (collectionFormat == null || collectionFormat.isEmpty) + ? "csv" + : collectionFormat; // default: csv + + if (collectionFormat == "multi") { + return values.map((v) => new QueryParam(name, parameterToString(v))); + } + + String delimiter = _delimiters[collectionFormat] ?? ","; + + params.add(new QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter))); + return params; +} + +/// Format the given parameter object into string. +String parameterToString(dynamic value) { + if (value == null) { + return ''; + } else if (value is DateTime) { + return value.toUtc().toIso8601String(); + } else { + return value.toString(); + } +} diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/lib/auth/api_key_auth.dart b/samples/client/petstore/dart/flutter_petstore/swagger/lib/auth/api_key_auth.dart new file mode 100644 index 000000000000..aacfa9b2d943 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/lib/auth/api_key_auth.dart @@ -0,0 +1,27 @@ +part of swagger.api; + +class ApiKeyAuth implements Authentication { + + final String location; + final String paramName; + String apiKey; + String apiKeyPrefix; + + ApiKeyAuth(this.location, this.paramName); + + @override + void applyToParams(List queryParams, Map headerParams) { + String value; + if (apiKeyPrefix != null) { + value = '$apiKeyPrefix $apiKey'; + } else { + value = apiKey; + } + + if (location == 'query' && value != null) { + queryParams.add(new QueryParam(paramName, value)); + } else if (location == 'header' && value != null) { + headerParams[paramName] = value; + } + } +} diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/lib/auth/authentication.dart b/samples/client/petstore/dart/flutter_petstore/swagger/lib/auth/authentication.dart new file mode 100644 index 000000000000..3d6b6aadcda0 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/lib/auth/authentication.dart @@ -0,0 +1,7 @@ +part of swagger.api; + +abstract class Authentication { + + /// Apply authentication settings to header and query params. + void applyToParams(List queryParams, Map headerParams); +} \ No newline at end of file diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/lib/auth/http_basic_auth.dart b/samples/client/petstore/dart/flutter_petstore/swagger/lib/auth/http_basic_auth.dart new file mode 100644 index 000000000000..7a118d6cdad8 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/lib/auth/http_basic_auth.dart @@ -0,0 +1,14 @@ +part of swagger.api; + +class HttpBasicAuth implements Authentication { + + String username; + String password; + + @override + void applyToParams(List queryParams, Map headerParams) { + String str = (username == null ? "" : username) + ":" + (password == null ? "" : password); + headerParams["Authorization"] = "Basic " + BASE64.encode(UTF8.encode(str)); + } + +} \ No newline at end of file diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/lib/auth/oauth.dart b/samples/client/petstore/dart/flutter_petstore/swagger/lib/auth/oauth.dart new file mode 100644 index 000000000000..d0872d09a0f6 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/lib/auth/oauth.dart @@ -0,0 +1,9 @@ +part of swagger.api; + +class OAuth implements Authentication { + + @override + void applyToParams(List queryParams, Map headerParams) { + // TODO: support oauth + } +} diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/lib/model/api_response.dart b/samples/client/petstore/dart/flutter_petstore/swagger/lib/model/api_response.dart new file mode 100644 index 000000000000..68ed711118e8 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/lib/model/api_response.dart @@ -0,0 +1,54 @@ +part of swagger.api; + +class ApiResponse { + + int code = null; + + + String type = null; + + + String message = null; + + ApiResponse(); + + @override + String toString() { + return 'ApiResponse[code=$code, type=$type, message=$message, ]'; + } + + ApiResponse.fromJson(Map json) { + if (json == null) return; + code = + json['code']; + type = + json['type']; + message = + json['message']; + } + + Map toJson() { + return { + 'code': code, + 'type': type, + 'message': message + }; + } + + static List listFromJson(List> json) { + var list = new List(); + if (json != null && json.length > 0) { + json.forEach((Map value) => list.add(new ApiResponse.fromJson(value))); + } + return list; + } + + static Map mapFromJson(Map> json) { + var map = new Map(); + if (json != null && json.length > 0) { + json.forEach((String key, Map value) => map[key] = new ApiResponse.fromJson(value)); + } + return map; + } +} + diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/lib/model/category.dart b/samples/client/petstore/dart/flutter_petstore/swagger/lib/model/category.dart new file mode 100644 index 000000000000..29855232387f --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/lib/model/category.dart @@ -0,0 +1,48 @@ +part of swagger.api; + +class Category { + + int id = null; + + + String name = null; + + Category(); + + @override + String toString() { + return 'Category[id=$id, name=$name, ]'; + } + + Category.fromJson(Map json) { + if (json == null) return; + id = + json['id']; + name = + json['name']; + } + + Map toJson() { + return { + 'id': id, + 'name': name + }; + } + + static List listFromJson(List> json) { + var list = new List(); + if (json != null && json.length > 0) { + json.forEach((Map value) => list.add(new Category.fromJson(value))); + } + return list; + } + + static Map mapFromJson(Map> json) { + var map = new Map(); + if (json != null && json.length > 0) { + json.forEach((String key, Map value) => map[key] = new Category.fromJson(value)); + } + return map; + } +} + diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/lib/model/order.dart b/samples/client/petstore/dart/flutter_petstore/swagger/lib/model/order.dart new file mode 100644 index 000000000000..852e9e62738b --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/lib/model/order.dart @@ -0,0 +1,71 @@ +part of swagger.api; + +class Order { + + int id = null; + + + int petId = null; + + + int quantity = null; + + + DateTime shipDate = null; + +/* Order Status */ + String status = null; + //enum statusEnum { placed, approved, delivered, }; + + bool complete = null; + + Order(); + + @override + String toString() { + return 'Order[id=$id, petId=$petId, quantity=$quantity, shipDate=$shipDate, status=$status, complete=$complete, ]'; + } + + Order.fromJson(Map json) { + if (json == null) return; + id = + json['id']; + petId = + json['petId']; + quantity = + json['quantity']; + shipDate = json['shipDate'] == null ? null : DateTime.parse(json['shipDate']); + status = + json['status']; + complete = + json['complete']; + } + + Map toJson() { + return { + 'id': id, + 'petId': petId, + 'quantity': quantity, + 'shipDate': shipDate == null ? '' : shipDate.toUtc().toIso8601String(), + 'status': status, + 'complete': complete + }; + } + + static List listFromJson(List> json) { + var list = new List(); + if (json != null && json.length > 0) { + json.forEach((Map value) => list.add(new Order.fromJson(value))); + } + return list; + } + + static Map mapFromJson(Map> json) { + var map = new Map(); + if (json != null && json.length > 0) { + json.forEach((String key, Map value) => map[key] = new Order.fromJson(value)); + } + return map; + } +} + diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/lib/model/pet.dart b/samples/client/petstore/dart/flutter_petstore/swagger/lib/model/pet.dart new file mode 100644 index 000000000000..85d231848fd4 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/lib/model/pet.dart @@ -0,0 +1,76 @@ +part of swagger.api; + +class Pet { + + int id = null; + + + Category category = null; + + + String name = null; + + + List photoUrls = []; + + + List tags = []; + +/* pet status in the store */ + String status = null; + //enum statusEnum { available, pending, sold, }; + Pet(); + + @override + String toString() { + return 'Pet[id=$id, category=$category, name=$name, photoUrls=$photoUrls, tags=$tags, status=$status, ]'; + } + + Pet.fromJson(Map json) { + if (json == null) return; + id = + json['id']; + category = + + + new Category.fromJson(json['category']) + ; + name = + json['name']; + photoUrls = + json['photoUrls']; + tags = + Tag.listFromJson(json['tags']) + ; + status = + json['status']; + } + + Map toJson() { + return { + 'id': id, + 'category': category, + 'name': name, + 'photoUrls': photoUrls, + 'tags': tags, + 'status': status + }; + } + + static List listFromJson(List> json) { + var list = new List(); + if (json != null && json.length > 0) { + json.forEach((Map value) => list.add(new Pet.fromJson(value))); + } + return list; + } + + static Map mapFromJson(Map> json) { + var map = new Map(); + if (json != null && json.length > 0) { + json.forEach((String key, Map value) => map[key] = new Pet.fromJson(value)); + } + return map; + } +} + diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/lib/model/tag.dart b/samples/client/petstore/dart/flutter_petstore/swagger/lib/model/tag.dart new file mode 100644 index 000000000000..ed2828f90694 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/lib/model/tag.dart @@ -0,0 +1,48 @@ +part of swagger.api; + +class Tag { + + int id = null; + + + String name = null; + + Tag(); + + @override + String toString() { + return 'Tag[id=$id, name=$name, ]'; + } + + Tag.fromJson(Map json) { + if (json == null) return; + id = + json['id']; + name = + json['name']; + } + + Map toJson() { + return { + 'id': id, + 'name': name + }; + } + + static List listFromJson(List> json) { + var list = new List(); + if (json != null && json.length > 0) { + json.forEach((Map value) => list.add(new Tag.fromJson(value))); + } + return list; + } + + static Map mapFromJson(Map> json) { + var map = new Map(); + if (json != null && json.length > 0) { + json.forEach((String key, Map value) => map[key] = new Tag.fromJson(value)); + } + return map; + } +} + diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/lib/model/user.dart b/samples/client/petstore/dart/flutter_petstore/swagger/lib/model/user.dart new file mode 100644 index 000000000000..a4d049b97e7e --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/lib/model/user.dart @@ -0,0 +1,84 @@ +part of swagger.api; + +class User { + + int id = null; + + + String username = null; + + + String firstName = null; + + + String lastName = null; + + + String email = null; + + + String password = null; + + + String phone = null; + +/* User Status */ + int userStatus = null; + + User(); + + @override + String toString() { + return 'User[id=$id, username=$username, firstName=$firstName, lastName=$lastName, email=$email, password=$password, phone=$phone, userStatus=$userStatus, ]'; + } + + User.fromJson(Map json) { + if (json == null) return; + id = + json['id']; + username = + json['username']; + firstName = + json['firstName']; + lastName = + json['lastName']; + email = + json['email']; + password = + json['password']; + phone = + json['phone']; + userStatus = + json['userStatus']; + } + + Map toJson() { + return { + 'id': id, + 'username': username, + 'firstName': firstName, + 'lastName': lastName, + 'email': email, + 'password': password, + 'phone': phone, + 'userStatus': userStatus + }; + } + + static List listFromJson(List> json) { + var list = new List(); + if (json != null && json.length > 0) { + json.forEach((Map value) => list.add(new User.fromJson(value))); + } + return list; + } + + static Map mapFromJson(Map> json) { + var map = new Map(); + if (json != null && json.length > 0) { + json.forEach((String key, Map value) => map[key] = new User.fromJson(value)); + } + return map; + } +} + diff --git a/samples/client/petstore/dart/flutter_petstore/swagger/pubspec.yaml b/samples/client/petstore/dart/flutter_petstore/swagger/pubspec.yaml new file mode 100644 index 000000000000..1f94390bbb77 --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/swagger/pubspec.yaml @@ -0,0 +1,5 @@ +name: swagger +version: 1.0.0 +description: Swagger API client +dependencies: + http: '>=0.11.1 <0.12.0' diff --git a/samples/client/petstore/dart/flutter_petstore/test/widget_test.dart b/samples/client/petstore/dart/flutter_petstore/test/widget_test.dart new file mode 100644 index 000000000000..ae01c7b8e72c --- /dev/null +++ b/samples/client/petstore/dart/flutter_petstore/test/widget_test.dart @@ -0,0 +1,29 @@ +// This is a basic Flutter widget test. +// To perform an interaction with a widget in your test, use the WidgetTester utility that Flutter +// provides. For example, you can send tap and scroll gestures. You can also use WidgetTester to +// find child widgets in the widget tree, read text, and verify that the values of widget properties +// are correct. + +import 'package:flutter/material.dart'; +import 'package:flutter_test/flutter_test.dart'; + +import 'package:flutter_petstore/main.dart'; + +void main() { + testWidgets('Counter increments smoke test', (WidgetTester tester) async { + // Build our app and trigger a frame. + await tester.pumpWidget(new MyApp()); + + // Verify that our counter starts at 0. + expect(find.text('0'), findsOneWidget); + expect(find.text('1'), findsNothing); + + // Tap the '+' icon and trigger a frame. + await tester.tap(find.byIcon(Icons.add)); + await tester.pump(); + + // Verify that our counter has incremented. + expect(find.text('0'), findsNothing); + expect(find.text('1'), findsOneWidget); + }); +} diff --git a/samples/client/petstore/dart/petstore/packages b/samples/client/petstore/dart/petstore/packages deleted file mode 100644 index a16c40501556..000000000000 --- a/samples/client/petstore/dart/petstore/packages +++ /dev/null @@ -1 +0,0 @@ -../packages \ No newline at end of file diff --git a/samples/client/petstore/dart/petstore/pubspec.yaml b/samples/client/petstore/dart/petstore/pubspec.yaml index 26f7d22205db..108bc8a93058 100644 --- a/samples/client/petstore/dart/petstore/pubspec.yaml +++ b/samples/client/petstore/dart/petstore/pubspec.yaml @@ -3,7 +3,7 @@ version: 1.0.0 description: Petstore client using swagger API library dependencies: swagger: - path: ../swagger - + path: ../swagger-browser-client + browser: any dev_dependencies: - guinness: '^0.1.17' \ No newline at end of file + guinness: '^0.1.17' diff --git a/samples/client/petstore/dart/petstore/test/browser/packages b/samples/client/petstore/dart/petstore/test/browser/packages deleted file mode 120000 index 4b727bf68897..000000000000 --- a/samples/client/petstore/dart/petstore/test/browser/packages +++ /dev/null @@ -1 +0,0 @@ -../../packages \ No newline at end of file diff --git a/samples/client/petstore/dart/petstore/test/packages b/samples/client/petstore/dart/petstore/test/packages deleted file mode 100644 index a16c40501556..000000000000 --- a/samples/client/petstore/dart/petstore/test/packages +++ /dev/null @@ -1 +0,0 @@ -../packages \ No newline at end of file diff --git a/samples/client/petstore/dart/swagger-browser-client/.analysis_options b/samples/client/petstore/dart/swagger-browser-client/.analysis_options new file mode 100644 index 000000000000..518eb901a6ff --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/.analysis_options @@ -0,0 +1,2 @@ +analyzer: + strong-mode: true \ No newline at end of file diff --git a/samples/client/petstore/dart/swagger-browser-client/.gitignore b/samples/client/petstore/dart/swagger-browser-client/.gitignore new file mode 100644 index 000000000000..7c2804416498 --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/.gitignore @@ -0,0 +1,27 @@ +# See https://www.dartlang.org/tools/private-files.html + +# Files and directories created by pub +.buildlog +.packages +.project +.pub/ +build/ +**/packages/ + +# Files created by dart2js +# (Most Dart developers will use pub build to compile Dart, use/modify these +# rules if you intend to use dart2js directly +# Convention is to use extension '.dart.js' for Dart compiled to Javascript to +# differentiate from explicit Javascript files) +*.dart.js +*.part.js +*.js.deps +*.js.map +*.info.json + +# Directory created by dartdoc +doc/api/ + +# Don't commit pubspec lock file +# (Library packages only! Remove pattern if developing an application package) +pubspec.lock diff --git a/samples/client/petstore/dart/swagger-browser-client/.swagger-codegen-ignore b/samples/client/petstore/dart/swagger-browser-client/.swagger-codegen-ignore new file mode 100644 index 000000000000..c5fa491b4c55 --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/.swagger-codegen-ignore @@ -0,0 +1,23 @@ +# Swagger Codegen Ignore +# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen + +# Use this file to prevent files from being overwritten by the generator. +# The patterns follow closely to .gitignore or .dockerignore. + +# As an example, the C# client generator defines ApiClient.cs. +# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line: +#ApiClient.cs + +# You can match any string of characters against a directory, file or extension with a single asterisk (*): +#foo/*/qux +# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux + +# You can recursively match patterns against a directory, file or extension with a double asterisk (**): +#foo/**/qux +# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux + +# You can also negate patterns with an exclamation (!). +# For example, you can ignore all files in a docs folder with the file extension .md: +#docs/*.md +# Then explicitly reverse the ignore rule for a single file: +#!docs/README.md diff --git a/samples/client/petstore/dart/swagger-browser-client/.swagger-codegen/VERSION b/samples/client/petstore/dart/swagger-browser-client/.swagger-codegen/VERSION new file mode 100644 index 000000000000..a6254504e401 --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/.swagger-codegen/VERSION @@ -0,0 +1 @@ +2.3.1 \ No newline at end of file diff --git a/samples/client/petstore/dart/swagger-browser-client/README.md b/samples/client/petstore/dart/swagger-browser-client/README.md new file mode 100644 index 000000000000..7244e3f3b944 --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/README.md @@ -0,0 +1,121 @@ +# swagger +This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + +This Dart package is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project: + +- API version: 1.0.0 +- Build package: io.swagger.codegen.languages.DartClientCodegen + +## Requirements + +Dart 1.20.0 or later OR Flutter 0.0.20 or later + +## Installation & Usage + +### Github +If this Dart package is published to Github, please include the following in pubspec.yaml +``` +name: swagger +version: 1.0.0 +description: Swagger API client +dependencies: + swagger: + git: https://github.com/GIT_USER_ID/GIT_REPO_ID.git + version: 'any' +``` + +### Local +To use the package in your local drive, please include the following in pubspec.yaml +``` +dependencies: + swagger: + path: /path/to/swagger +``` + +## Tests + +TODO + +## Getting Started + +Please follow the [installation procedure](#installation--usage) and then run the following: + +```dart +import 'package:swagger/api.dart'; + +// TODO Configure OAuth2 access token for authorization: petstore_auth +//swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; + +var api_instance = new PetApi(); +var body = new Pet(); // Pet | Pet object that needs to be added to the store + +try { + api_instance.addPet(body); +} catch (e) { + print("Exception when calling PetApi->addPet: $e\n"); +} + +``` + +## Documentation for API Endpoints + +All URIs are relative to *http://petstore.swagger.io/v2* + +Class | Method | HTTP request | Description +------------ | ------------- | ------------- | ------------- +*PetApi* | [**addPet**](docs//PetApi.md#addpet) | **POST** /pet | Add a new pet to the store +*PetApi* | [**deletePet**](docs//PetApi.md#deletepet) | **DELETE** /pet/{petId} | Deletes a pet +*PetApi* | [**findPetsByStatus**](docs//PetApi.md#findpetsbystatus) | **GET** /pet/findByStatus | Finds Pets by status +*PetApi* | [**findPetsByTags**](docs//PetApi.md#findpetsbytags) | **GET** /pet/findByTags | Finds Pets by tags +*PetApi* | [**getPetById**](docs//PetApi.md#getpetbyid) | **GET** /pet/{petId} | Find pet by ID +*PetApi* | [**updatePet**](docs//PetApi.md#updatepet) | **PUT** /pet | Update an existing pet +*PetApi* | [**updatePetWithForm**](docs//PetApi.md#updatepetwithform) | **POST** /pet/{petId} | Updates a pet in the store with form data +*PetApi* | [**uploadFile**](docs//PetApi.md#uploadfile) | **POST** /pet/{petId}/uploadImage | uploads an image +*StoreApi* | [**deleteOrder**](docs//StoreApi.md#deleteorder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +*StoreApi* | [**getInventory**](docs//StoreApi.md#getinventory) | **GET** /store/inventory | Returns pet inventories by status +*StoreApi* | [**getOrderById**](docs//StoreApi.md#getorderbyid) | **GET** /store/order/{orderId} | Find purchase order by ID +*StoreApi* | [**placeOrder**](docs//StoreApi.md#placeorder) | **POST** /store/order | Place an order for a pet +*UserApi* | [**createUser**](docs//UserApi.md#createuser) | **POST** /user | Create user +*UserApi* | [**createUsersWithArrayInput**](docs//UserApi.md#createuserswitharrayinput) | **POST** /user/createWithArray | Creates list of users with given input array +*UserApi* | [**createUsersWithListInput**](docs//UserApi.md#createuserswithlistinput) | **POST** /user/createWithList | Creates list of users with given input array +*UserApi* | [**deleteUser**](docs//UserApi.md#deleteuser) | **DELETE** /user/{username} | Delete user +*UserApi* | [**getUserByName**](docs//UserApi.md#getuserbyname) | **GET** /user/{username} | Get user by user name +*UserApi* | [**loginUser**](docs//UserApi.md#loginuser) | **GET** /user/login | Logs user into the system +*UserApi* | [**logoutUser**](docs//UserApi.md#logoutuser) | **GET** /user/logout | Logs out current logged in user session +*UserApi* | [**updateUser**](docs//UserApi.md#updateuser) | **PUT** /user/{username} | Updated user + + +## Documentation For Models + + - [ApiResponse](docs//ApiResponse.md) + - [Category](docs//Category.md) + - [Order](docs//Order.md) + - [Pet](docs//Pet.md) + - [Tag](docs//Tag.md) + - [User](docs//User.md) + + +## Documentation For Authorization + + +## api_key + +- **Type**: API key +- **API key parameter name**: api_key +- **Location**: HTTP header + +## petstore_auth + +- **Type**: OAuth +- **Flow**: implicit +- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog +- **Scopes**: + - **write:pets**: modify pets in your account + - **read:pets**: read your pets + + +## Author + +apiteam@swagger.io + + diff --git a/samples/client/petstore/dart/swagger-browser-client/docs/ApiResponse.md b/samples/client/petstore/dart/swagger-browser-client/docs/ApiResponse.md new file mode 100644 index 000000000000..7bc0c834d782 --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/docs/ApiResponse.md @@ -0,0 +1,17 @@ +# swagger.model.ApiResponse + +## Load the model package +```dart +import 'package:swagger/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **int** | | [optional] [default to null] +**type** | **String** | | [optional] [default to null] +**message** | **String** | | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/dart/swagger-browser-client/docs/Category.md b/samples/client/petstore/dart/swagger-browser-client/docs/Category.md new file mode 100644 index 000000000000..3f5d01c5e1ce --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/docs/Category.md @@ -0,0 +1,16 @@ +# swagger.model.Category + +## Load the model package +```dart +import 'package:swagger/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] [default to null] +**name** | **String** | | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/dart/swagger-browser-client/docs/Order.md b/samples/client/petstore/dart/swagger-browser-client/docs/Order.md new file mode 100644 index 000000000000..c076322a76e3 --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/docs/Order.md @@ -0,0 +1,20 @@ +# swagger.model.Order + +## Load the model package +```dart +import 'package:swagger/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] [default to null] +**petId** | **int** | | [optional] [default to null] +**quantity** | **int** | | [optional] [default to null] +**shipDate** | [**DateTime**](DateTime.md) | | [optional] [default to null] +**status** | **String** | Order Status | [optional] [default to null] +**complete** | **bool** | | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/dart/swagger-browser-client/docs/Pet.md b/samples/client/petstore/dart/swagger-browser-client/docs/Pet.md new file mode 100644 index 000000000000..3f8629fbd43e --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/docs/Pet.md @@ -0,0 +1,20 @@ +# swagger.model.Pet + +## Load the model package +```dart +import 'package:swagger/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] [default to null] +**category** | [**Category**](Category.md) | | [optional] [default to null] +**name** | **String** | | [default to null] +**photoUrls** | **List<String>** | | [default to []] +**tags** | [**List<Tag>**](Tag.md) | | [optional] [default to []] +**status** | **String** | pet status in the store | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/dart/swagger-browser-client/docs/PetApi.md b/samples/client/petstore/dart/swagger-browser-client/docs/PetApi.md new file mode 100644 index 000000000000..8832e57f4ab6 --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/docs/PetApi.md @@ -0,0 +1,389 @@ +# swagger.api.PetApi + +## Load the API package +```dart +import 'package:swagger/api.dart'; +``` + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**addPet**](PetApi.md#addPet) | **POST** /pet | Add a new pet to the store +[**deletePet**](PetApi.md#deletePet) | **DELETE** /pet/{petId} | Deletes a pet +[**findPetsByStatus**](PetApi.md#findPetsByStatus) | **GET** /pet/findByStatus | Finds Pets by status +[**findPetsByTags**](PetApi.md#findPetsByTags) | **GET** /pet/findByTags | Finds Pets by tags +[**getPetById**](PetApi.md#getPetById) | **GET** /pet/{petId} | Find pet by ID +[**updatePet**](PetApi.md#updatePet) | **PUT** /pet | Update an existing pet +[**updatePetWithForm**](PetApi.md#updatePetWithForm) | **POST** /pet/{petId} | Updates a pet in the store with form data +[**uploadFile**](PetApi.md#uploadFile) | **POST** /pet/{petId}/uploadImage | uploads an image + + +# **addPet** +> addPet(body) + +Add a new pet to the store + + + +### Example +```dart +import 'package:swagger/api.dart'; +// TODO Configure OAuth2 access token for authorization: petstore_auth +//swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; + +var api_instance = new PetApi(); +var body = new Pet(); // Pet | Pet object that needs to be added to the store + +try { + api_instance.addPet(body); +} catch (e) { + print("Exception when calling PetApi->addPet: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **deletePet** +> deletePet(petId, apiKey) + +Deletes a pet + + + +### Example +```dart +import 'package:swagger/api.dart'; +// TODO Configure OAuth2 access token for authorization: petstore_auth +//swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; + +var api_instance = new PetApi(); +var petId = 789; // int | Pet id to delete +var apiKey = apiKey_example; // String | + +try { + api_instance.deletePet(petId, apiKey); +} catch (e) { + print("Exception when calling PetApi->deletePet: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **int**| Pet id to delete | + **apiKey** | **String**| | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **findPetsByStatus** +> List findPetsByStatus(status) + +Finds Pets by status + +Multiple status values can be provided with comma separated strings + +### Example +```dart +import 'package:swagger/api.dart'; +// TODO Configure OAuth2 access token for authorization: petstore_auth +//swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; + +var api_instance = new PetApi(); +var status = []; // List | Status values that need to be considered for filter + +try { + var result = api_instance.findPetsByStatus(status); + print(result); +} catch (e) { + print("Exception when calling PetApi->findPetsByStatus: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **status** | [**List<String>**](String.md)| Status values that need to be considered for filter | + +### Return type + +[**List**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **findPetsByTags** +> List findPetsByTags(tags) + +Finds Pets by tags + +Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + +### Example +```dart +import 'package:swagger/api.dart'; +// TODO Configure OAuth2 access token for authorization: petstore_auth +//swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; + +var api_instance = new PetApi(); +var tags = []; // List | Tags to filter by + +try { + var result = api_instance.findPetsByTags(tags); + print(result); +} catch (e) { + print("Exception when calling PetApi->findPetsByTags: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **tags** | [**List<String>**](String.md)| Tags to filter by | + +### Return type + +[**List**](Pet.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **getPetById** +> Pet getPetById(petId) + +Find pet by ID + +Returns a single pet + +### Example +```dart +import 'package:swagger/api.dart'; +// TODO Configure API key authorization: api_key +//swagger.api.Configuration.apiKey{'api_key'} = 'YOUR_API_KEY'; +// uncomment below to setup prefix (e.g. Bearer) for API key, if needed +//swagger.api.Configuration.apiKeyPrefix{'api_key'} = "Bearer"; + +var api_instance = new PetApi(); +var petId = 789; // int | ID of pet to return + +try { + var result = api_instance.getPetById(petId); + print(result); +} catch (e) { + print("Exception when calling PetApi->getPetById: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **int**| ID of pet to return | + +### Return type + +[**Pet**](Pet.md) + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **updatePet** +> updatePet(body) + +Update an existing pet + + + +### Example +```dart +import 'package:swagger/api.dart'; +// TODO Configure OAuth2 access token for authorization: petstore_auth +//swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; + +var api_instance = new PetApi(); +var body = new Pet(); // Pet | Pet object that needs to be added to the store + +try { + api_instance.updatePet(body); +} catch (e) { + print("Exception when calling PetApi->updatePet: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Pet**](Pet.md)| Pet object that needs to be added to the store | + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/json, application/xml + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **updatePetWithForm** +> updatePetWithForm(petId, name, status) + +Updates a pet in the store with form data + + + +### Example +```dart +import 'package:swagger/api.dart'; +// TODO Configure OAuth2 access token for authorization: petstore_auth +//swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; + +var api_instance = new PetApi(); +var petId = 789; // int | ID of pet that needs to be updated +var name = name_example; // String | Updated name of the pet +var status = status_example; // String | Updated status of the pet + +try { + api_instance.updatePetWithForm(petId, name, status); +} catch (e) { + print("Exception when calling PetApi->updatePetWithForm: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **int**| ID of pet that needs to be updated | + **name** | **String**| Updated name of the pet | [optional] + **status** | **String**| Updated status of the pet | [optional] + +### Return type + +void (empty response body) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: application/x-www-form-urlencoded + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **uploadFile** +> ApiResponse uploadFile(petId, additionalMetadata, file) + +uploads an image + + + +### Example +```dart +import 'package:swagger/api.dart'; +// TODO Configure OAuth2 access token for authorization: petstore_auth +//swagger.api.Configuration.accessToken = 'YOUR_ACCESS_TOKEN'; + +var api_instance = new PetApi(); +var petId = 789; // int | ID of pet to update +var additionalMetadata = additionalMetadata_example; // String | Additional data to pass to server +var file = /path/to/file.txt; // MultipartFile | file to upload + +try { + var result = api_instance.uploadFile(petId, additionalMetadata, file); + print(result); +} catch (e) { + print("Exception when calling PetApi->uploadFile: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **petId** | **int**| ID of pet to update | + **additionalMetadata** | **String**| Additional data to pass to server | [optional] + **file** | **MultipartFile**| file to upload | [optional] + +### Return type + +[**ApiResponse**](ApiResponse.md) + +### Authorization + +[petstore_auth](../README.md#petstore_auth) + +### HTTP request headers + + - **Content-Type**: multipart/form-data + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/dart/swagger-browser-client/docs/StoreApi.md b/samples/client/petstore/dart/swagger-browser-client/docs/StoreApi.md new file mode 100644 index 000000000000..b2615f0d4f56 --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/docs/StoreApi.md @@ -0,0 +1,188 @@ +# swagger.api.StoreApi + +## Load the API package +```dart +import 'package:swagger/api.dart'; +``` + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**deleteOrder**](StoreApi.md#deleteOrder) | **DELETE** /store/order/{orderId} | Delete purchase order by ID +[**getInventory**](StoreApi.md#getInventory) | **GET** /store/inventory | Returns pet inventories by status +[**getOrderById**](StoreApi.md#getOrderById) | **GET** /store/order/{orderId} | Find purchase order by ID +[**placeOrder**](StoreApi.md#placeOrder) | **POST** /store/order | Place an order for a pet + + +# **deleteOrder** +> deleteOrder(orderId) + +Delete purchase order by ID + +For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + +### Example +```dart +import 'package:swagger/api.dart'; + +var api_instance = new StoreApi(); +var orderId = orderId_example; // String | ID of the order that needs to be deleted + +try { + api_instance.deleteOrder(orderId); +} catch (e) { + print("Exception when calling StoreApi->deleteOrder: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **String**| ID of the order that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **getInventory** +> Map getInventory() + +Returns pet inventories by status + +Returns a map of status codes to quantities + +### Example +```dart +import 'package:swagger/api.dart'; +// TODO Configure API key authorization: api_key +//swagger.api.Configuration.apiKey{'api_key'} = 'YOUR_API_KEY'; +// uncomment below to setup prefix (e.g. Bearer) for API key, if needed +//swagger.api.Configuration.apiKeyPrefix{'api_key'} = "Bearer"; + +var api_instance = new StoreApi(); + +try { + var result = api_instance.getInventory(); + print(result); +} catch (e) { + print("Exception when calling StoreApi->getInventory: $e\n"); +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +**Map** + +### Authorization + +[api_key](../README.md#api_key) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **getOrderById** +> Order getOrderById(orderId) + +Find purchase order by ID + +For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + +### Example +```dart +import 'package:swagger/api.dart'; + +var api_instance = new StoreApi(); +var orderId = 789; // int | ID of pet that needs to be fetched + +try { + var result = api_instance.getOrderById(orderId); + print(result); +} catch (e) { + print("Exception when calling StoreApi->getOrderById: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **orderId** | **int**| ID of pet that needs to be fetched | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **placeOrder** +> Order placeOrder(body) + +Place an order for a pet + + + +### Example +```dart +import 'package:swagger/api.dart'; + +var api_instance = new StoreApi(); +var body = new Order(); // Order | order placed for purchasing the pet + +try { + var result = api_instance.placeOrder(body); + print(result); +} catch (e) { + print("Exception when calling StoreApi->placeOrder: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**Order**](Order.md)| order placed for purchasing the pet | + +### Return type + +[**Order**](Order.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/dart/swagger-browser-client/docs/Tag.md b/samples/client/petstore/dart/swagger-browser-client/docs/Tag.md new file mode 100644 index 000000000000..c644f1e826ae --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/docs/Tag.md @@ -0,0 +1,16 @@ +# swagger.model.Tag + +## Load the model package +```dart +import 'package:swagger/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] [default to null] +**name** | **String** | | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/dart/swagger-browser-client/docs/User.md b/samples/client/petstore/dart/swagger-browser-client/docs/User.md new file mode 100644 index 000000000000..d49bb37d96c5 --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/docs/User.md @@ -0,0 +1,22 @@ +# swagger.model.User + +## Load the model package +```dart +import 'package:swagger/api.dart'; +``` + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**id** | **int** | | [optional] [default to null] +**username** | **String** | | [optional] [default to null] +**firstName** | **String** | | [optional] [default to null] +**lastName** | **String** | | [optional] [default to null] +**email** | **String** | | [optional] [default to null] +**password** | **String** | | [optional] [default to null] +**phone** | **String** | | [optional] [default to null] +**userStatus** | **int** | User Status | [optional] [default to null] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/samples/client/petstore/dart/swagger-browser-client/docs/UserApi.md b/samples/client/petstore/dart/swagger-browser-client/docs/UserApi.md new file mode 100644 index 000000000000..2c14f3508d48 --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/docs/UserApi.md @@ -0,0 +1,359 @@ +# swagger.api.UserApi + +## Load the API package +```dart +import 'package:swagger/api.dart'; +``` + +All URIs are relative to *http://petstore.swagger.io/v2* + +Method | HTTP request | Description +------------- | ------------- | ------------- +[**createUser**](UserApi.md#createUser) | **POST** /user | Create user +[**createUsersWithArrayInput**](UserApi.md#createUsersWithArrayInput) | **POST** /user/createWithArray | Creates list of users with given input array +[**createUsersWithListInput**](UserApi.md#createUsersWithListInput) | **POST** /user/createWithList | Creates list of users with given input array +[**deleteUser**](UserApi.md#deleteUser) | **DELETE** /user/{username} | Delete user +[**getUserByName**](UserApi.md#getUserByName) | **GET** /user/{username} | Get user by user name +[**loginUser**](UserApi.md#loginUser) | **GET** /user/login | Logs user into the system +[**logoutUser**](UserApi.md#logoutUser) | **GET** /user/logout | Logs out current logged in user session +[**updateUser**](UserApi.md#updateUser) | **PUT** /user/{username} | Updated user + + +# **createUser** +> createUser(body) + +Create user + +This can only be done by the logged in user. + +### Example +```dart +import 'package:swagger/api.dart'; + +var api_instance = new UserApi(); +var body = new User(); // User | Created user object + +try { + api_instance.createUser(body); +} catch (e) { + print("Exception when calling UserApi->createUser: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**User**](User.md)| Created user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **createUsersWithArrayInput** +> createUsersWithArrayInput(body) + +Creates list of users with given input array + + + +### Example +```dart +import 'package:swagger/api.dart'; + +var api_instance = new UserApi(); +var body = [new List<User>()]; // List | List of user object + +try { + api_instance.createUsersWithArrayInput(body); +} catch (e) { + print("Exception when calling UserApi->createUsersWithArrayInput: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**List<User>**](User.md)| List of user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **createUsersWithListInput** +> createUsersWithListInput(body) + +Creates list of users with given input array + + + +### Example +```dart +import 'package:swagger/api.dart'; + +var api_instance = new UserApi(); +var body = [new List<User>()]; // List | List of user object + +try { + api_instance.createUsersWithListInput(body); +} catch (e) { + print("Exception when calling UserApi->createUsersWithListInput: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **body** | [**List<User>**](User.md)| List of user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **deleteUser** +> deleteUser(username) + +Delete user + +This can only be done by the logged in user. + +### Example +```dart +import 'package:swagger/api.dart'; + +var api_instance = new UserApi(); +var username = username_example; // String | The name that needs to be deleted + +try { + api_instance.deleteUser(username); +} catch (e) { + print("Exception when calling UserApi->deleteUser: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The name that needs to be deleted | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **getUserByName** +> User getUserByName(username) + +Get user by user name + + + +### Example +```dart +import 'package:swagger/api.dart'; + +var api_instance = new UserApi(); +var username = username_example; // String | The name that needs to be fetched. Use user1 for testing. + +try { + var result = api_instance.getUserByName(username); + print(result); +} catch (e) { + print("Exception when calling UserApi->getUserByName: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The name that needs to be fetched. Use user1 for testing. | + +### Return type + +[**User**](User.md) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **loginUser** +> String loginUser(username, password) + +Logs user into the system + + + +### Example +```dart +import 'package:swagger/api.dart'; + +var api_instance = new UserApi(); +var username = username_example; // String | The user name for login +var password = password_example; // String | The password for login in clear text + +try { + var result = api_instance.loginUser(username, password); + print(result); +} catch (e) { + print("Exception when calling UserApi->loginUser: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| The user name for login | + **password** | **String**| The password for login in clear text | + +### Return type + +**String** + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **logoutUser** +> logoutUser() + +Logs out current logged in user session + + + +### Example +```dart +import 'package:swagger/api.dart'; + +var api_instance = new UserApi(); + +try { + api_instance.logoutUser(); +} catch (e) { + print("Exception when calling UserApi->logoutUser: $e\n"); +} +``` + +### Parameters +This endpoint does not need any parameter. + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +# **updateUser** +> updateUser(username, body) + +Updated user + +This can only be done by the logged in user. + +### Example +```dart +import 'package:swagger/api.dart'; + +var api_instance = new UserApi(); +var username = username_example; // String | name that need to be deleted +var body = new User(); // User | Updated user object + +try { + api_instance.updateUser(username, body); +} catch (e) { + print("Exception when calling UserApi->updateUser: $e\n"); +} +``` + +### Parameters + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **username** | **String**| name that need to be deleted | + **body** | [**User**](User.md)| Updated user object | + +### Return type + +void (empty response body) + +### Authorization + +No authorization required + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/xml, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/samples/client/petstore/dart/swagger-browser-client/git_push.sh b/samples/client/petstore/dart/swagger-browser-client/git_push.sh new file mode 100644 index 000000000000..ae01b182ae9e --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/git_push.sh @@ -0,0 +1,52 @@ +#!/bin/sh +# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ +# +# Usage example: /bin/sh ./git_push.sh wing328 swagger-petstore-perl "minor update" + +git_user_id=$1 +git_repo_id=$2 +release_note=$3 + +if [ "$git_user_id" = "" ]; then + git_user_id="GIT_USER_ID" + echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" +fi + +if [ "$git_repo_id" = "" ]; then + git_repo_id="GIT_REPO_ID" + echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" +fi + +if [ "$release_note" = "" ]; then + release_note="Minor update" + echo "[INFO] No command line input provided. Set \$release_note to $release_note" +fi + +# Initialize the local directory as a Git repository +git init + +# Adds the files in the local repository and stages them for commit. +git add . + +# Commits the tracked changes and prepares them to be pushed to a remote repository. +git commit -m "$release_note" + +# Sets the new remote +git_remote=`git remote` +if [ "$git_remote" = "" ]; then # git remote not defined + + if [ "$GIT_TOKEN" = "" ]; then + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." + git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + else + git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + fi + +fi + +git pull origin master + +# Pushes (Forces) the changes in the local repository up to the remote repository +echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +git push origin master 2>&1 | grep -v 'To https' + diff --git a/samples/client/petstore/dart/swagger-browser-client/lib/api.dart b/samples/client/petstore/dart/swagger-browser-client/lib/api.dart new file mode 100644 index 000000000000..33dd7f750e20 --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/lib/api.dart @@ -0,0 +1,28 @@ +library swagger.api; + +import 'dart:async'; +import 'dart:convert'; +import 'package:http/browser_client.dart'; +import 'package:http/http.dart'; + +part 'api_client.dart'; +part 'api_helper.dart'; +part 'api_exception.dart'; +part 'auth/authentication.dart'; +part 'auth/api_key_auth.dart'; +part 'auth/oauth.dart'; +part 'auth/http_basic_auth.dart'; + +part 'api/pet_api.dart'; +part 'api/store_api.dart'; +part 'api/user_api.dart'; + +part 'model/api_response.dart'; +part 'model/category.dart'; +part 'model/order.dart'; +part 'model/pet.dart'; +part 'model/tag.dart'; +part 'model/user.dart'; + + +ApiClient defaultApiClient = new ApiClient(); diff --git a/samples/client/petstore/dart/swagger-browser-client/lib/api/pet_api.dart b/samples/client/petstore/dart/swagger-browser-client/lib/api/pet_api.dart new file mode 100644 index 000000000000..1d7c37382c77 --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/lib/api/pet_api.dart @@ -0,0 +1,449 @@ +part of swagger.api; + + + +class PetApi { + final ApiClient apiClient; + + PetApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient; + + /// Add a new pet to the store + /// + /// + Future addPet(Pet body) async { + Object postBody = body; + + // verify required params are set + if(body == null) { + throw new ApiException(400, "Missing required param: body"); + } + + // create path and map variables + String path = "/pet".replaceAll("{format}","json"); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = ["application/json","application/xml"]; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = ["petstore_auth"]; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return ; + } else { + return ; + } + } + /// Deletes a pet + /// + /// + Future deletePet(int petId, { String apiKey }) async { + Object postBody = null; + + // verify required params are set + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); + } + + // create path and map variables + String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + headerParams["api_key"] = apiKey; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = ["petstore_auth"]; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return ; + } else { + return ; + } + } + /// Finds Pets by status + /// + /// Multiple status values can be provided with comma separated strings + Future> findPetsByStatus(List status) async { + Object postBody = null; + + // verify required params are set + if(status == null) { + throw new ApiException(400, "Missing required param: status"); + } + + // create path and map variables + String path = "/pet/findByStatus".replaceAll("{format}","json"); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + queryParams.addAll(_convertParametersForCollectionFormat("csv", "status", status)); + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = ["petstore_auth"]; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return apiClient.deserialize(response.body, 'List') as List ; + } else { + return null; + } + } + /// Finds Pets by tags + /// + /// Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + Future> findPetsByTags(List tags) async { + Object postBody = null; + + // verify required params are set + if(tags == null) { + throw new ApiException(400, "Missing required param: tags"); + } + + // create path and map variables + String path = "/pet/findByTags".replaceAll("{format}","json"); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + queryParams.addAll(_convertParametersForCollectionFormat("csv", "tags", tags)); + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = ["petstore_auth"]; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return apiClient.deserialize(response.body, 'List') as List ; + } else { + return null; + } + } + /// Find pet by ID + /// + /// Returns a single pet + Future getPetById(int petId) async { + Object postBody = null; + + // verify required params are set + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); + } + + // create path and map variables + String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = ["api_key"]; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return apiClient.deserialize(response.body, 'Pet') as Pet ; + } else { + return null; + } + } + /// Update an existing pet + /// + /// + Future updatePet(Pet body) async { + Object postBody = body; + + // verify required params are set + if(body == null) { + throw new ApiException(400, "Missing required param: body"); + } + + // create path and map variables + String path = "/pet".replaceAll("{format}","json"); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = ["application/json","application/xml"]; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = ["petstore_auth"]; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'PUT', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return ; + } else { + return ; + } + } + /// Updates a pet in the store with form data + /// + /// + Future updatePetWithForm(int petId, { String name, String status }) async { + Object postBody = null; + + // verify required params are set + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); + } + + // create path and map variables + String path = "/pet/{petId}".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = ["application/x-www-form-urlencoded"]; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = ["petstore_auth"]; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if (name != null) { + hasFields = true; + mp.fields['name'] = parameterToString(name); + } + + if (status != null) { + hasFields = true; + mp.fields['status'] = parameterToString(status); + } + + if(hasFields) + postBody = mp; + } + else { + if (name != null) + formParams['name'] = parameterToString(name); +if (status != null) + formParams['status'] = parameterToString(status); + } + + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return ; + } else { + return ; + } + } + /// uploads an image + /// + /// + Future uploadFile(int petId, { String additionalMetadata, MultipartFile file }) async { + Object postBody = null; + + // verify required params are set + if(petId == null) { + throw new ApiException(400, "Missing required param: petId"); + } + + // create path and map variables + String path = "/pet/{petId}/uploadImage".replaceAll("{format}","json").replaceAll("{" + "petId" + "}", petId.toString()); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = ["multipart/form-data"]; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = ["petstore_auth"]; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if (additionalMetadata != null) { + hasFields = true; + mp.fields['additionalMetadata'] = parameterToString(additionalMetadata); + } + + if (file != null) { + hasFields = true; + mp.fields['file'] = file.field; + mp.files.add(file); + } + + if(hasFields) + postBody = mp; + } + else { + if (additionalMetadata != null) + formParams['additionalMetadata'] = parameterToString(additionalMetadata); + + } + + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return apiClient.deserialize(response.body, 'ApiResponse') as ApiResponse ; + } else { + return null; + } + } +} diff --git a/samples/client/petstore/dart/swagger-browser-client/lib/api/store_api.dart b/samples/client/petstore/dart/swagger-browser-client/lib/api/store_api.dart new file mode 100644 index 000000000000..9b1c4d6b6e9e --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/lib/api/store_api.dart @@ -0,0 +1,211 @@ +part of swagger.api; + + + +class StoreApi { + final ApiClient apiClient; + + StoreApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient; + + /// Delete purchase order by ID + /// + /// For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + Future deleteOrder(String orderId) async { + Object postBody = null; + + // verify required params are set + if(orderId == null) { + throw new ApiException(400, "Missing required param: orderId"); + } + + // create path and map variables + String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString()); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = []; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return ; + } else { + return ; + } + } + /// Returns pet inventories by status + /// + /// Returns a map of status codes to quantities + Future> getInventory() async { + Object postBody = null; + + // verify required params are set + + // create path and map variables + String path = "/store/inventory".replaceAll("{format}","json"); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = ["api_key"]; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return apiClient.deserialize(response.body, 'Map') as Map ; + } else { + return null; + } + } + /// Find purchase order by ID + /// + /// For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + Future getOrderById(int orderId) async { + Object postBody = null; + + // verify required params are set + if(orderId == null) { + throw new ApiException(400, "Missing required param: orderId"); + } + + // create path and map variables + String path = "/store/order/{orderId}".replaceAll("{format}","json").replaceAll("{" + "orderId" + "}", orderId.toString()); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = []; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return apiClient.deserialize(response.body, 'Order') as Order ; + } else { + return null; + } + } + /// Place an order for a pet + /// + /// + Future placeOrder(Order body) async { + Object postBody = body; + + // verify required params are set + if(body == null) { + throw new ApiException(400, "Missing required param: body"); + } + + // create path and map variables + String path = "/store/order".replaceAll("{format}","json"); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = []; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return apiClient.deserialize(response.body, 'Order') as Order ; + } else { + return null; + } + } +} diff --git a/samples/client/petstore/dart/swagger-browser-client/lib/api/user_api.dart b/samples/client/petstore/dart/swagger-browser-client/lib/api/user_api.dart new file mode 100644 index 000000000000..3632422fecdf --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/lib/api/user_api.dart @@ -0,0 +1,423 @@ +part of swagger.api; + + + +class UserApi { + final ApiClient apiClient; + + UserApi([ApiClient apiClient]) : apiClient = apiClient ?? defaultApiClient; + + /// Create user + /// + /// This can only be done by the logged in user. + Future createUser(User body) async { + Object postBody = body; + + // verify required params are set + if(body == null) { + throw new ApiException(400, "Missing required param: body"); + } + + // create path and map variables + String path = "/user".replaceAll("{format}","json"); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = []; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return ; + } else { + return ; + } + } + /// Creates list of users with given input array + /// + /// + Future createUsersWithArrayInput(List body) async { + Object postBody = body; + + // verify required params are set + if(body == null) { + throw new ApiException(400, "Missing required param: body"); + } + + // create path and map variables + String path = "/user/createWithArray".replaceAll("{format}","json"); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = []; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return ; + } else { + return ; + } + } + /// Creates list of users with given input array + /// + /// + Future createUsersWithListInput(List body) async { + Object postBody = body; + + // verify required params are set + if(body == null) { + throw new ApiException(400, "Missing required param: body"); + } + + // create path and map variables + String path = "/user/createWithList".replaceAll("{format}","json"); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = []; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'POST', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return ; + } else { + return ; + } + } + /// Delete user + /// + /// This can only be done by the logged in user. + Future deleteUser(String username) async { + Object postBody = null; + + // verify required params are set + if(username == null) { + throw new ApiException(400, "Missing required param: username"); + } + + // create path and map variables + String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString()); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = []; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'DELETE', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return ; + } else { + return ; + } + } + /// Get user by user name + /// + /// + Future getUserByName(String username) async { + Object postBody = null; + + // verify required params are set + if(username == null) { + throw new ApiException(400, "Missing required param: username"); + } + + // create path and map variables + String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString()); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = []; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return apiClient.deserialize(response.body, 'User') as User ; + } else { + return null; + } + } + /// Logs user into the system + /// + /// + Future loginUser(String username, String password) async { + Object postBody = null; + + // verify required params are set + if(username == null) { + throw new ApiException(400, "Missing required param: username"); + } + if(password == null) { + throw new ApiException(400, "Missing required param: password"); + } + + // create path and map variables + String path = "/user/login".replaceAll("{format}","json"); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + queryParams.addAll(_convertParametersForCollectionFormat("", "username", username)); + queryParams.addAll(_convertParametersForCollectionFormat("", "password", password)); + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = []; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return apiClient.deserialize(response.body, 'String') as String ; + } else { + return null; + } + } + /// Logs out current logged in user session + /// + /// + Future logoutUser() async { + Object postBody = null; + + // verify required params are set + + // create path and map variables + String path = "/user/logout".replaceAll("{format}","json"); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = []; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'GET', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return ; + } else { + return ; + } + } + /// Updated user + /// + /// This can only be done by the logged in user. + Future updateUser(String username, User body) async { + Object postBody = body; + + // verify required params are set + if(username == null) { + throw new ApiException(400, "Missing required param: username"); + } + if(body == null) { + throw new ApiException(400, "Missing required param: body"); + } + + // create path and map variables + String path = "/user/{username}".replaceAll("{format}","json").replaceAll("{" + "username" + "}", username.toString()); + + // query params + List queryParams = []; + Map headerParams = {}; + Map formParams = {}; + + List contentTypes = []; + + String contentType = contentTypes.length > 0 ? contentTypes[0] : "application/json"; + List authNames = []; + + if(contentType.startsWith("multipart/form-data")) { + bool hasFields = false; + MultipartRequest mp = new MultipartRequest(null, null); + + if(hasFields) + postBody = mp; + } + else { + } + + var response = await apiClient.invokeAPI(path, + 'PUT', + queryParams, + postBody, + headerParams, + formParams, + contentType, + authNames); + + if(response.statusCode >= 400) { + throw new ApiException(response.statusCode, response.body); + } else if(response.body != null) { + return ; + } else { + return ; + } + } +} diff --git a/samples/client/petstore/dart/swagger-browser-client/lib/api_client.dart b/samples/client/petstore/dart/swagger-browser-client/lib/api_client.dart new file mode 100644 index 000000000000..beee9e40f9e4 --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/lib/api_client.dart @@ -0,0 +1,152 @@ +part of swagger.api; + +class QueryParam { + String name; + String value; + + QueryParam(this.name, this.value); +} + +class ApiClient { + + String basePath; + var client = new BrowserClient(); + + Map _defaultHeaderMap = {}; + Map _authentications = {}; + + final _RegList = new RegExp(r'^List<(.*)>$'); + final _RegMap = new RegExp(r'^Map$'); + + ApiClient({this.basePath: "http://petstore.swagger.io/v2"}) { + // Setup authentications (key: authentication name, value: authentication). + _authentications['api_key'] = new ApiKeyAuth("header", "api_key"); + _authentications['petstore_auth'] = new OAuth(); + } + + void addDefaultHeader(String key, String value) { + _defaultHeaderMap[key] = value; + } + + dynamic _deserialize(dynamic value, String targetType) { + try { + switch (targetType) { + case 'String': + return '$value'; + case 'int': + return value is int ? value : int.parse('$value'); + case 'bool': + return value is bool ? value : '$value'.toLowerCase() == 'true'; + case 'double': + return value is double ? value : double.parse('$value'); + case 'ApiResponse': + return new ApiResponse.fromJson(value); + case 'Category': + return new Category.fromJson(value); + case 'Order': + return new Order.fromJson(value); + case 'Pet': + return new Pet.fromJson(value); + case 'Tag': + return new Tag.fromJson(value); + case 'User': + return new User.fromJson(value); + default: + { + Match match; + if (value is List && + (match = _RegList.firstMatch(targetType)) != null) { + var newTargetType = match[1]; + return value.map((v) => _deserialize(v, newTargetType)).toList(); + } else if (value is Map && + (match = _RegMap.firstMatch(targetType)) != null) { + var newTargetType = match[1]; + return new Map.fromIterables(value.keys, + value.values.map((v) => _deserialize(v, newTargetType))); + } + } + } + } catch (e, stack) { + throw new ApiException.withInner(500, 'Exception during deserialization.', e, stack); + } + throw new ApiException(500, 'Could not find a suitable class for deserialization'); + } + + dynamic deserialize(String json, String targetType) { + // Remove all spaces. Necessary for reg expressions as well. + targetType = targetType.replaceAll(' ', ''); + + if (targetType == 'String') return json; + + var decodedJson = JSON.decode(json); + return _deserialize(decodedJson, targetType); + } + + String serialize(Object obj) { + String serialized = ''; + if (obj == null) { + serialized = ''; + } else { + serialized = JSON.encode(obj); + } + return serialized; + } + + // We don't use a Map for queryParams. + // If collectionFormat is 'multi' a key might appear multiple times. + Future invokeAPI(String path, + String method, + Iterable queryParams, + Object body, + Map headerParams, + Map formParams, + String contentType, + List authNames) async { + + _updateParamsForAuth(authNames, queryParams, headerParams); + + var ps = queryParams.where((p) => p.value != null).map((p) => '${p.name}=${p.value}'); + String queryString = ps.isNotEmpty ? + '?' + ps.join('&') : + ''; + + String url = basePath + path + queryString; + + headerParams.addAll(_defaultHeaderMap); + headerParams['Content-Type'] = contentType; + + if(body is MultipartRequest) { + var request = new MultipartRequest(method, Uri.parse(url)); + request.fields.addAll(body.fields); + request.files.addAll(body.files); + request.headers.addAll(body.headers); + request.headers.addAll(headerParams); + var response = await client.send(request); + return Response.fromStream(response); + } else { + var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body); + switch(method) { + case "POST": + return client.post(url, headers: headerParams, body: msgBody); + case "PUT": + return client.put(url, headers: headerParams, body: msgBody); + case "DELETE": + return client.delete(url, headers: headerParams); + case "PATCH": + return client.patch(url, headers: headerParams, body: msgBody); + default: + return client.get(url, headers: headerParams); + } + } + } + + /// Update query and header parameters based on authentication settings. + /// @param authNames The authentications to apply + void _updateParamsForAuth(List authNames, List queryParams, Map headerParams) { + authNames.forEach((authName) { + Authentication auth = _authentications[authName]; + if (auth == null) throw new ArgumentError("Authentication undefined: " + authName); + auth.applyToParams(queryParams, headerParams); + }); + } +} diff --git a/samples/client/petstore/dart/swagger-browser-client/lib/api_exception.dart b/samples/client/petstore/dart/swagger-browser-client/lib/api_exception.dart new file mode 100644 index 000000000000..b861591bec01 --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/lib/api_exception.dart @@ -0,0 +1,23 @@ +part of swagger.api; + +class ApiException implements Exception { + int code = 0; + String message = null; + Exception innerException = null; + StackTrace stackTrace = null; + + ApiException(this.code, this.message); + + ApiException.withInner(this.code, this.message, this.innerException, this.stackTrace); + + String toString() { + if (message == null) return "ApiException"; + + if (innerException == null) { + return "ApiException $code: $message"; + } + + return "ApiException $code: $message (Inner exception: ${innerException})\n\n" + + stackTrace.toString(); + } +} diff --git a/samples/client/petstore/dart/swagger-browser-client/lib/api_helper.dart b/samples/client/petstore/dart/swagger-browser-client/lib/api_helper.dart new file mode 100644 index 000000000000..82eb1f3fb36a --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/lib/api_helper.dart @@ -0,0 +1,44 @@ +part of swagger.api; + +const _delimiters = const {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'}; + +// port from Java version +Iterable _convertParametersForCollectionFormat( + String collectionFormat, String name, dynamic value) { + var params = []; + + // preconditions + if (name == null || name.isEmpty || value == null) return params; + + if (value is! List) { + params.add(new QueryParam(name, parameterToString(value))); + return params; + } + + List values = value as List; + + // get the collection format + collectionFormat = (collectionFormat == null || collectionFormat.isEmpty) + ? "csv" + : collectionFormat; // default: csv + + if (collectionFormat == "multi") { + return values.map((v) => new QueryParam(name, parameterToString(v))); + } + + String delimiter = _delimiters[collectionFormat] ?? ","; + + params.add(new QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter))); + return params; +} + +/// Format the given parameter object into string. +String parameterToString(dynamic value) { + if (value == null) { + return ''; + } else if (value is DateTime) { + return value.toUtc().toIso8601String(); + } else { + return value.toString(); + } +} diff --git a/samples/client/petstore/dart/swagger-browser-client/lib/auth/api_key_auth.dart b/samples/client/petstore/dart/swagger-browser-client/lib/auth/api_key_auth.dart new file mode 100644 index 000000000000..aacfa9b2d943 --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/lib/auth/api_key_auth.dart @@ -0,0 +1,27 @@ +part of swagger.api; + +class ApiKeyAuth implements Authentication { + + final String location; + final String paramName; + String apiKey; + String apiKeyPrefix; + + ApiKeyAuth(this.location, this.paramName); + + @override + void applyToParams(List queryParams, Map headerParams) { + String value; + if (apiKeyPrefix != null) { + value = '$apiKeyPrefix $apiKey'; + } else { + value = apiKey; + } + + if (location == 'query' && value != null) { + queryParams.add(new QueryParam(paramName, value)); + } else if (location == 'header' && value != null) { + headerParams[paramName] = value; + } + } +} diff --git a/samples/client/petstore/dart/swagger-browser-client/lib/auth/authentication.dart b/samples/client/petstore/dart/swagger-browser-client/lib/auth/authentication.dart new file mode 100644 index 000000000000..3d6b6aadcda0 --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/lib/auth/authentication.dart @@ -0,0 +1,7 @@ +part of swagger.api; + +abstract class Authentication { + + /// Apply authentication settings to header and query params. + void applyToParams(List queryParams, Map headerParams); +} \ No newline at end of file diff --git a/samples/client/petstore/dart/swagger-browser-client/lib/auth/http_basic_auth.dart b/samples/client/petstore/dart/swagger-browser-client/lib/auth/http_basic_auth.dart new file mode 100644 index 000000000000..7a118d6cdad8 --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/lib/auth/http_basic_auth.dart @@ -0,0 +1,14 @@ +part of swagger.api; + +class HttpBasicAuth implements Authentication { + + String username; + String password; + + @override + void applyToParams(List queryParams, Map headerParams) { + String str = (username == null ? "" : username) + ":" + (password == null ? "" : password); + headerParams["Authorization"] = "Basic " + BASE64.encode(UTF8.encode(str)); + } + +} \ No newline at end of file diff --git a/samples/client/petstore/dart/swagger-browser-client/lib/auth/oauth.dart b/samples/client/petstore/dart/swagger-browser-client/lib/auth/oauth.dart new file mode 100644 index 000000000000..d0872d09a0f6 --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/lib/auth/oauth.dart @@ -0,0 +1,9 @@ +part of swagger.api; + +class OAuth implements Authentication { + + @override + void applyToParams(List queryParams, Map headerParams) { + // TODO: support oauth + } +} diff --git a/samples/client/petstore/dart/swagger-browser-client/lib/model/api_response.dart b/samples/client/petstore/dart/swagger-browser-client/lib/model/api_response.dart new file mode 100644 index 000000000000..68ed711118e8 --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/lib/model/api_response.dart @@ -0,0 +1,54 @@ +part of swagger.api; + +class ApiResponse { + + int code = null; + + + String type = null; + + + String message = null; + + ApiResponse(); + + @override + String toString() { + return 'ApiResponse[code=$code, type=$type, message=$message, ]'; + } + + ApiResponse.fromJson(Map json) { + if (json == null) return; + code = + json['code']; + type = + json['type']; + message = + json['message']; + } + + Map toJson() { + return { + 'code': code, + 'type': type, + 'message': message + }; + } + + static List listFromJson(List> json) { + var list = new List(); + if (json != null && json.length > 0) { + json.forEach((Map value) => list.add(new ApiResponse.fromJson(value))); + } + return list; + } + + static Map mapFromJson(Map> json) { + var map = new Map(); + if (json != null && json.length > 0) { + json.forEach((String key, Map value) => map[key] = new ApiResponse.fromJson(value)); + } + return map; + } +} + diff --git a/samples/client/petstore/dart/swagger-browser-client/lib/model/category.dart b/samples/client/petstore/dart/swagger-browser-client/lib/model/category.dart new file mode 100644 index 000000000000..29855232387f --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/lib/model/category.dart @@ -0,0 +1,48 @@ +part of swagger.api; + +class Category { + + int id = null; + + + String name = null; + + Category(); + + @override + String toString() { + return 'Category[id=$id, name=$name, ]'; + } + + Category.fromJson(Map json) { + if (json == null) return; + id = + json['id']; + name = + json['name']; + } + + Map toJson() { + return { + 'id': id, + 'name': name + }; + } + + static List listFromJson(List> json) { + var list = new List(); + if (json != null && json.length > 0) { + json.forEach((Map value) => list.add(new Category.fromJson(value))); + } + return list; + } + + static Map mapFromJson(Map> json) { + var map = new Map(); + if (json != null && json.length > 0) { + json.forEach((String key, Map value) => map[key] = new Category.fromJson(value)); + } + return map; + } +} + diff --git a/samples/client/petstore/dart/swagger-browser-client/lib/model/order.dart b/samples/client/petstore/dart/swagger-browser-client/lib/model/order.dart new file mode 100644 index 000000000000..852e9e62738b --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/lib/model/order.dart @@ -0,0 +1,71 @@ +part of swagger.api; + +class Order { + + int id = null; + + + int petId = null; + + + int quantity = null; + + + DateTime shipDate = null; + +/* Order Status */ + String status = null; + //enum statusEnum { placed, approved, delivered, }; + + bool complete = null; + + Order(); + + @override + String toString() { + return 'Order[id=$id, petId=$petId, quantity=$quantity, shipDate=$shipDate, status=$status, complete=$complete, ]'; + } + + Order.fromJson(Map json) { + if (json == null) return; + id = + json['id']; + petId = + json['petId']; + quantity = + json['quantity']; + shipDate = json['shipDate'] == null ? null : DateTime.parse(json['shipDate']); + status = + json['status']; + complete = + json['complete']; + } + + Map toJson() { + return { + 'id': id, + 'petId': petId, + 'quantity': quantity, + 'shipDate': shipDate == null ? '' : shipDate.toUtc().toIso8601String(), + 'status': status, + 'complete': complete + }; + } + + static List listFromJson(List> json) { + var list = new List(); + if (json != null && json.length > 0) { + json.forEach((Map value) => list.add(new Order.fromJson(value))); + } + return list; + } + + static Map mapFromJson(Map> json) { + var map = new Map(); + if (json != null && json.length > 0) { + json.forEach((String key, Map value) => map[key] = new Order.fromJson(value)); + } + return map; + } +} + diff --git a/samples/client/petstore/dart/swagger-browser-client/lib/model/pet.dart b/samples/client/petstore/dart/swagger-browser-client/lib/model/pet.dart new file mode 100644 index 000000000000..85d231848fd4 --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/lib/model/pet.dart @@ -0,0 +1,76 @@ +part of swagger.api; + +class Pet { + + int id = null; + + + Category category = null; + + + String name = null; + + + List photoUrls = []; + + + List tags = []; + +/* pet status in the store */ + String status = null; + //enum statusEnum { available, pending, sold, }; + Pet(); + + @override + String toString() { + return 'Pet[id=$id, category=$category, name=$name, photoUrls=$photoUrls, tags=$tags, status=$status, ]'; + } + + Pet.fromJson(Map json) { + if (json == null) return; + id = + json['id']; + category = + + + new Category.fromJson(json['category']) + ; + name = + json['name']; + photoUrls = + json['photoUrls']; + tags = + Tag.listFromJson(json['tags']) + ; + status = + json['status']; + } + + Map toJson() { + return { + 'id': id, + 'category': category, + 'name': name, + 'photoUrls': photoUrls, + 'tags': tags, + 'status': status + }; + } + + static List listFromJson(List> json) { + var list = new List(); + if (json != null && json.length > 0) { + json.forEach((Map value) => list.add(new Pet.fromJson(value))); + } + return list; + } + + static Map mapFromJson(Map> json) { + var map = new Map(); + if (json != null && json.length > 0) { + json.forEach((String key, Map value) => map[key] = new Pet.fromJson(value)); + } + return map; + } +} + diff --git a/samples/client/petstore/dart/swagger-browser-client/lib/model/tag.dart b/samples/client/petstore/dart/swagger-browser-client/lib/model/tag.dart new file mode 100644 index 000000000000..ed2828f90694 --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/lib/model/tag.dart @@ -0,0 +1,48 @@ +part of swagger.api; + +class Tag { + + int id = null; + + + String name = null; + + Tag(); + + @override + String toString() { + return 'Tag[id=$id, name=$name, ]'; + } + + Tag.fromJson(Map json) { + if (json == null) return; + id = + json['id']; + name = + json['name']; + } + + Map toJson() { + return { + 'id': id, + 'name': name + }; + } + + static List listFromJson(List> json) { + var list = new List(); + if (json != null && json.length > 0) { + json.forEach((Map value) => list.add(new Tag.fromJson(value))); + } + return list; + } + + static Map mapFromJson(Map> json) { + var map = new Map(); + if (json != null && json.length > 0) { + json.forEach((String key, Map value) => map[key] = new Tag.fromJson(value)); + } + return map; + } +} + diff --git a/samples/client/petstore/dart/swagger-browser-client/lib/model/user.dart b/samples/client/petstore/dart/swagger-browser-client/lib/model/user.dart new file mode 100644 index 000000000000..a4d049b97e7e --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/lib/model/user.dart @@ -0,0 +1,84 @@ +part of swagger.api; + +class User { + + int id = null; + + + String username = null; + + + String firstName = null; + + + String lastName = null; + + + String email = null; + + + String password = null; + + + String phone = null; + +/* User Status */ + int userStatus = null; + + User(); + + @override + String toString() { + return 'User[id=$id, username=$username, firstName=$firstName, lastName=$lastName, email=$email, password=$password, phone=$phone, userStatus=$userStatus, ]'; + } + + User.fromJson(Map json) { + if (json == null) return; + id = + json['id']; + username = + json['username']; + firstName = + json['firstName']; + lastName = + json['lastName']; + email = + json['email']; + password = + json['password']; + phone = + json['phone']; + userStatus = + json['userStatus']; + } + + Map toJson() { + return { + 'id': id, + 'username': username, + 'firstName': firstName, + 'lastName': lastName, + 'email': email, + 'password': password, + 'phone': phone, + 'userStatus': userStatus + }; + } + + static List listFromJson(List> json) { + var list = new List(); + if (json != null && json.length > 0) { + json.forEach((Map value) => list.add(new User.fromJson(value))); + } + return list; + } + + static Map mapFromJson(Map> json) { + var map = new Map(); + if (json != null && json.length > 0) { + json.forEach((String key, Map value) => map[key] = new User.fromJson(value)); + } + return map; + } +} + diff --git a/samples/client/petstore/dart/swagger-browser-client/pubspec.yaml b/samples/client/petstore/dart/swagger-browser-client/pubspec.yaml new file mode 100644 index 000000000000..1f94390bbb77 --- /dev/null +++ b/samples/client/petstore/dart/swagger-browser-client/pubspec.yaml @@ -0,0 +1,5 @@ +name: swagger +version: 1.0.0 +description: Swagger API client +dependencies: + http: '>=0.11.1 <0.12.0' diff --git a/samples/client/petstore/dart/swagger/.swagger-codegen/VERSION b/samples/client/petstore/dart/swagger/.swagger-codegen/VERSION index f9f7450d1359..a6254504e401 100644 --- a/samples/client/petstore/dart/swagger/.swagger-codegen/VERSION +++ b/samples/client/petstore/dart/swagger/.swagger-codegen/VERSION @@ -1 +1 @@ -2.3.0-SNAPSHOT \ No newline at end of file +2.3.1 \ No newline at end of file diff --git a/samples/client/petstore/dart/swagger/README.md b/samples/client/petstore/dart/swagger/README.md index 4ac75e49d78e..7244e3f3b944 100644 --- a/samples/client/petstore/dart/swagger/README.md +++ b/samples/client/petstore/dart/swagger/README.md @@ -8,7 +8,7 @@ This Dart package is automatically generated by the [Swagger Codegen](https://gi ## Requirements -Dart 1.20.0 and later +Dart 1.20.0 or later OR Flutter 0.0.20 or later ## Installation & Usage diff --git a/samples/client/petstore/dart/swagger/git_push.sh b/samples/client/petstore/dart/swagger/git_push.sh index ed374619b139..ae01b182ae9e 100644 --- a/samples/client/petstore/dart/swagger/git_push.sh +++ b/samples/client/petstore/dart/swagger/git_push.sh @@ -36,7 +36,7 @@ git_remote=`git remote` if [ "$git_remote" = "" ]; then # git remote not defined if [ "$GIT_TOKEN" = "" ]; then - echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git crediential in your environment." + echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git else git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git diff --git a/samples/client/petstore/dart/swagger/lib/api.dart b/samples/client/petstore/dart/swagger/lib/api.dart index 79a83321fa57..6853e7c628f6 100644 --- a/samples/client/petstore/dart/swagger/lib/api.dart +++ b/samples/client/petstore/dart/swagger/lib/api.dart @@ -2,11 +2,7 @@ library swagger.api; import 'dart:async'; import 'dart:convert'; -import 'package:http/browser_client.dart'; import 'package:http/http.dart'; -import 'package:dartson/dartson.dart'; -import 'package:dartson/transformers/date_time.dart'; -import 'package:dartson/type_transformer.dart'; part 'api_client.dart'; part 'api_helper.dart'; diff --git a/samples/client/petstore/dart/swagger/lib/api/pet_api.dart b/samples/client/petstore/dart/swagger/lib/api/pet_api.dart index 961387012ccc..1d7c37382c77 100644 --- a/samples/client/petstore/dart/swagger/lib/api/pet_api.dart +++ b/samples/client/petstore/dart/swagger/lib/api/pet_api.dart @@ -346,12 +346,12 @@ class PetApi { if (name != null) { hasFields = true; - mp.fields['name'] = apiClient.parameterToString(name); + mp.fields['name'] = parameterToString(name); } if (status != null) { hasFields = true; - mp.fields['status'] = apiClient.parameterToString(status); + mp.fields['status'] = parameterToString(status); } if(hasFields) @@ -359,9 +359,9 @@ class PetApi { } else { if (name != null) - formParams['name'] = apiClient.parameterToString(name); + formParams['name'] = parameterToString(name); if (status != null) - formParams['status'] = apiClient.parameterToString(status); + formParams['status'] = parameterToString(status); } var response = await apiClient.invokeAPI(path, @@ -411,7 +411,7 @@ if (status != null) if (additionalMetadata != null) { hasFields = true; - mp.fields['additionalMetadata'] = apiClient.parameterToString(additionalMetadata); + mp.fields['additionalMetadata'] = parameterToString(additionalMetadata); } if (file != null) { @@ -425,7 +425,7 @@ if (status != null) } else { if (additionalMetadata != null) - formParams['additionalMetadata'] = apiClient.parameterToString(additionalMetadata); + formParams['additionalMetadata'] = parameterToString(additionalMetadata); } diff --git a/samples/client/petstore/dart/swagger/lib/api_client.dart b/samples/client/petstore/dart/swagger/lib/api_client.dart index 6c292b973f0b..a13a8218c65c 100644 --- a/samples/client/petstore/dart/swagger/lib/api_client.dart +++ b/samples/client/petstore/dart/swagger/lib/api_client.dart @@ -10,14 +10,11 @@ class QueryParam { class ApiClient { String basePath; - var client = new BrowserClient(); + var client = new Client(); Map _defaultHeaderMap = {}; Map _authentications = {}; - final dson = new Dartson.JSON() - ..addTransformer(new DateTimeParser(), DateTime); - final _RegList = new RegExp(r'^List<(.*)>$'); final _RegMap = new RegExp(r'^Map$'); @@ -43,17 +40,17 @@ class ApiClient { case 'double': return value is double ? value : double.parse('$value'); case 'ApiResponse': - return dson.map(value, new ApiResponse()); + return new ApiResponse.fromJson(value); case 'Category': - return dson.map(value, new Category()); + return new Category.fromJson(value); case 'Order': - return dson.map(value, new Order()); + return new Order.fromJson(value); case 'Pet': - return dson.map(value, new Pet()); + return new Pet.fromJson(value); case 'Tag': - return dson.map(value, new Tag()); + return new Tag.fromJson(value); case 'User': - return dson.map(value, new User()); + return new User.fromJson(value); default: { Match match; @@ -89,10 +86,8 @@ class ApiClient { String serialized = ''; if (obj == null) { serialized = ''; - } else if (obj is String) { - serialized = obj; } else { - serialized = dson.encode(obj); + serialized = JSON.encode(obj); } return serialized; } diff --git a/samples/client/petstore/dart/swagger/lib/api_helper.dart b/samples/client/petstore/dart/swagger/lib/api_helper.dart index 6da2530b1b25..82eb1f3fb36a 100644 --- a/samples/client/petstore/dart/swagger/lib/api_helper.dart +++ b/samples/client/petstore/dart/swagger/lib/api_helper.dart @@ -11,7 +11,7 @@ Iterable _convertParametersForCollectionFormat( if (name == null || name.isEmpty || value == null) return params; if (value is! List) { - params.add(new QueryParam(name, _parameterToString(value))); + params.add(new QueryParam(name, parameterToString(value))); return params; } @@ -23,17 +23,17 @@ Iterable _convertParametersForCollectionFormat( : collectionFormat; // default: csv if (collectionFormat == "multi") { - return values.map((v) => new QueryParam(name, _parameterToString(v))); + return values.map((v) => new QueryParam(name, parameterToString(v))); } String delimiter = _delimiters[collectionFormat] ?? ","; - params.add(new QueryParam(name, values.map((v)=>_parameterToString(v)).join(delimiter))); + params.add(new QueryParam(name, values.map((v) => parameterToString(v)).join(delimiter))); return params; } /// Format the given parameter object into string. -String _parameterToString(dynamic value) { +String parameterToString(dynamic value) { if (value == null) { return ''; } else if (value is DateTime) { diff --git a/samples/client/petstore/dart/swagger/lib/auth/api_key_auth.dart b/samples/client/petstore/dart/swagger/lib/auth/api_key_auth.dart index d46fa15e9b84..aacfa9b2d943 100644 --- a/samples/client/petstore/dart/swagger/lib/auth/api_key_auth.dart +++ b/samples/client/petstore/dart/swagger/lib/auth/api_key_auth.dart @@ -24,4 +24,4 @@ class ApiKeyAuth implements Authentication { headerParams[paramName] = value; } } -} \ No newline at end of file +} diff --git a/samples/client/petstore/dart/swagger/lib/auth/oauth.dart b/samples/client/petstore/dart/swagger/lib/auth/oauth.dart index 405c5119a45e..d0872d09a0f6 100644 --- a/samples/client/petstore/dart/swagger/lib/auth/oauth.dart +++ b/samples/client/petstore/dart/swagger/lib/auth/oauth.dart @@ -6,4 +6,4 @@ class OAuth implements Authentication { void applyToParams(List queryParams, Map headerParams) { // TODO: support oauth } -} \ No newline at end of file +} diff --git a/samples/client/petstore/dart/swagger/lib/model/api_response.dart b/samples/client/petstore/dart/swagger/lib/model/api_response.dart index 7cb79fb8aef5..68ed711118e8 100644 --- a/samples/client/petstore/dart/swagger/lib/model/api_response.dart +++ b/samples/client/petstore/dart/swagger/lib/model/api_response.dart @@ -1,24 +1,54 @@ part of swagger.api; -@Entity() class ApiResponse { - @Property(name: 'code') int code = null; - @Property(name: 'type') String type = null; - @Property(name: 'message') String message = null; ApiResponse(); @override - String toString() { + String toString() { return 'ApiResponse[code=$code, type=$type, message=$message, ]'; } + + ApiResponse.fromJson(Map json) { + if (json == null) return; + code = + json['code']; + type = + json['type']; + message = + json['message']; + } + + Map toJson() { + return { + 'code': code, + 'type': type, + 'message': message + }; + } + + static List listFromJson(List> json) { + var list = new List(); + if (json != null && json.length > 0) { + json.forEach((Map value) => list.add(new ApiResponse.fromJson(value))); + } + return list; + } + + static Map mapFromJson(Map> json) { + var map = new Map(); + if (json != null && json.length > 0) { + json.forEach((String key, Map value) => map[key] = new ApiResponse.fromJson(value)); + } + return map; + } } diff --git a/samples/client/petstore/dart/swagger/lib/model/category.dart b/samples/client/petstore/dart/swagger/lib/model/category.dart index 26b902731632..29855232387f 100644 --- a/samples/client/petstore/dart/swagger/lib/model/category.dart +++ b/samples/client/petstore/dart/swagger/lib/model/category.dart @@ -1,20 +1,48 @@ part of swagger.api; -@Entity() class Category { - @Property(name: 'id') int id = null; - @Property(name: 'name') String name = null; Category(); @override - String toString() { + String toString() { return 'Category[id=$id, name=$name, ]'; } + + Category.fromJson(Map json) { + if (json == null) return; + id = + json['id']; + name = + json['name']; + } + + Map toJson() { + return { + 'id': id, + 'name': name + }; + } + + static List listFromJson(List> json) { + var list = new List(); + if (json != null && json.length > 0) { + json.forEach((Map value) => list.add(new Category.fromJson(value))); + } + return list; + } + + static Map mapFromJson(Map> json) { + var map = new Map(); + if (json != null && json.length > 0) { + json.forEach((String key, Map value) => map[key] = new Category.fromJson(value)); + } + return map; + } } diff --git a/samples/client/petstore/dart/swagger/lib/model/order.dart b/samples/client/petstore/dart/swagger/lib/model/order.dart index 84e4a972d57b..852e9e62738b 100644 --- a/samples/client/petstore/dart/swagger/lib/model/order.dart +++ b/samples/client/petstore/dart/swagger/lib/model/order.dart @@ -1,36 +1,71 @@ part of swagger.api; -@Entity() class Order { - @Property(name: 'id') int id = null; - @Property(name: 'petId') int petId = null; - @Property(name: 'quantity') int quantity = null; - @Property(name: 'shipDate') DateTime shipDate = null; /* Order Status */ - @Property(name: 'status') String status = null; //enum statusEnum { placed, approved, delivered, }; - @Property(name: 'complete') bool complete = null; Order(); @override - String toString() { + String toString() { return 'Order[id=$id, petId=$petId, quantity=$quantity, shipDate=$shipDate, status=$status, complete=$complete, ]'; } + + Order.fromJson(Map json) { + if (json == null) return; + id = + json['id']; + petId = + json['petId']; + quantity = + json['quantity']; + shipDate = json['shipDate'] == null ? null : DateTime.parse(json['shipDate']); + status = + json['status']; + complete = + json['complete']; + } + + Map toJson() { + return { + 'id': id, + 'petId': petId, + 'quantity': quantity, + 'shipDate': shipDate == null ? '' : shipDate.toUtc().toIso8601String(), + 'status': status, + 'complete': complete + }; + } + + static List listFromJson(List> json) { + var list = new List(); + if (json != null && json.length > 0) { + json.forEach((Map value) => list.add(new Order.fromJson(value))); + } + return list; + } + + static Map mapFromJson(Map> json) { + var map = new Map(); + if (json != null && json.length > 0) { + json.forEach((String key, Map value) => map[key] = new Order.fromJson(value)); + } + return map; + } } diff --git a/samples/client/petstore/dart/swagger/lib/model/pet.dart b/samples/client/petstore/dart/swagger/lib/model/pet.dart index f2b4108b892c..85d231848fd4 100644 --- a/samples/client/petstore/dart/swagger/lib/model/pet.dart +++ b/samples/client/petstore/dart/swagger/lib/model/pet.dart @@ -1,36 +1,76 @@ part of swagger.api; -@Entity() class Pet { - @Property(name: 'id') int id = null; - @Property(name: 'category') Category category = null; - @Property(name: 'name') String name = null; - @Property(name: 'photoUrls') List photoUrls = []; - @Property(name: 'tags') List tags = []; /* pet status in the store */ - @Property(name: 'status') String status = null; //enum statusEnum { available, pending, sold, }; Pet(); @override - String toString() { + String toString() { return 'Pet[id=$id, category=$category, name=$name, photoUrls=$photoUrls, tags=$tags, status=$status, ]'; } + + Pet.fromJson(Map json) { + if (json == null) return; + id = + json['id']; + category = + + + new Category.fromJson(json['category']) + ; + name = + json['name']; + photoUrls = + json['photoUrls']; + tags = + Tag.listFromJson(json['tags']) + ; + status = + json['status']; + } + + Map toJson() { + return { + 'id': id, + 'category': category, + 'name': name, + 'photoUrls': photoUrls, + 'tags': tags, + 'status': status + }; + } + + static List listFromJson(List> json) { + var list = new List(); + if (json != null && json.length > 0) { + json.forEach((Map value) => list.add(new Pet.fromJson(value))); + } + return list; + } + + static Map mapFromJson(Map> json) { + var map = new Map(); + if (json != null && json.length > 0) { + json.forEach((String key, Map value) => map[key] = new Pet.fromJson(value)); + } + return map; + } } diff --git a/samples/client/petstore/dart/swagger/lib/model/tag.dart b/samples/client/petstore/dart/swagger/lib/model/tag.dart index 45f3668b3e7f..ed2828f90694 100644 --- a/samples/client/petstore/dart/swagger/lib/model/tag.dart +++ b/samples/client/petstore/dart/swagger/lib/model/tag.dart @@ -1,20 +1,48 @@ part of swagger.api; -@Entity() class Tag { - @Property(name: 'id') int id = null; - @Property(name: 'name') String name = null; Tag(); @override - String toString() { + String toString() { return 'Tag[id=$id, name=$name, ]'; } + + Tag.fromJson(Map json) { + if (json == null) return; + id = + json['id']; + name = + json['name']; + } + + Map toJson() { + return { + 'id': id, + 'name': name + }; + } + + static List listFromJson(List> json) { + var list = new List(); + if (json != null && json.length > 0) { + json.forEach((Map value) => list.add(new Tag.fromJson(value))); + } + return list; + } + + static Map mapFromJson(Map> json) { + var map = new Map(); + if (json != null && json.length > 0) { + json.forEach((String key, Map value) => map[key] = new Tag.fromJson(value)); + } + return map; + } } diff --git a/samples/client/petstore/dart/swagger/lib/model/user.dart b/samples/client/petstore/dart/swagger/lib/model/user.dart index 77c021144288..a4d049b97e7e 100644 --- a/samples/client/petstore/dart/swagger/lib/model/user.dart +++ b/samples/client/petstore/dart/swagger/lib/model/user.dart @@ -1,44 +1,84 @@ part of swagger.api; -@Entity() class User { - @Property(name: 'id') int id = null; - @Property(name: 'username') String username = null; - @Property(name: 'firstName') String firstName = null; - @Property(name: 'lastName') String lastName = null; - @Property(name: 'email') String email = null; - @Property(name: 'password') String password = null; - @Property(name: 'phone') String phone = null; /* User Status */ - @Property(name: 'userStatus') int userStatus = null; User(); @override - String toString() { + String toString() { return 'User[id=$id, username=$username, firstName=$firstName, lastName=$lastName, email=$email, password=$password, phone=$phone, userStatus=$userStatus, ]'; } + + User.fromJson(Map json) { + if (json == null) return; + id = + json['id']; + username = + json['username']; + firstName = + json['firstName']; + lastName = + json['lastName']; + email = + json['email']; + password = + json['password']; + phone = + json['phone']; + userStatus = + json['userStatus']; + } + + Map toJson() { + return { + 'id': id, + 'username': username, + 'firstName': firstName, + 'lastName': lastName, + 'email': email, + 'password': password, + 'phone': phone, + 'userStatus': userStatus + }; + } + + static List listFromJson(List> json) { + var list = new List(); + if (json != null && json.length > 0) { + json.forEach((Map value) => list.add(new User.fromJson(value))); + } + return list; + } + + static Map mapFromJson(Map> json) { + var map = new Map(); + if (json != null && json.length > 0) { + json.forEach((String key, Map value) => map[key] = new User.fromJson(value)); + } + return map; + } } diff --git a/samples/client/petstore/dart/swagger/pubspec.yaml b/samples/client/petstore/dart/swagger/pubspec.yaml index 50938a1c0951..1f94390bbb77 100644 --- a/samples/client/petstore/dart/swagger/pubspec.yaml +++ b/samples/client/petstore/dart/swagger/pubspec.yaml @@ -3,11 +3,3 @@ version: 1.0.0 description: Swagger API client dependencies: http: '>=0.11.1 <0.12.0' - dartson: "^0.2.4" - -dev_dependencies: - guinness: '^0.1.17' - browser: any - -transformers: - - dartson