From 7cddacf3226af78e273a59d3431c3efcb533dcae Mon Sep 17 00:00:00 2001 From: Wahab Alshahin Date: Sun, 27 Aug 2023 16:38:24 -0400 Subject: [PATCH] Keep all caps class names for schema generation --- CHANGELOG.md | 4 ++++ lib/src/generators/schema.dart | 8 +++++++- pubspec.yaml | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81016ad..16d5eb6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.4.11 + +* Keep all caps class names in schema generation + ## 0.4.10 * Better handling of whitespace in schema generation diff --git a/lib/src/generators/schema.dart b/lib/src/generators/schema.dart index 4d7f4e4..aeb0c73 100644 --- a/lib/src/generators/schema.dart +++ b/lib/src/generators/schema.dart @@ -74,7 +74,13 @@ class SchemaGenerator extends BaseGenerator { // Loop through all the schemas and write for (final s in schemas.keys) { final filename = s.snakeCase.replaceAll(RegExp(r'(?<=\w)_(?=\w_)'), ''); - String name = s.pascalCase; + String name; + if (s == s.toUpperCase()) { + // Do not modify all uppercase schema names + name = s; + } else { + name = s.pascalCase; + } if (options.onSchemaName != null) { final userSchemaName = options.onSchemaName!(name); diff --git a/pubspec.yaml b/pubspec.yaml index 19ee409..6267f6c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: openapi_spec description: OpenAPI Specification generator using native Dart code, as well as an all-in-one parser of existing specifications. -version: 0.4.10 +version: 0.4.11 maintainer: Taza Technology LLC repository: https://github.com/tazatechnology/openapi_spec issue_tracker: https://github.com/tazatechnology/openapi_spec/issues