update dart, ruby petstore samples

This commit is contained in:
wing328 2018-02-22 17:53:51 +08:00
parent 91bd7ac3b9
commit a59c325cb7
29 changed files with 100 additions and 42 deletions

View File

@ -59,7 +59,7 @@ try {
## Documentation for API Endpoints
All URIs are relative to *http://petstore.swagger.io/v2*
All URIs are relative to *http://localhost/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------

View File

@ -5,7 +5,7 @@
import 'package:swagger/api.dart';
```
All URIs are relative to *http://petstore.swagger.io/v2*
All URIs are relative to *http://localhost/v2*
Method | HTTP request | Description
------------- | ------------- | -------------

View File

@ -5,7 +5,7 @@
import 'package:swagger/api.dart';
```
All URIs are relative to *http://petstore.swagger.io/v2*
All URIs are relative to *http://localhost/v2*
Method | HTTP request | Description
------------- | ------------- | -------------

View File

@ -5,7 +5,7 @@
import 'package:swagger/api.dart';
```
All URIs are relative to *http://petstore.swagger.io/v2*
All URIs are relative to *http://localhost/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
@ -213,7 +213,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
### Return type

View File

@ -18,7 +18,7 @@ class ApiClient {
final _RegList = new RegExp(r'^List<(.*)>$');
final _RegMap = new RegExp(r'^Map<String,(.*)>$');
ApiClient({this.basePath: "http://petstore.swagger.io/v2"}) {
ApiClient({this.basePath: "http://localhost/v2"}) {
// Setup authentications (key: authentication name, value: authentication).
_authentications['api_key'] = new ApiKeyAuth("header", "api_key");
_authentications['petstore_auth'] = new OAuth();
@ -149,4 +149,12 @@ class ApiClient {
auth.applyToParams(queryParams, headerParams);
});
}
void setAccessToken(String accessToken) {
_authentications.forEach((key, auth) {
if (auth is OAuth) {
auth.setAccessToken(accessToken);
}
});
}
}

View File

@ -1,9 +1,19 @@
part of swagger.api;
class OAuth implements Authentication {
String accessToken;
OAuth({this.accessToken}) {
}
@override
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
// TODO: support oauth
if (accessToken != null) {
headerParams["Authorization"] = "Bearer " + accessToken;
}
}
void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
}

View File

@ -59,7 +59,7 @@ try {
## Documentation for API Endpoints
All URIs are relative to *http://petstore.swagger.io/v2*
All URIs are relative to *http://localhost/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------

View File

@ -5,7 +5,7 @@
import 'package:swagger/api.dart';
```
All URIs are relative to *http://petstore.swagger.io/v2*
All URIs are relative to *http://localhost/v2*
Method | HTTP request | Description
------------- | ------------- | -------------

View File

@ -5,7 +5,7 @@
import 'package:swagger/api.dart';
```
All URIs are relative to *http://petstore.swagger.io/v2*
All URIs are relative to *http://localhost/v2*
Method | HTTP request | Description
------------- | ------------- | -------------

View File

@ -5,7 +5,7 @@
import 'package:swagger/api.dart';
```
All URIs are relative to *http://petstore.swagger.io/v2*
All URIs are relative to *http://localhost/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
@ -213,7 +213,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
### Return type

View File

@ -18,7 +18,7 @@ class ApiClient {
final _RegList = new RegExp(r'^List<(.*)>$');
final _RegMap = new RegExp(r'^Map<String,(.*)>$');
ApiClient({this.basePath: "http://petstore.swagger.io/v2"}) {
ApiClient({this.basePath: "http://localhost/v2"}) {
// Setup authentications (key: authentication name, value: authentication).
_authentications['api_key'] = new ApiKeyAuth("header", "api_key");
_authentications['petstore_auth'] = new OAuth();
@ -149,4 +149,12 @@ class ApiClient {
auth.applyToParams(queryParams, headerParams);
});
}
void setAccessToken(String accessToken) {
_authentications.forEach((key, auth) {
if (auth is OAuth) {
auth.setAccessToken(accessToken);
}
});
}
}

View File

@ -1,9 +1,19 @@
part of swagger.api;
class OAuth implements Authentication {
String accessToken;
OAuth({this.accessToken}) {
}
@override
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
// TODO: support oauth
if (accessToken != null) {
headerParams["Authorization"] = "Bearer " + accessToken;
}
}
void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
}

View File

@ -1 +1 @@
2.3.1
2.4.0-SNAPSHOT

View File

