From 14149a3e3c956b6e76a0ef7bd268aa944f7cb09c Mon Sep 17 00:00:00 2001 From: Patrick Stewart Date: Sun, 4 Aug 2024 03:59:05 -0700 Subject: [PATCH] add(conduit): working on refactoring open_api to openapi --- packages/openapi/lib/src/.gitkeep | 0 packages/openapi/lib/src/object.dart | 8 ++++ .../openapi/lib/src/util/list_helper.dart | 28 ++++++++++++++ packages/openapi/lib/src/util/map_helper.dart | 38 +++++++++++++++++++ packages/openapi/lib/src/v2/document.dart | 8 ++++ packages/openapi/lib/src/v2/header.dart | 8 ++++ packages/openapi/lib/src/v2/metadata.dart | 8 ++++ packages/openapi/lib/src/v2/operation.dart | 8 ++++ packages/openapi/lib/src/v2/parameter.dart | 8 ++++ packages/openapi/lib/src/v2/path.dart | 8 ++++ packages/openapi/lib/src/v2/property.dart | 8 ++++ packages/openapi/lib/src/v2/response.dart | 8 ++++ packages/openapi/lib/src/v2/schema.dart | 8 ++++ packages/openapi/lib/src/v2/security.dart | 8 ++++ packages/openapi/lib/src/v2/types.dart | 8 ++++ packages/openapi/lib/src/v3/callback.dart | 8 ++++ packages/openapi/lib/src/v3/componenets.dart | 8 ++++ packages/openapi/lib/src/v3/document.dart | 8 ++++ packages/openapi/lib/src/v3/encoding.dart | 8 ++++ packages/openapi/lib/src/v3/header.dart | 8 ++++ packages/openapi/lib/src/v3/media_type.dart | 8 ++++ packages/openapi/lib/src/v3/metadata.dart | 8 ++++ packages/openapi/lib/src/v3/operation.dart | 8 ++++ packages/openapi/lib/src/v3/parameter.dart | 8 ++++ packages/openapi/lib/src/v3/path.dart | 8 ++++ packages/openapi/lib/src/v3/request_body.dart | 8 ++++ packages/openapi/lib/src/v3/response.dart | 8 ++++ packages/openapi/lib/src/v3/schema.dart | 8 ++++ packages/openapi/lib/src/v3/security.dart | 8 ++++ packages/openapi/lib/src/v3/server.dart | 8 ++++ packages/openapi/lib/src/v3/types.dart | 8 ++++ packages/openapi/lib/v2.dart | 15 +++++--- packages/openapi/lib/v3.dart | 15 +++++--- packages/openapi/pubspec.yaml | 5 ++- 34 files changed, 311 insertions(+), 14 deletions(-) delete mode 100644 packages/openapi/lib/src/.gitkeep create mode 100644 packages/openapi/lib/src/object.dart create mode 100644 packages/openapi/lib/src/util/list_helper.dart create mode 100644 packages/openapi/lib/src/util/map_helper.dart create mode 100644 packages/openapi/lib/src/v2/document.dart create mode 100644 packages/openapi/lib/src/v2/header.dart create mode 100644 packages/openapi/lib/src/v2/metadata.dart create mode 100644 packages/openapi/lib/src/v2/operation.dart create mode 100644 packages/openapi/lib/src/v2/parameter.dart create mode 100644 packages/openapi/lib/src/v2/path.dart create mode 100644 packages/openapi/lib/src/v2/property.dart create mode 100644 packages/openapi/lib/src/v2/response.dart create mode 100644 packages/openapi/lib/src/v2/schema.dart create mode 100644 packages/openapi/lib/src/v2/security.dart create mode 100644 packages/openapi/lib/src/v2/types.dart create mode 100644 packages/openapi/lib/src/v3/callback.dart create mode 100644 packages/openapi/lib/src/v3/componenets.dart create mode 100644 packages/openapi/lib/src/v3/document.dart create mode 100644 packages/openapi/lib/src/v3/encoding.dart create mode 100644 packages/openapi/lib/src/v3/header.dart create mode 100644 packages/openapi/lib/src/v3/media_type.dart create mode 100644 packages/openapi/lib/src/v3/metadata.dart create mode 100644 packages/openapi/lib/src/v3/operation.dart create mode 100644 packages/openapi/lib/src/v3/parameter.dart create mode 100644 packages/openapi/lib/src/v3/path.dart create mode 100644 packages/openapi/lib/src/v3/request_body.dart create mode 100644 packages/openapi/lib/src/v3/response.dart create mode 100644 packages/openapi/lib/src/v3/schema.dart create mode 100644 packages/openapi/lib/src/v3/security.dart create mode 100644 packages/openapi/lib/src/v3/server.dart create mode 100644 packages/openapi/lib/src/v3/types.dart diff --git a/packages/openapi/lib/src/.gitkeep b/packages/openapi/lib/src/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/packages/openapi/lib/src/object.dart b/packages/openapi/lib/src/object.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/object.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/util/list_helper.dart b/packages/openapi/lib/src/util/list_helper.dart new file mode 100644 index 0000000..2358318 --- /dev/null +++ b/packages/openapi/lib/src/util/list_helper.dart @@ -0,0 +1,28 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/// Removes null entries from a list of nullable strings and returns a new list of non-nullable strings. +/// +/// This function takes a nullable list of nullable strings as input and performs two operations: +/// 1. It removes any null entries from the list. +/// 2. It converts the resulting list to a List. +/// +/// If the input list is null, the function returns null. +/// +/// Parameters: +/// [list] - The input list of nullable strings (List?) that may contain null entries. +/// +/// Returns: +/// A new List with all non-null entries from the input list, or null if the input list is null. +List? removeNullsFromList(List? list) { + if (list == null) return null; + + // remove nulls and convert to List + return list.nonNulls.toList(); +} diff --git a/packages/openapi/lib/src/util/map_helper.dart b/packages/openapi/lib/src/util/map_helper.dart new file mode 100644 index 0000000..b0ee80f --- /dev/null +++ b/packages/openapi/lib/src/util/map_helper.dart @@ -0,0 +1,38 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +/// Removes null values from a map and converts its type. +/// +/// This function takes a nullable [Map] with potentially nullable values +/// and returns a new [Map] with the following characteristics: +/// - All entries with null values are removed. +/// - The resulting map is non-nullable (both for the map itself and its values). +/// - If the input map is null, an empty map is returned. +/// +/// Parameters: +/// [map]: The input map of type `Map?` where `K` is the key type +/// and `V` is the value type. +/// +/// Returns: +/// A new `Map` with null values removed and non-nullable types. +Map removeNullsFromMap(Map? map) { + if (map == null) return {}; + + final fixed = {}; + + // remove nulls + for (final key in map.keys) { + final value = map[key]; + if (value != null) { + fixed[key] = value; + } + } + + return fixed; +} diff --git a/packages/openapi/lib/src/v2/document.dart b/packages/openapi/lib/src/v2/document.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v2/document.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v2/header.dart b/packages/openapi/lib/src/v2/header.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v2/header.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v2/metadata.dart b/packages/openapi/lib/src/v2/metadata.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v2/metadata.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v2/operation.dart b/packages/openapi/lib/src/v2/operation.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v2/operation.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v2/parameter.dart b/packages/openapi/lib/src/v2/parameter.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v2/parameter.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v2/path.dart b/packages/openapi/lib/src/v2/path.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v2/path.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v2/property.dart b/packages/openapi/lib/src/v2/property.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v2/property.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v2/response.dart b/packages/openapi/lib/src/v2/response.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v2/response.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v2/schema.dart b/packages/openapi/lib/src/v2/schema.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v2/schema.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v2/security.dart b/packages/openapi/lib/src/v2/security.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v2/security.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v2/types.dart b/packages/openapi/lib/src/v2/types.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v2/types.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v3/callback.dart b/packages/openapi/lib/src/v3/callback.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v3/callback.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v3/componenets.dart b/packages/openapi/lib/src/v3/componenets.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v3/componenets.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v3/document.dart b/packages/openapi/lib/src/v3/document.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v3/document.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v3/encoding.dart b/packages/openapi/lib/src/v3/encoding.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v3/encoding.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v3/header.dart b/packages/openapi/lib/src/v3/header.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v3/header.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v3/media_type.dart b/packages/openapi/lib/src/v3/media_type.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v3/media_type.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v3/metadata.dart b/packages/openapi/lib/src/v3/metadata.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v3/metadata.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v3/operation.dart b/packages/openapi/lib/src/v3/operation.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v3/operation.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v3/parameter.dart b/packages/openapi/lib/src/v3/parameter.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v3/parameter.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v3/path.dart b/packages/openapi/lib/src/v3/path.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v3/path.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v3/request_body.dart b/packages/openapi/lib/src/v3/request_body.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v3/request_body.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v3/response.dart b/packages/openapi/lib/src/v3/response.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v3/response.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v3/schema.dart b/packages/openapi/lib/src/v3/schema.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v3/schema.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v3/security.dart b/packages/openapi/lib/src/v3/security.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v3/security.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v3/server.dart b/packages/openapi/lib/src/v3/server.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v3/server.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/src/v3/types.dart b/packages/openapi/lib/src/v3/types.dart new file mode 100644 index 0000000..651786d --- /dev/null +++ b/packages/openapi/lib/src/v3/types.dart @@ -0,0 +1,8 @@ +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ \ No newline at end of file diff --git a/packages/openapi/lib/v2.dart b/packages/openapi/lib/v2.dart index 1325848..250f2fe 100644 --- a/packages/openapi/lib/v2.dart +++ b/packages/openapi/lib/v2.dart @@ -1,7 +1,10 @@ -/// Support for doing something awesome. -/// -/// More dartdocs go here. +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + library; - - -// TODO: Export any libraries intended for clients of this package. diff --git a/packages/openapi/lib/v3.dart b/packages/openapi/lib/v3.dart index 1325848..250f2fe 100644 --- a/packages/openapi/lib/v3.dart +++ b/packages/openapi/lib/v3.dart @@ -1,7 +1,10 @@ -/// Support for doing something awesome. -/// -/// More dartdocs go here. +/* + * This file is part of the Protevus Platform. + * + * (C) Protevus + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + library; - - -// TODO: Export any libraries intended for clients of this package. diff --git a/packages/openapi/pubspec.yaml b/packages/openapi/pubspec.yaml index 1615c44..2da5a1b 100644 --- a/packages/openapi/pubspec.yaml +++ b/packages/openapi/pubspec.yaml @@ -1,5 +1,5 @@ name: protevus_openapi -description: The openapi specification for the Protevus Platform +description: Data structures for OpenAPI (Swagger) specification. Reads and writes JSON specifications. version: 0.0.1 homepage: https://protevus.com documentation: https://docs.protevus.com @@ -10,7 +10,8 @@ environment: # Add regular dependencies here. dependencies: - # path: ^1.8.0 + protevus_typeforge: ^0.0.1 + meta: ^1.12.0 dev_dependencies: lints: ^3.0.0