Skip to content

Commit

Permalink
Add workaround for RicoSuter/NSwag#4681
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollo3zehn committed Mar 2, 2024
1 parent e1e25e3 commit 3147fe8
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion openapi.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"x-generator": "NSwag v13.18.2.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v13.0.0.0))",
"x-generator": "NSwag v14.0.3.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))",
"openapi": "3.0.0",
"info": {
"title": "Nexus REST API",
Expand Down
4 changes: 4 additions & 0 deletions src/Nexus/Core/Models_Public.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,12 @@ public RefreshToken(Guid id, string token, DateTime expires, string description)
/// </summary>
public string Description { get; init; }

[JsonIgnore]
#warning Remove this when https://github.com/RicoSuter/NSwag/issues/4681 is solved
internal bool IsExpired => DateTime.UtcNow >= Expires;

[JsonIgnore]
#warning Remove this when https://github.com/RicoSuter/NSwag/issues/4681 is solved
internal InternalRefreshToken InternalRefreshToken { get; }

#pragma warning disable CS1591
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ public IReadOnlyDictionary<string, JsonElement>? Parameters
/// <summary>
/// The representation kind.
/// </summary>
[JsonIgnore]
#warning Remove this when https://github.com/RicoSuter/NSwag/issues/4681 is solved
internal RepresentationKind Kind { get; }

/// <summary>
Expand Down
7 changes: 7 additions & 0 deletions src/extensibility/dotnet-extensibility/DataModel/Resource.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Diagnostics;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;

namespace Nexus.DataModel
Expand Down Expand Up @@ -43,16 +44,22 @@ public Resource(
/// <summary>
/// Gets a regular expression to validate a resource identifier.
/// </summary>
[JsonIgnore]
#warning Remove this when https://github.com/RicoSuter/NSwag/issues/4681 is solved
public static Regex ValidIdExpression { get; } = new Regex(@"^[a-zA-Z_][a-zA-Z_0-9]*$");

/// <summary>
/// Gets a regular expression to find invalid characters in a resource identifier.
/// </summary>
[JsonIgnore]
#warning Remove this when https://github.com/RicoSuter/NSwag/issues/4681 is solved
public static Regex InvalidIdCharsExpression { get; } = new Regex(@"[^a-zA-Z_0-9]", RegexOptions.Compiled);

/// <summary>
/// Gets a regular expression to find invalid start characters in a resource identifier.
/// </summary>
[JsonIgnore]
#warning Remove this when https://github.com/RicoSuter/NSwag/issues/4681 is solved
public static Regex InvalidIdStartCharsExpression { get; } = new Regex(@"^[^a-zA-Z_]+", RegexOptions.Compiled);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;

namespace Nexus.DataModel
Expand Down Expand Up @@ -45,8 +46,12 @@ public ResourceCatalog(
/// <summary>
/// Gets a regular expression to validate a resource catalog identifier.
/// </summary>
[JsonIgnore]
#warning Remove this when https://github.com/RicoSuter/NSwag/issues/4681 is solved
public static Regex ValidIdExpression { get; } = new Regex(@"^(?:\/[a-zA-Z_][a-zA-Z_0-9]*)+$", RegexOptions.Compiled);

[JsonIgnore]
#warning Remove this when https://github.com/RicoSuter/NSwag/issues/4681 is solved
private static Regex _matchSingleParametersExpression { get; } = new Regex(@"\s*(.+?)\s*=\s*([^,\)]+)\s*,?", RegexOptions.Compiled);

/// <summary>
Expand Down

0 comments on commit 3147fe8

Please sign in to comment.