@ -59,7 +59,7 @@ try {
## Documentation for API Endpoints
All URIs are relative to *http://petstore.swagger.io/v2*
All URIs are relative to *http://localhost/v2*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------

View File

@ -5,7 +5,7 @@
import 'package:swagger/api.dart';
```
All URIs are relative to *http://petstore.swagger.io/v2*
All URIs are relative to *http://localhost/v2*
Method | HTTP request | Description
------------- | ------------- | -------------

View File

@ -5,7 +5,7 @@
import 'package:swagger/api.dart';
```
All URIs are relative to *http://petstore.swagger.io/v2*
All URIs are relative to *http://localhost/v2*
Method | HTTP request | Description
------------- | ------------- | -------------

View File

@ -5,7 +5,7 @@
import 'package:swagger/api.dart';
```
All URIs are relative to *http://petstore.swagger.io/v2*
All URIs are relative to *http://localhost/v2*
Method | HTTP request | Description
------------- | ------------- | -------------
@ -213,7 +213,7 @@ try {
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
**username** | **String**| The name that needs to be fetched. Use user1 for testing. |
### Return type

View File

@ -18,7 +18,7 @@ class ApiClient {
final _RegList = new RegExp(r'^List<(.*)>$');
final _RegMap = new RegExp(r'^Map<String,(.*)>$');
ApiClient({this.basePath: "http://petstore.swagger.io/v2"}) {
ApiClient({this.basePath: "http://localhost/v2"}) {
// Setup authentications (key: authentication name, value: authentication).
_authentications['api_key'] = new ApiKeyAuth("header", "api_key");
_authentications['petstore_auth'] = new OAuth();
@ -149,4 +149,12 @@ class ApiClient {
auth.applyToParams(queryParams, headerParams);
});
}
void setAccessToken(String accessToken) {
_authentications.forEach((key, auth) {
if (auth is OAuth) {
auth.setAccessToken(accessToken);
}
});
}
}

View File

@ -1,9 +1,19 @@
part of swagger.api;
class OAuth implements Authentication {
String accessToken;
OAuth({this.accessToken}) {
}
@override
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams) {
// TODO: support oauth
if (accessToken != null) {
headerParams["Authorization"] = "Bearer " + accessToken;
}
}
void setAccessToken(String accessToken) {
this.accessToken = accessToken;
}
}

View File

@ -1,10 +1,11 @@
# This file is based on https://github.com/rails/rails/blob/master/.rubocop.yml (MIT license)
# Automatically generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen)
AllCops:
TargetRubyVersion: 2.2
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
# to ignore them, so only the ones explicitly set in this file are enabled.
DisabledByDefault: true
Exclude:
- '**/spec/**/*'
- '**/templates/**/*'
- '**/vendor/**/*'
- 'actionpack/lib/action_dispatch/journey/parser.rb'
@ -113,9 +114,9 @@ Layout/SpaceInsideParens:
Enabled: true
# Check quotes usage according to lint rule below.
Style/StringLiterals:
Enabled: true
EnforcedStyle: single_quotes
#Style/StringLiterals:
# Enabled: true
# EnforcedStyle: single_quotes
# Detect hard tabs, no hard tabs.
Layout/Tab:

View File

@ -12,6 +12,8 @@ Method | HTTP request | Description
To test class name in snake case
To test class name in snake case
### Example
```ruby
# load the gem

View File

@ -20,6 +20,7 @@ module Petstore
@api_client = api_client
end
# To test class name in snake case
# To test class name in snake case
# @param body client model
# @param [Hash] opts the optional parameters
# @return [Client]
@ -28,6 +29,7 @@ module Petstore
data
end
# To test class name in snake case
# To test class name in snake case
# @param body client model
# @param [Hash] opts the optional parameters

View File

@ -248,7 +248,7 @@ module Petstore
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
"will be deleted automatically with GC. It's also recommended to delete the temp file "\
'explicitly with `tempfile.delete`'
"explicitly with `tempfile.delete`"
end
end

View File

@ -1,5 +1,5 @@
# -*- encoding: utf-8 -*-
#
=begin
#Swagger Petstore
@ -24,8 +24,7 @@ Gem::Specification.new do |s|
s.homepage = "https://github.com/swagger-api/swagger-codegen"
s.summary = "Swagger Petstore Ruby Gem"
s.description = "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\"
# TODO uncomment and update below with a proper license
#s.license = "Apache 2.0"
s.license = "Unlicense"
s.required_ruby_version = ">= 1.9"
s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
@ -39,7 +38,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'autotest-growl', '~> 0.2', '>= 0.2.16'
s.add_development_dependency 'autotest-fsevent', '~> 0.2', '>= 0.2.12'
s.files = `find *`.split("\n").uniq.sort.select{|f| !f.empty? }
s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? }
s.test_files = `find spec/*`.split("\n")
s.executables = []
s.require_paths = ["lib"]