Skip to content
Snippets Groups Projects
Commit 34ad729b authored by Klaus Fischer's avatar Klaus Fischer
Browse files

Added example schema

parent 2a9b6257
No related branches found
No related tags found
2 merge requests!58Issue/release preparation,!42Issue/872 check submission data schema
{
"$schema": "http://json-schema.org/draft-04/schema#",
"$id": "http://example.com/example.json",
"title": "Example Schema",
"description": "An example schema to play around with",
"type": "object",
"properties": {
"foo": {
"type": "string"
},
"bar": {
"type": "integer",
"minimum": 0
}
}
}
\ No newline at end of file
......@@ -22,6 +22,7 @@ public class Submission : SendableSubmission, ISubmissionBody {
public MetadataDto? Metadata { get; internal set; }
// public string? Data { get; internal set; }
public Uri? SchemaUri { get; set; }
public string? EncryptedMetadata { get; internal set; }
public string? EncryptedData { get; internal set; }
public string? MetaAuthentication => EncryptedMetadata?.Split('.').Last();
......
......@@ -100,7 +100,7 @@ public class Sender : FitConnectClient, ISender {
/// <exception cref="ArgumentNullException"></exception>
/// <exception cref="ArgumentException"></exception>
public async Task<SentSubmission> SendAsync(SendableEncryptedSubmission submission) {
SubmissionSenderGuards(submission);
await SubmissionSenderGuards(submission);
var sendable = await CreateSubmission(submission);
sendable.AddServiceType(submission.ServiceName!, submission.ServiceIdentifier!);
......@@ -298,6 +298,25 @@ public class Sender : FitConnectClient, ISender {
if (submission.Data == null)
throw new ArgumentNullException(nameof(SendableSubmission.Data));
if (new Regex(LeikaKeyPattern).IsMatch(submission.LeikaKey) == false)
throw new ArgumentException("The leika key is not valid");
var destination = await DestinationService.GetDestinationAsync(submission.DestinationId);
var leikaMatch = destination?.Services.Any(s => s.Identifier == submission.LeikaKey) ??
false;
if (!leikaMatch)
throw new ArgumentException("The leika key is not valid for the destination");
if (submission.SchemaUri == null)
return;
var schemaMatch = destination?.Services.Any(s =>
s.SubmissionSchemas.Any(schema =>
schema.SchemaUri == submission.SchemaUri.ToString())) ?? false;
if (!schemaMatch)
throw new ArgumentException("The schema uri is not valid for the destination");
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment