Skip to content

Commit

Permalink
Showing 50 changed files with 2,176 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
* @ricardoboss
/packages/kiota_serialization_json @joanne-ter-maat
/packages/kiota_serialization_multipart @Kees-Schotanus
24 changes: 21 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub-get: pub-get-abstractions pub-get-http pub-get-serialization-text pub-get-serialization-form
pub-get: pub-get-abstractions pub-get-http pub-get-serialization-text pub-get-serialization-form pub-get-serialization-json pub-get-serialization-multipart

pub-get-abstractions:
cd packages/kiota_abstractions && dart pub get
@@ -12,10 +12,16 @@ pub-get-serialization-text:
pub-get-serialization-form:
cd packages/kiota_serialization_form && dart pub get

pub-get-serialization-json:
cd packages/kiota_serialization_json && dart pub get

pub-get-serialization-multipart:
cd packages/kiota_serialization_multipart && dart pub get

format:
dart format packages

generate: generate-abstractions generate-http generate-serialization-form
generate: generate-abstractions generate-http generate-serialization-form generate-serialization-json

generate-abstractions:
cd packages/kiota_abstractions && dart run build_runner build --delete-conflicting-outputs
@@ -26,7 +32,13 @@ generate-http:
generate-serialization-form:
cd packages/kiota_serialization_form && dart run build_runner build --delete-conflicting-outputs

test: test-abstractions test-http test-serialization-text test-serialization-form
generate-serialization-json:
cd packages/kiota_serialization_json && dart run build_runner build --delete-conflicting-outputs

generate-serialization-multipart:
cd packages/kiota_serialization_multipart && dart run build_runner build --delete-conflicting-outputs

test: test-abstractions test-http test-serialization-text test-serialization-form test-serialization-json test-serialization-multipart

test-abstractions: pub-get-abstractions generate-abstractions
cd packages/kiota_abstractions && dart test
@@ -39,3 +51,9 @@ test-serialization-text: pub-get-serialization-text

test-serialization-form: pub-get-serialization-form generate-serialization-form
cd packages/kiota_serialization_form && dart test

test-serialization-json: pub-get-serialization-json generate-serialization-json
cd packages/kiota_serialization_json && dart test

test-serialization-multipart: pub-get-serialization-multipart generate-serialization-multipart
cd packages/kiota_serialization_multipart && dart test
8 changes: 8 additions & 0 deletions packages/kiota_abstractions/lib/kiota_abstractions.dart
Original file line number Diff line number Diff line change
@@ -63,6 +63,14 @@ part 'src/serialization/serialization_writer.dart';
part 'src/serialization/serialization_writer_factory.dart';
part 'src/serialization/serialization_writer_factory_registry.dart';
part 'src/serialization/serialization_writer_proxy_factory.dart';
part 'src/serialization/untyped_array.dart';
part 'src/serialization/untyped_boolean.dart';
part 'src/serialization/untyped_double.dart';
part 'src/serialization/untyped_integer.dart';
part 'src/serialization/untyped_node.dart';
part 'src/serialization/untyped_null.dart';
part 'src/serialization/untyped_object.dart';
part 'src/serialization/untyped_string.dart';
part 'src/store/backed_model.dart';
part 'src/store/backing_store.dart';
part 'src/store/backing_store_factory.dart';
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ part of '../../kiota_abstractions.dart';

