Skip to content

Commit

Permalink
update dart, ruby petstore samples
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 committed Feb 22, 2018
1 parent 91bd7ac commit a59c325
Show file tree
Hide file tree
Showing 29 changed files with 100 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.1
2.4.0-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------ | ------------- | ------------- | -------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------- | ------------- | -------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------- | ------------- | -------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------- | ------------- | -------------
Expand Down Expand Up @@ -199,7 +199,7 @@ Get user by user name
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.
var username = username_example; // String | The name that needs to be fetched. Use user1 for testing.
try {
var result = api_instance.getUserByName(username);
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
});
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of swagger.api;

abstract class Authentication {

/// Apply authentication settings to header and query params.
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams);
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.1
2.4.0-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------ | ------------- | ------------- | -------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------- | ------------- | -------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------- | ------------- | -------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------- | ------------- | -------------
Expand Down Expand Up @@ -199,7 +199,7 @@ Get user by user name
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.
var username = username_example; // String | The name that needs to be fetched. Use user1 for testing.
try {
var result = api_instance.getUserByName(username);
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
});
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of swagger.api;

abstract class Authentication {

/// Apply authentication settings to header and query params.
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams);
}
}
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.3.1
2.4.0-SNAPSHOT
2 changes: 1 addition & 1 deletion samples/client/petstore/dart/swagger/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------ | ------------- | ------------- | -------------
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/dart/swagger/docs/PetApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------- | ------------- | -------------
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/dart/swagger/docs/StoreApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------- | ------------- | -------------
Expand Down
6 changes: 3 additions & 3 deletions samples/client/petstore/dart/swagger/docs/UserApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
------------- | ------------- | -------------
Expand Down Expand Up @@ -199,7 +199,7 @@ Get user by user name
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.
var username = username_example; // String | The name that needs to be fetched. Use user1 for testing.
try {
var result = api_instance.getUserByName(username);
Expand All @@ -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

Expand Down
10 changes: 9 additions & 1 deletion samples/client/petstore/dart/swagger/lib/api_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
});
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
part of swagger.api;

abstract class Authentication {

/// Apply authentication settings to header and query params.
void applyToParams(List<QueryParam> queryParams, Map<String, String> headerParams);
}
}
12 changes: 11 additions & 1 deletion samples/client/petstore/dart/swagger/lib/auth/oauth.dart
Original file line number Diff line number Diff line change
@@ -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;
}
}
9 changes: 5 additions & 4 deletions samples/client/petstore/ruby/.rubocop.yml
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions samples/client/petstore/ruby/docs/FakeClassnameTags123Api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def initialize(api_client = ApiClient.default)
@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]
Expand All @@ -28,6 +29,7 @@ def test_classname(body, opts = {})
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
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/ruby/lib/petstore/api_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def download_file(request)
@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

Expand Down
Loading

0 comments on commit a59c325

Please sign in to comment.