Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dickermoshe committed Mar 11, 2024
1 parent 0fb6a96 commit 295a90d
Show file tree
Hide file tree
Showing 252 changed files with 46,413 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/openapi_spec_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'oas_examples/test.dart' as oas_examples;
import 'chromadb/test.dart' as chromadb;
import 'openai/test.dart' as openai;
import 'unions/test.dart' as unions;
import 'static/main.dart' as static_;

void main() {
// Ensure a clean test tmp directory
Expand All @@ -19,4 +20,5 @@ void main() {
chromadb.main();
openai.main();
unions.main();
static_.main();
}
32 changes: 32 additions & 0 deletions test/static/main.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import 'dart:io';
import 'package:path/path.dart' as p;
import 'package:test/test.dart';

import 'package:openapi_spec/openapi_spec.dart';

void main() {
final tmp = Directory(
p.join('test', 'tmp', 'static'),
);

group("Static", () {
setUpAll(() {
if (!tmp.existsSync()) {
tmp.createSync(recursive: true);
}
});

for (final version in ['v3.0', 'v3.1']) {
final schema = Directory(p.join('test', 'static', version));
final allSchemas = schema.listSync().whereType<File>().where((element) =>
element.path.endsWith('.json') || element.path.endsWith('.yaml'));
for (final e in allSchemas) {
final dest = p.join(tmp.path, p.basenameWithoutExtension(e.path));
test(p.basenameWithoutExtension(e.path), () async {
final spec = OpenApi.fromFile(source: e.path);
await spec.generate(destination: dest);
});
}
}
});
}
27 changes: 27 additions & 0 deletions test/static/v3.0/11_regex.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
components:
schemas:
StringWithRegexWithThreeFlags:
format: uuid
pattern: /a./sim
type: string
UUID:
format: uuid
pattern: '[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}'
type: string
info:
title: Test
version: 1.0.0-SNAPSHOT
openapi: 3.0.3
paths:
/test:
get:
parameters:
- in: query
name: uuid
schema:
$ref: '#/components/schemas/UUID'
responses:
'200':
description: OK
tags:
- Test Resource
12 changes: 12 additions & 0 deletions test/static/v3.0/13942_schema_enum_names.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
components:
schemas:
StringEnum:
enum:
- '#367B9C'
- '#FFA5A4'
type: string
info:
title: Test
version: 1.0.0-SNAPSHOT
openapi: 3.0.3
paths: {}
22 changes: 22 additions & 0 deletions test/static/v3.0/3134-regression.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
info:
description: info
title: info
version: 0.1.0
openapi: 3.0.2
paths:
/example/api:
post:
description: description
requestBody:
content:
application/json:
schema:
properties:
name:
type: string
type: object
required: false
responses:
200:
description: response
summary: summary
25 changes: 25 additions & 0 deletions test/static/v3.0/3248-regression-dates.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
info:
description: info
title: info
version: 0.1.0
openapi: 3.0.2
paths:
/example/api:
get:
description: description
parameters:
- description: The start time.
in: query
name: start
required: true
schema:
format: date-time
type: string
responses:
200:
content:
application/json:
schema:
type: string
description: response
summary: summary
44 changes: 44 additions & 0 deletions test/static/v3.0/3248-regression.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
components:
parameters:
formatParam:
description: set format
in: query
name: format
required: false
schema:
$ref: '#/components/schemas/format'
requiredQueryParam:
description: set query
in: query
name: query
required: true
schema:
type: string
schemas:
format:
default: json
description: response format
enum:
- json
- csv
type: string
info:
description: info
title: info
version: 0.1.0
openapi: 3.0.2
paths:
/example/api:
get:
description: description
parameters:
- $ref: '#/components/parameters/requiredQueryParam'
- $ref: '#/components/parameters/formatParam'
responses:
200:
content:
application/json:
schema:
type: string
description: response
summary: summary
35 changes: 35 additions & 0 deletions test/static/v3.0/3_0__arrayRefBody.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
components:
schemas:
Input:
properties:
age:
format: int32
type: integer
dt:
format: date-time
type: string
id:
type: string
type: object
info:
title: ''
version: ''
openapi: 3.0.0
paths:
/examples:
post:
operationId: getFilteredTransactions
requestBody:
content:
application/json:
schema:
items:
$ref: '#/components/schemas/Input'
type: array
description: subscription payload
responses:
default:
description: successful operation
summary: Get a list of transactions
tags:
- Examples
Loading

0 comments on commit 295a90d

Please sign in to comment.