/// Defines a contract for models that can hold additional data besides the
/// properties defined in the model.
abstract class AdditionDataHolder {
abstract class AdditionalDataHolder {
/// Additional data that is not part of the model's properties.
Map<String, Object> additionalData = {};
Map<String, Object?> additionalData = {};
}
Original file line number Diff line number Diff line change
@@ -71,7 +71,7 @@ abstract class SerializationWriter {
void writeObjectValue<T extends Parsable>(
String? key,
T? value, [
Iterable<Parsable>? additionalValuesToMerge,
Iterable<Parsable?>? additionalValuesToMerge,
]);

/// Writes the specified enum value to the buffer with an optional given
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
part of '../../kiota_abstractions.dart';

/// Represents an untyped node with a collection of other untyped nodes.
class UntypedArray extends UntypedNode {
/// Constructs an instance from the supplied [collection]
const UntypedArray(this.collection);

final Iterable<UntypedNode> collection;

@override
Iterable<UntypedNode> getValue() {
return collection;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
part of '../../kiota_abstractions.dart';

class UntypedBoolean extends UntypedNode {
const UntypedBoolean({required this.value});

final bool value;

@override
bool? getValue() {
return value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
part of '../../kiota_abstractions.dart';

class UntypedDouble extends UntypedNode {
const UntypedDouble(this.value);

final double value;

@override
double? getValue() {
return value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
part of '../../kiota_abstractions.dart';

class UntypedInteger extends UntypedNode {
const UntypedInteger(this.value);

final int value;

@override
int? getValue() {
return value;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
part of '../../kiota_abstractions.dart';

/// Base class for untyped node.
class UntypedNode implements Parsable {
const UntypedNode();

/// Creates a new [UntypedNode] instance.
factory UntypedNode.createFromDiscriminatorValue(ParseNode _) {
return const UntypedNode();
}

/// The deserialization information for the current model.
/// Returns a map of serializer methods for this object.
@override
Map<String, void Function(ParseNode)> getFieldDeserializers() {
return {};
}

/// Serializes the current object
@override
void serialize(SerializationWriter writer) {
// no properties to serialize. This is handled by custom serialization logic.
}

/// Gets the value assigned to untyped node.
Object? getValue() {
throw Exception('getValue is implemented for derived types of UntypedNode');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
part of '../../kiota_abstractions.dart';

class UntypedNull extends UntypedNode {
const UntypedNull();

@override
Object? getValue() {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
part of '../../kiota_abstractions.dart';

/// Represents an untyped node with object value.
class UntypedObject extends UntypedNode {
const UntypedObject(this.properties);

final Map<String, UntypedNode> properties;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
part of '../../kiota_abstractions.dart';

class UntypedString extends UntypedNode {
const UntypedString(this.value);

final String value;

@override
String? getValue() {
return value;
}
}
Original file line number Diff line number Diff line change
@@ -81,7 +81,7 @@ class HttpClientRequestAdapter implements RequestAdapter {
}

void _setBaseUrl(RequestInformation requestInfo) {
requestInfo.pathParameters['baseUrl'] = baseUrl;
requestInfo.pathParameters['baseurl'] = baseUrl;
}

ResponseHandler? _getResponseHandler(RequestInformation requestInfo) {
Original file line number Diff line number Diff line change
@@ -219,7 +219,7 @@ class FormParseNode implements ParseNode {
}

Map<String, Object>? additionalData;
if (item case final AdditionDataHolder dataHolder) {
if (item case final AdditionalDataHolder dataHolder) {
dataHolder.additionalData = additionalData ??= {};
}

Original file line number Diff line number Diff line change
@@ -146,7 +146,7 @@ class FormSerializationWriter implements SerializationWriter {
void writeObjectValue<T extends Parsable>(
String? key,
T? value, [
Iterable<Parsable>? additionalValuesToMerge,
Iterable<Parsable?>? additionalValuesToMerge,
]) {
if (writingObject) {
throw UnsupportedError(
@@ -168,12 +168,14 @@ class FormSerializationWriter implements SerializationWriter {

if (additionalValuesToMerge != null) {
for (final additionalValue in additionalValuesToMerge) {
onBeforeObjectSerialization?.call(additionalValue);
onStartObjectSerialization?.call(additionalValue, this);
if (additionalValue != null) {
onBeforeObjectSerialization?.call(additionalValue);
onStartObjectSerialization?.call(additionalValue, this);

additionalValue.serialize(this);
additionalValue.serialize(this);

onAfterObjectSerialization?.call(additionalValue);
onAfterObjectSerialization?.call(additionalValue);
}
}
}

7 changes: 7 additions & 0 deletions packages/kiota_serialization_json/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/

# Avoid committing pubspec.lock for library packages; see
# https://dart.dev/guides/libraries/private-files#pubspeclock.
pubspec.lock
4 changes: 4 additions & 0 deletions packages/kiota_serialization_json/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Unreleased

- Initial version.
- Provides parsing and serialization support for the `application/json` content type.
21 changes: 21 additions & 0 deletions packages/kiota_serialization_json/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The `kiota_serialization_json` package is the Dart Json serialization library implementation to
handle `application/json` responses.

## Usage

Install the package in the generated project:

> For now, you can add the git repository as a dependency in your `pubspec.yaml` file:
>
> ```yaml
> dependencies:
> kiota_serialization_json:
> git:
> url: https://github.com/ricardoboss/dart_kiota.git
> ref: main
> path: packages/kiota_serialization_json
> ```
```bash
dart pub add kiota_serialization_json
```
1 change: 1 addition & 0 deletions packages/kiota_serialization_json/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include: package:strict/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/// This library implements deserialization for application/json responses.
///
/// This library is not meant to be used directly, but rather to be used as a
/// dependency in the generated code.
library kiota_serialization_json;

import 'dart:convert';
import 'dart:typed_data';

import 'package:kiota_abstractions/kiota_abstractions.dart';
import 'package:uuid/uuid_value.dart';

part 'src/json_parse_node.dart';
part 'src/json_parse_node_factory.dart';
part 'src/json_serialization_writer.dart';
part 'src/json_serialization_writer_factory.dart';
Loading

0 comments on commit 584b68c

Please sign in to comment.