-
Notifications
You must be signed in to change notification settings - Fork 58
Jtikekar/reverting nullables #353
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Revert DTO-nullables, Add Metadata-serializer
Revert nullables, Revert DTO-nullables, Add Metadata-serializer
epgrading to API version 3.0.2
Support for Metadata as per 3.0.2
Support for /submodel-elements and Get + $path
Support for $Path
|
|
||
| [XmlIgnore] | ||
| [JsonIgnore] | ||
| private DateTime[] _timeStamp = new DateTime[2]; |
Check notice
Code scanning / CodeQL
Missed 'readonly' opportunity
| JsonNode? json = MetadataJsonSerializer.ToJsonObject((IMetadataDTO)context.Object); | ||
| var writer = new Utf8JsonWriter(response.Body); | ||
| json.WriteTo(writer); | ||
| writer.FlushAsync().GetAwaiter().GetResult(); |
Check warning
Code scanning / CodeQL
Missing Dispose call on local IDisposable
| var json = MetadataJsonSerializer.ToJsonObject(item); | ||
| jsonArray.Add(json); | ||
| } | ||
| } | ||
| JsonObject jsonNode = new JsonObject(); |
Check notice
Code scanning / CodeQL
Missed opportunity to use Select
| jsonNode["paging_metadata"] = pagingMetadata; | ||
| var writer = new Utf8JsonWriter(response.Body); | ||
| jsonNode.WriteTo(writer); | ||
| writer.FlushAsync().GetAwaiter().GetResult(); |
Check warning
Code scanning / CodeQL
Missing Dispose call on local IDisposable
| } | ||
| var writer = new Utf8JsonWriter(response.Body); | ||
| jsonNode.WriteTo(writer); | ||
| writer.FlushAsync().GetAwaiter().GetResult(); |
Check warning
Code scanning / CodeQL
Missing Dispose call on local IDisposable
src/IO.Swagger.Lib.V3/SerializationModifiers/LevelExtent/LevelExtentTransformer.cs
Fixed
Show fixed
Hide fixed
| var valueNode = JsonSerializer.Deserialize<JsonNode>(valueString); | ||
| valueArray.Add(valueNode); | ||
| } | ||
| var elementNode = ToJsonObject(element, true) as JsonNode; |
Check warning
Code scanning / CodeQL
Cast to same type
| return valueObject; | ||
| } | ||
|
|
||
| if (isParentSML) |
Check warning
Code scanning / CodeQL
Constant condition
| var context = new LevelExtentModifierContext(level, extent); | ||
| return that.Select(source => source != null ? _transformer.Transform(source, context) : null).ToList(); | ||
| private readonly IAppLogger<LevelExtentModifierService> _logger; | ||
| LevelExtentTransformer _transformer; |
Check notice
Code scanning / CodeQL
Missed 'readonly' opportunity
| [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] | ||
| [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] | ||
| public virtual IActionResult GetAllSubmodelDescriptorsThroughSuperpath([FromRoute] [Required] string aasIdentifier, | ||
| public virtual IActionResult GetAllSubmodelDescriptorsThroughSuperpath([FromRoute] [Required] string? aasIdentifier, |
Check failure
Code scanning / CodeQL
Missing function level access control
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI about 1 year ago
To fix the issue, we need to add an authorization check to the GetAllSubmodelDescriptorsThroughSuperpath method. The best way to do this in an ASP.NET Core MVC application is to use the [Authorize] attribute, which ensures that only authenticated users can access the method. If specific roles are required, we can specify them within the attribute.
- Add the
[Authorize]attribute to theGetAllSubmodelDescriptorsThroughSuperpathmethod. - Ensure that the necessary imports for authorization are present.
-
Copy modified line R217
| @@ -216,2 +216,3 @@ | ||
| [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] | ||
| [Authorize] | ||
| public virtual IActionResult GetAllSubmodelDescriptorsThroughSuperpath([FromRoute] [Required] string? aasIdentifier, |
|
|
|
Added copyright headers. |
Change in incorrect level and extent handling
| aasList = output.Where(a => a.AssetInformation.SpecificAssetIds.ContainsSpecificAssetId(assetId)).ToList(); | ||
| var result = new List<IAssetAdministrationShell>(); | ||
| if (!string.IsNullOrEmpty(assetId.Name)) | ||
| { |
Check warning
Code scanning / CodeQL
Useless assignment to local variable
| result = output.Where(a => a.AssetInformation.GlobalAssetId!.Equals(assetId.Value)).ToList(); | ||
| } | ||
| else | ||
| { | ||
| result = output.Where(a => a.AssetInformation.SpecificAssetIds!.ContainsSpecificAssetId(assetId)).ToList(); | ||
| } | ||
| } | ||
| else |
Check notice
Code scanning / CodeQL
Missed ternary opportunity
| ( | ||
| InoutputArguments == other.InoutputArguments || | ||
| InoutputArguments != null && | ||
| InoutputArguments.Equals(other.InoutputArguments) | ||
| ) && | ||
| ( | ||
| InputArguments == other.InputArguments || | ||
| InputArguments != null && | ||
| InputArguments.Equals(other.InputArguments) | ||
| ) && | ||
| ( | ||
| ClientTimeoutDuration == other.ClientTimeoutDuration || | ||
| ClientTimeoutDuration != null && | ||
| ClientTimeoutDuration.Equals(other.ClientTimeoutDuration) | ||
| ); |
Check notice
Code scanning / CodeQL
Complex condition
| if (InoutputArguments != null) | ||
| hashCode = hashCode * 59 + InoutputArguments.GetHashCode(); |
Check warning
Code scanning / CodeQL
Misleading indentation
| if (InputArguments != null) | ||
| hashCode = hashCode * 59 + InputArguments.GetHashCode(); |
Check warning
Code scanning / CodeQL
Misleading indentation
| if (InoutputArguments != null) | ||
| hashCode = hashCode * 59 + InoutputArguments.GetHashCode(); |
Check warning
Code scanning / CodeQL
Misleading indentation
| catch (Exception e) | ||
| { | ||
| throw new InvalidSerializationModifierException("extent"); | ||
| } |
Check notice
Code scanning / CodeQL
Generic catch clause
| { | ||
| result = Enum.Parse<ExtentEnum>(extent, true); | ||
| } | ||
| catch (Exception e) |
Check warning
Code scanning / CodeQL
Useless assignment to local variable
| catch(Exception e) | ||
| { | ||
| throw new InvalidSerializationModifierException("level"); | ||
| } |
Check notice
Code scanning / CodeQL
Generic catch clause
| { | ||
| result = Enum.Parse<LevelEnum>(level, true); | ||
| } | ||
| catch(Exception e) |
Check warning
Code scanning / CodeQL
Useless assignment to local variable
| [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] | ||
| public virtual IActionResult GetDescription() | ||
| { | ||
| var output = new ServiceDescription(); |
Check warning
Code scanning / CodeQL
Useless assignment to local variable
| var sb = new StringBuilder(); | ||
| sb.Append("class ServiceDescription {\n"); | ||
| sb.Append(" Profiles: ").Append(Profiles).Append('\n'); | ||
| sb.Append(" Profiles: ").Append(profiles).Append('\n'); |
Check warning
Code scanning / CodeQL
Use of default ToString()
| var reqIsCaseOf = _jsonQueryDeserializer.DeserializeReference("isCaseOf", isCaseOf); | ||
| var reqDataSpecificationRef = _jsonQueryDeserializer.DeserializeReference("dataSpecificationRef", dataSpecificationRef); | ||
|
|
||
| var cdList = new List<IConceptDescription>(); |
Check warning
Code scanning / CodeQL
Useless assignment to local variable
| //Using is null or empty, as the query parameter in controll currently receives empty list (not null, but count = 0) | ||
| if (submodelIds.IsNullOrEmpty()) | ||
| if (!submodelIds.IsNullOrEmpty()) | ||
| { |
Check warning
Code scanning / CodeQL
Dereferenced variable may be null
|
|
||
|
|
||
| if((bool)includeCD) | ||
| { |
Check warning
Code scanning / CodeQL
Dereferenced variable may be null
Revert nullables, Revert DTO-nullables, Add Metadata-serializer
Upgrading to API version 3.0.2
Remove child elements from MetadataDTOs (3.0.2)
Support for Metadata as per 3.0.2
Support for /submodel-elements and Get + $path
Support for $Path
Change in incorrect level and extent handling
…n-shell-io/aasx-server into jtikekar/revertingNullables
Description
Upgrading the AAS Repo APIs to BugFix Version 3.0.2 and fixing the broken Get APIs.
Motivation and Context
Due to refactoring lot of APIs have stopped working. Thus, fixing the API step by step also upgrading the APIs to the latest BugFix Version.
Fixes # (issue)
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
The APIs have been tested manually and with the aas-test-engine.
Screenshots (if appropriate):
Checklist: