Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !9503
An error occurred while fetching the assigned milestone of the selected merge_request.

Fix CircleCI failures

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Peter Leibiger requested to merge github/fork/kuhnroyal/go/fix-echo-server-sample into master 4 years ago
  • Overview 0
  • Commits 2
  • Pipelines 0
  • Changes 29

An attempt to get CircleCi builds to succeed again.

GO

  • remove wrong argument for go sample

Dart

  • fixes following https://github.com/OpenAPITools/openapi-generator/pull/9392
  • MultipartRequest(null, null) is no longer valid after http package upgrade
  • fix petstore sample project not compiling
  • disable live petstore tests
  • use template to strip out unused code blocks

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    Commit all changed files. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master, 5.1.x, 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
Compare
  • master (base)

and
  • latest version
    d4d29ea0
    2 commits, 2 years ago

29 files
+ 298
- 1586

    Preferences

    File browser
    Compare changes
modules/openapi-ge‎nerator/…/…/…/dart2‎
api.mu‎stache‎ +30 -32
sam‎ples‎
openapi3/client‎/petstore/dart2‎
pets‎tore‎
te‎st‎
fake_cli‎ent.dart‎ +10 -9
order_mode‎l_test.dart‎ +4 -4
pet_faked_cli‎ent_test.dart‎ +14 -31
pet_te‎st.dart‎ +4 -7
random_‎id.dart‎ +1 -1
store_faked_cl‎ient_test.dart‎ +38 -44
store_t‎est.dart‎ +10 -12
user_te‎st.dart‎ +4 -5
.analysi‎s_options‎ +0 -2
pubspe‎c.yaml‎ +7 -2
petstore_clie‎nt_lib/lib/api‎
pet_ap‎i.dart‎ +18 -112
store_a‎pi.dart‎ +0 -44
user_a‎pi.dart‎ +0 -88
petstore_client_‎lib_fake/lib/api‎
another_fa‎ke_api.dart‎ +0 -11
default_‎api.dart‎ +0 -11
fake_a‎pi.dart‎ +48 -297
fake_classname_‎tags123_api.dart‎ +0 -11
pet_ap‎i.dart‎ +31 -134
store_a‎pi.dart‎ +0 -44
user_a‎pi.dart‎ +0 -88
…/‎…/…‎
another_fa‎ke_api.dart‎ +0 -11
default_‎api.dart‎ +0 -11
fake_a‎pi.dart‎ +48 -297
fake_classname_‎tags123_api.dart‎ +0 -11
pet_ap‎i.dart‎ +31 -134
store_a‎pi.dart‎ +0 -44
user_a‎pi.dart‎ +0 -88
server/petstore‎/go-echo-server‎
pom‎.xml‎ +0 -1
modules/openapi-generator/src/main/resources/dart2/api.mustache
+ 30
- 32
  • View file @ d4d29ea0

  • Edit in single-file editor

  • Open in Web IDE


@@ -99,39 +99,37 @@ class {{{classname}}} {
final nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null;
final authNames = <String>[{{#authMethods}}'{{{name}}}'{{^-last}}, {{/-last}}{{/authMethods}}];
if (
nullableContentType != null &&
nullableContentType.toLowerCase().startsWith('multipart/form-data')
) {
bool hasFields = false;
final mp = MultipartRequest(null, null);
{{#formParams}}
{{^isFile}}
if ({{{paramName}}} != null) {
hasFields = true;
mp.fields[r'{{{baseName}}}'] = parameterToString({{{paramName}}});
}
{{/isFile}}
{{#isFile}}
if ({{{paramName}}} != null) {
hasFields = true;
mp.fields[r'{{{baseName}}}'] = {{{paramName}}}.field;
mp.files.add({{{paramName}}});
}
{{/isFile}}
{{/formParams}}
if (hasFields) {
postBody = mp;
}
} else {
{{#formParams}}
{{^isFile}}
if ({{{paramName}}} != null) {
formParams[r'{{{baseName}}}'] = parameterToString({{{paramName}}});
}
{{/isFile}}
{{/formParams}}
{{#isMultipart}}
bool hasFields = false;
final mp = MultipartRequest('{{{httpMethod}}}', Uri.parse(path));
{{#formParams}}
{{^isFile}}
if ({{{paramName}}} != null) {
hasFields = true;
mp.fields[r'{{{baseName}}}'] = parameterToString({{{paramName}}});
}
{{/isFile}}
{{#isFile}}
if ({{{paramName}}} != null) {
hasFields = true;
mp.fields[r'{{{baseName}}}'] = {{{paramName}}}.field;
mp.files.add({{{paramName}}});
}
{{/isFile}}
{{/formParams}}
if (hasFields) {
postBody = mp;
}
{{/isMultipart}}
{{^isMultipart}}
{{#formParams}}
{{^isFile}}
if ({{{paramName}}} != null) {
formParams[r'{{{baseName}}}'] = parameterToString({{{paramName}}});
}
{{/isFile}}
{{/formParams}}
{{/isMultipart}}
return await apiClient.invokeAPI(
path,
samples/openapi3/client/petstore/dart2/petstore/test/fake_client.dart
+ 10
- 9
  • View file @ d4d29ea0

  • Edit in single-file editor

  • Open in Web IDE


@@ -21,9 +21,9 @@ class FakeClient extends Fake implements Client {
this.expectedPutRequestBody,
this.putResponseBody,
this.sendResponseBody,
this.expectedUrl,
String expectedUrl,
this.expectedHeaders = null,
});
}) : this.expectedUrl = Uri.parse(expectedUrl);
Exception throwException;
Object expectedPostRequestBody;
@@ -34,12 +34,12 @@ class FakeClient extends Fake implements Client {
String expectedPutRequestBody;
String putResponseBody;
String sendResponseBody;
String expectedUrl;
Uri expectedUrl;
Map<String, String> expectedHeaders;
@override
Future<Response> post(url,
{Map<String, String> headers, body, Encoding encoding}) async {
Future<Response> post(Uri url,
{Map<String, String> headers, Object body, Encoding encoding}) async {
// check that the request was made with expected values
if (url != expectedUrl) {
throw StateError(
@@ -67,7 +67,7 @@ class FakeClient extends Fake implements Client {
}
@override
Future<Response> get(url, {Map<String, String> headers}) async {
Future<Response> get(Uri url, {Map<String, String> headers}) async {
// check that the request was made with expected values
if (url != expectedUrl) {
throw StateError(
@@ -85,7 +85,8 @@ class FakeClient extends Fake implements Client {
}
@override
Future<Response> delete(url, {Map<String, String> headers}) async {
Future<Response> delete(Uri url,
{Map<String, String> headers, Object body, Encoding encoding}) async {
// check that the request was made with expected values
if (url != expectedUrl) {
throw StateError(
@@ -103,8 +104,8 @@ class FakeClient extends Fake implements Client {
}
@override
Future<Response> put(url,
{Map<String, String> headers, body, Encoding encoding}) async {
Future<Response> put(Uri url,
{Map<String, String> headers, Object body, Encoding encoding}) async {
// check that the request was made with expected values
if (url != expectedUrl) {
throw StateError(
samples/openapi3/client/petstore/dart2/petstore/test/order_model_test.dart
+ 4
- 4
  • View file @ d4d29ea0

  • Edit in single-file editor

  • Open in Web IDE


@@ -2,8 +2,8 @@ import 'package:openapi/api.dart';
import 'package:test/test.dart';
void main() {
test('Check if default value is generated', () async {
var order = Order();
expect(order.complete, equals(false));
});
test('Check if default value is generated', () async {
var order = Order();
expect(order.complete, equals(false));
});
}
samples/openapi3/client/petstore/dart2/petstore/test/pet_faked_client_test.dart
+ 14
- 31
  • View file @ d4d29ea0

  • Edit in single-file editor

  • Open in Web IDE


@@ -26,11 +26,10 @@ void main() {
..id = 124321
..name = 'Jose'
];
return Pet()
return Pet(name: name)
..id = id
..category = category
..tags = tags
..name = name
..status = PetStatusEnum.fromJson(status)
..photoUrls = ['https://petstore.com/sample/photo1.jpg'];
}
@@ -53,8 +52,7 @@ void main() {
// use the pet api to add a pet
petApi.apiClient.client = FakeClient(
expectedUrl: 'http://petstore.swagger.io/v2/pet',
expectedPostRequestBody:
await petApi.apiClient.serializeAsync(newPet),
expectedPostRequestBody: await petApi.apiClient.serializeAsync(newPet),
postResponseBody: await petApi.apiClient.serializeAsync(newPet),
expectedHeaders: {'Content-Type': 'application/json'});
await petApi.addPet(newPet);
@@ -76,8 +74,7 @@ void main() {
expectedUrl: 'http://petstore.swagger.io/v2/pet/$id',
throwException: ApiException(400, 'not found'),
);
expect(
petApi.getPetById(id), throwsA(equals(TypeMatcher<ApiException>())));
expect(petApi.getPetById(id), throwsA(equals(TypeMatcher<ApiException>())));
});
test('deletes existing pet by id', () async {
@@ -87,8 +84,7 @@ void main() {
// add a new pet
petApi.apiClient.client = FakeClient(
expectedUrl: 'http://petstore.swagger.io/v2/pet',
expectedPostRequestBody:
await petApi.apiClient.serializeAsync(newPet),
expectedPostRequestBody: await petApi.apiClient.serializeAsync(newPet),
postResponseBody: await petApi.apiClient.serializeAsync(newPet),
expectedHeaders: {'Content-Type': 'application/json'});
await petApi.addPet(newPet);
@@ -106,8 +102,7 @@ void main() {
expectedUrl: 'http://petstore.swagger.io/v2/pet/$id',
throwException: ApiException(400, 'Not found'),
);
expect(
petApi.getPetById(id), throwsA(equals(TypeMatcher<ApiException>())));
expect(petApi.getPetById(id), throwsA(equals(TypeMatcher<ApiException>())));
});
test('updates pet with form', () async {
@@ -117,16 +112,11 @@ void main() {
// add a new pet
petApi.apiClient.client = FakeClient(
expectedUrl: 'http://petstore.swagger.io/v2/pet',
expectedPostRequestBody:
await petApi.apiClient.serializeAsync(newPet),
expectedPostRequestBody: await petApi.apiClient.serializeAsync(newPet),
postResponseBody: await petApi.apiClient.serializeAsync(newPet),
expectedHeaders: {'Content-Type': 'application/json'});
await petApi.addPet(newPet);
final multipartRequest = MultipartRequest(null, null);
multipartRequest.fields['name'] = 'Doge';
multipartRequest.fields['status'] = '';
// update with form
petApi.apiClient.client = FakeClient(
expectedUrl: 'http://petstore.swagger.io/v2/pet/$id',
@@ -157,8 +147,7 @@ void main() {
// add a new pet
petApi.apiClient.client = FakeClient(
expectedUrl: 'http://petstore.swagger.io/v2/pet',
expectedPostRequestBody:
await petApi.apiClient.serializeAsync(newPet),
expectedPostRequestBody: await petApi.apiClient.serializeAsync(newPet),
postResponseBody: await petApi.apiClient.serializeAsync(newPet),
expectedHeaders: {'Content-Type': 'application/json'});
await petApi.addPet(newPet);
@@ -166,8 +155,7 @@ void main() {
// update the same pet
petApi.apiClient.client = FakeClient(
expectedUrl: 'http://petstore.swagger.io/v2/pet',
expectedPutRequestBody:
await petApi.apiClient.serializeAsync(updatePet),
expectedPutRequestBody: await petApi.apiClient.serializeAsync(updatePet),
putResponseBody: await petApi.apiClient.serializeAsync(updatePet),
expectedHeaders: {'Content-Type': 'application/json'});
await petApi.updatePet(updatePet);
@@ -196,15 +184,13 @@ void main() {
// retrieve pets by status
petApi.apiClient.client = FakeClient(
expectedUrl:
'http://petstore.swagger.io/v2/pet/findByStatus?status=$status',
expectedUrl: 'http://petstore.swagger.io/v2/pet/findByStatus?status=$status',
getResponseBody: await petApi.apiClient.serializeAsync([pet1, pet2]),
);
final pets = await petApi.findPetsByStatus([status]);
// tests serialisation and deserialisation of enum
final petsByStatus =
pets.where((p) => p.status == PetStatusEnum.available);
final petsByStatus = pets.where((p) => p.status == PetStatusEnum.available);
expect(petsByStatus.length, equals(2));
final petIds = pets.map((pet) => pet.id).toList();
expect(petIds, contains(id1));
@@ -216,14 +202,12 @@ void main() {
final id = newId();
final newPet = makePet(id: id);
// get some test data (recorded from live response)
final uploadResponse =
await File('test/file_upload_response.json').readAsString();
final uploadResponse = await File('test/file_upload_response.json').readAsString();
// add a new pet
petApi.apiClient.client = FakeClient(
expectedUrl: 'http://petstore.swagger.io/v2/pet',
expectedPostRequestBody:
await petApi.apiClient.serializeAsync(newPet),
expectedPostRequestBody: await petApi.apiClient.serializeAsync(newPet),
postResponseBody: await petApi.apiClient.serializeAsync(newPet),
expectedHeaders: {'Content-Type': 'application/json'});
await petApi.addPet(newPet);
@@ -232,9 +216,8 @@ void main() {
expectedUrl: 'http://petstore.swagger.io/v2/pet',
sendResponseBody: uploadResponse,
);
final file =
new MultipartFile.fromBytes('file', [104, 101, 108, 108, 111]);
await petApi.uploadFile(id, additionalMetadata: '', file: file);
final file = new MultipartFile.fromBytes('file', [104, 101, 108, 108, 111]);
await petApi.uploadFile(id, file: file);
});
});
}
samples/openapi3/client/petstore/dart2/petstore/test/pet_test.dart
+ 4
- 7
  • View file @ d4d29ea0

  • Edit in single-file editor

  • Open in Web IDE


import 'dart:async';
@Skip('Needs real petstore')
import 'package:http/http.dart';
import 'package:openapi/api.dart';
import 'package:test/test.dart';
@@ -46,16 +45,14 @@ void main() {
});
test('doesn\'t get non-existing pet by id', () {
expect(petApi.getPetById(newId()),
throwsA(equals(TypeMatcher<ApiException>())));
expect(petApi.getPetById(newId()), throwsA(equals(TypeMatcher<ApiException>())));
});
test('deletes existing pet by id', () async {
var id = newId();
await petApi.addPet(makePet(id: id));
await petApi.deletePet(id, apiKey: 'special-key');
expect(
petApi.getPetById(id), throwsA(equals(TypeMatcher<ApiException>())));
expect(petApi.getPetById(id), throwsA(equals(TypeMatcher<ApiException>())));
});
test('updates pet with form', () async {
@@ -100,5 +97,5 @@ void main() {
var file = new MultipartFile.fromBytes('file', [104, 101, 108, 108, 111]);
await petApi.uploadFile(id, additionalMetadata: '', file: file);
});
}, skip: 'e2e tests for CI');
});
}
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 participants
Reference:
Source branch: github/fork/kuhnroyal/go/fix-echo-server-sample

Menu

Explore Projects Groups Snippets