-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5966 from kiota-community/features/dart
Add code generation for Dart
- Loading branch information
Showing
33 changed files
with
4,553 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
pubspec.lock | ||
.dart_tool/ | ||
src/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import 'package:microsoft_kiota_abstractions/microsoft_kiota_abstractions.dart'; | ||
import 'package:microsoft_kiota_http/microsoft_kiota_http.dart'; | ||
import 'package:test/test.dart'; | ||
import '../lib/api_client.dart'; | ||
import '../lib/models/error.dart'; | ||
|
||
void main() { | ||
group('apiclient', () { | ||
test('basic endpoint test', () { | ||
final requestAdapter = HttpClientRequestAdapter( | ||
client: KiotaClientFactory.createClient(), | ||
authProvider: AnonymousAuthenticationProvider(), | ||
pNodeFactory: ParseNodeFactoryRegistry.defaultInstance, | ||
sWriterFactory: SerializationWriterFactoryRegistry.defaultInstance, | ||
); | ||
requestAdapter.baseUrl = "http://localhost:1080"; | ||
var client = ApiClient(requestAdapter); | ||
expect( | ||
() => client.api.v1.topics.getAsync(), | ||
throwsA(predicate( | ||
(e) => e is Error && e.id == 'my-sample-id' && e.code == 123))); | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: kiota_dart_generate | ||
description: api generation | ||
version: 0.0.1 | ||
publish_to: none | ||
|
||
environment: | ||
sdk: ^3.6.0 | ||
|
||
# Add regular dependencies here. | ||
dependencies: | ||
microsoft_kiota_abstractions: ^0.0.1 | ||
microsoft_kiota_http: ^0.0.1 | ||
microsoft_kiota_serialization_form: ^0.0.1 | ||
microsoft_kiota_serialization_text: ^0.0.1 | ||
microsoft_kiota_serialization_json: ^0.0.1 | ||
microsoft_kiota_serialization_multipart: ^0.0.1 | ||
http: ^1.2.2 | ||
uuid: ^4.5.1 | ||
|
||
dev_dependencies: | ||
lints: ^5.1.1 | ||
test: ^1.25.14 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,6 @@ public enum GenerationLanguage | |
Go, | ||
Swift, | ||
Ruby, | ||
CLI | ||
CLI, | ||
Dart, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using Kiota.Builder.CodeDOM; | ||
using Kiota.Builder.Extensions; | ||
using Kiota.Builder.Writers.Go; | ||
|
||
namespace Kiota.Builder.PathSegmenters; | ||
|
||
public class DartPathSegmenter(string rootPath, string clientNamespaceName) : CommonPathSegmenter(rootPath, clientNamespaceName) | ||
{ | ||
public override string FileSuffix => ".dart"; | ||
|
||
public override string NormalizeNamespaceSegment(string segmentName) => segmentName.ToCamelCase(); | ||
|
||
public override string NormalizeFileName(CodeElement currentElement) => GetLastFileNameSegment(currentElement).ToSnakeCase(); | ||
|
||
internal string GetRelativeFileName(CodeNamespace @namespace, CodeElement element) | ||
{ | ||
return NormalizeFileName(element); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/Kiota.Builder/Refiners/DartExceptionsReservedNamesProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Kiota.Builder.Refiners; | ||
public class DartExceptionsReservedNamesProvider : IReservedNamesProvider | ||
{ | ||
private readonly Lazy<HashSet<string>> _reservedNames = new(static () => new(StringComparer.OrdinalIgnoreCase) | ||
{ | ||
"toString" | ||
}); | ||
public HashSet<string> ReservedNames => _reservedNames.Value; | ||
} |
Oops, something went wrong.