Skip to content

Commit 4da0fbf

Browse files
authored
Merge pull request #2115 from microsoft/dev
preview 6 release
2 parents 8943e2a + 50ddca2 commit 4da0fbf

File tree

364 files changed

+5172
-5042
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

364 files changed

+5172
-5042
lines changed

.azure-pipelines/ci-build.yml

+7-12
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ trigger:
88
- main
99
- dev
1010
- support/v1
11+
tags:
12+
include:
13+
- 'v*'
1114
pr:
1215
branches:
1316
include:
@@ -194,7 +197,7 @@ extends:
194197
content: '*.nupkg'
195198

196199
- stage: deploy
197-
condition: and(or(contains(variables['build.sourceBranch'], 'refs/heads/main'),contains(variables['build.sourceBranch'], 'refs/heads/support/v1')), succeeded())
200+
condition: and(contains(variables['build.sourceBranch'], 'refs/tags/v'), succeeded())
198201
dependsOn: build
199202
jobs:
200203
- deployment: deploy_hidi
@@ -305,18 +308,10 @@ extends:
305308
condition: succeededOrFailed()
306309
inputs:
307310
gitHubConnection: 'Github-MaggieKimani1'
308-
action: create
311+
action: edit
309312
tagSource: userSpecifiedTag
310-
tag: '$(artifactVersion)'
311-
title: '$(artifactVersion)'
313+
tag: 'v$(artifactVersion)'
312314
releaseNotesSource: inline
313315
assets: '$(Pipeline.Workspace)\**\*.exe'
314-
changeLogType: issueBased
315-
changeLogLabels: '[
316-
{ "label" : "feature-work", "feature", "displayName" : "New Features", "state" : "closed" },
317-
{ "label" : "enhancement", "V2-Enhancement", "displayName" : "Enhancements", "state" : "closed" },
318-
{ "label" : "bug", "bug-fix", "displayName" : "Bugs", "state" : "closed" },
319-
{ "label" : "documentation", "doc", "displayName" : "Documentation", "state" : "closed"},
320-
{ "label" : "dependencies", "displayName" : "Package Updates", "state" : "closed" }
321-
]'
316+
addChangeLog: false
322317

.config/1espt/PipelineAutobaseliningConfig.yml

+7
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,10 @@ pipelines:
1313
lastModifiedDate: 2024-09-13
1414
armory:
1515
lastModifiedDate: 2024-09-13
16+
binary:
17+
credscan:
18+
lastModifiedDate: 2025-01-27
19+
binskim:
20+
lastModifiedDate: 2025-01-27
21+
spotbugs:
22+
lastModifiedDate: 2025-01-27

.github/release-please.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
manifest: true
2+
primaryBranch: main
3+
handleGHRelease: true
4+
branches:
5+
- branch: support/v1
6+
manifest: true
7+
handleGHRelease: true

.github/workflows/auto-merge-dependabot.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
steps:
2020
- name: Dependabot metadata
2121
id: metadata
22-
uses: dependabot/fetch-metadata@v2.2.0
22+
uses: dependabot/fetch-metadata@v2.3.0
2323
with:
2424
github-token: "${{ secrets.GITHUB_TOKEN }}"
2525

.github/workflows/docker.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ jobs:
3030
id: getversion
3131
- name: Push to registry - Nightly
3232
if: ${{ github.ref == 'refs/heads/dev' }}
33-
uses: docker/build-push-action@v6.12.0
33+
uses: docker/build-push-action@v6.13.0
3434
with:
3535
push: true
3636
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly
3737
- name: Push to registry - Release
3838
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/support/v1' }}
39-
uses: docker/build-push-action@v6.12.0
39+
uses: docker/build-push-action@v6.13.0
4040
with:
4141
push: true
4242
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }}

.release-please-manifest.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "2.0.0-preview5"
3+
}

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+

CONTRIBUTING.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Contributing to OpenAPI.net
2+
3+
OpenAPI.net is a mono-repo containing source code for the following packages:
4+
5+
## Libraries
6+
7+
| Library | NuGet Release |
8+
|----------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
9+
| [Microsoft.OpenAPI](./src/Microsoft.OpenAPI/README.md) | [![NuGet Version](https://img.shields.io/nuget/vpre/Microsoft.OpenAPI?label=Latest&logo=nuget)](https://www.nuget.org/packages/Microsoft.OpenAPI/) |
10+
| [Microsoft.OpenAPI.Readers](./src/Microsoft.OpenAPI.Readers/README.md) | [![NuGet Version](https://img.shields.io/nuget/vpre/Microsoft.OpenAPI.Readers?label=Latest&logo=nuget)](https://www.nuget.org/packages/Microsoft.OpenAPI.Readers/) |
11+
| [Microsoft.OpenAPI.Hidi](./src/Microsoft.OpenAPI.Hidi/README.md) | [![NuGet Version](https://img.shields.io/nuget/vpre/Microsoft.OpenAPI.Hidi?label=Latest&logo=nuget)](https://www.nuget.org/packages/Microsoft.OpenAPI.Hidi/) |
12+
13+
OpenAPI.net is open to contributions. There are a couple of different recommended paths to get contributions into the released version of this library.
14+
15+
__NOTE__ A signed a contribution license agreement is required for all contributions, and is checked automatically on new pull requests. Please read and sign [the agreement](https://cla.microsoft.com/) before starting any work for this repository.
16+
17+
## File issues
18+
19+
The best way to get started with a contribution is to start a dialog with the owners of this repository. Sometimes features will be under development or out of scope for this SDK and it's best to check before starting work on contribution. Discussions on bugs and potential fixes could point you to the write change to make.
20+
21+
## Submit pull requests for bug fixes and features
22+
23+
Feel free to submit a pull request with a linked issue against the __main__ branch. The main branch will be updated frequently.
24+
## Commit message format
25+
26+
To support our automated release process, pull requests are required to follow the [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/)
27+
format.
28+
Each commit message consists of a __header__, an optional __body__ and an optional __footer__. The header is the first line of the commit and
29+
MUST have a __type__ (see below for a list of types) and a __description__. An optional __scope__ can be added to the header to give extra context.
30+
31+
```
32+
<type>[optional scope]: <short description>
33+
<BLANK LINE>
34+
<optional body>
35+
<BLANK LINE>
36+
<optional footer(s)>
37+
```
38+
39+
The recommended commit types used are:
40+
41+
- __feat__ for feature updates (increments the _minor_ version)
42+
- __fix__ for bug fixes (increments the _patch_ version)
43+
- __perf__ for performance related changes e.g. optimizing an algorithm
44+
- __refactor__ for code refactoring changes
45+
- __test__ for test suite updates e.g. adding a test or fixing a test
46+
- __style__ for changes that don't affect the meaning of code. e.g. formatting changes
47+
- __docs__ for documentation updates e.g. ReadMe update or code documentation updates
48+
- __build__ for build system changes (gradle updates, external dependency updates)
49+
- __ci__ for CI configuration file changes e.g. updating a pipeline
50+
- __chore__ for miscallaneous non-sdk changesin the repo e.g. removing an unused file
51+
52+
Adding an exclamation mark after the commit type (`feat!`) or footer with the prefix __BREAKING CHANGE:__ will cause an increment of the _major_ version.

Directory.Build.props

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<PackageProjectUrl>https://github.com/Microsoft/OpenAPI.NET</PackageProjectUrl>
1313
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
1414
<PackageTags>OpenAPI .NET</PackageTags>
15+
<Version>2.0.0-preview5</Version>
1516
</PropertyGroup>
1617
<!-- https://github.com/clairernovotny/DeterministicBuilds#deterministic-builds -->
1718
<PropertyGroup Condition="'$(TF_BUILD)' == 'true'">

release-please-config.json

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"bootstrap-sha": "8943e2ad40babb0204dedb11ad6f9273adf9cd53",
3+
"exclude-paths": [
4+
".azure-pipelines",
5+
".github",
6+
".idea",
7+
".vs",
8+
".vscode"
9+
],
10+
"release-type": "simple",
11+
"bump-minor-pre-major": true,
12+
"bump-patch-for-minor-pre-major": true,
13+
"include-component-in-tag": false,
14+
"include-v-in-tag": true,
15+
"draft": false,
16+
"prerelease": true,
17+
"versioning": "prerelease",
18+
"prerelease-type": "preview",
19+
"packages": {
20+
".": {
21+
"package-name": "Microsoft.OpenApi",
22+
"changelog-path": "CHANGELOG.md",
23+
"extra-files": [
24+
{
25+
"type": "xml",
26+
"path": "Directory.Build.props",
27+
"xpath": "//Project/PropertyGroup/Version"
28+
}
29+
]
30+
}
31+
},
32+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
33+
}

src/Microsoft.OpenApi.Hidi/Formatters/PowerShellFormatter.cs

+28-39
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Humanizer.Inflections;
88
using Microsoft.OpenApi.Hidi.Extensions;
99
using Microsoft.OpenApi.Models;
10+
using Microsoft.OpenApi.Models.Interfaces;
1011
using Microsoft.OpenApi.Services;
1112

1213
namespace Microsoft.OpenApi.Hidi.Formatters
@@ -15,7 +16,7 @@ internal class PowerShellFormatter : OpenApiVisitorBase
1516
{
1617
private const string DefaultPutPrefix = ".Update";
1718
private const string PowerShellPutPrefix = ".Set";
18-
private readonly Stack<OpenApiSchema> _schemaLoop = new();
19+
private readonly Stack<IOpenApiSchema> _schemaLoop = new();
1920
private static readonly Regex s_oDataCastRegex = new("(.*(?<=[a-z]))\\.(As(?=[A-Z]).*)", RegexOptions.Compiled, TimeSpan.FromSeconds(5));
2021
private static readonly Regex s_hashSuffixRegex = new(@"^[^-]+", RegexOptions.Compiled, TimeSpan.FromSeconds(5));
2122
private static readonly Regex s_oDataRefRegex = new("(?<=[a-z])Ref(?=[A-Z])", RegexOptions.Compiled, TimeSpan.FromSeconds(5));
@@ -41,7 +42,7 @@ static PowerShellFormatter()
4142
// 5. Fix anyOf and oneOf schema.
4243
// 6. Add AdditionalProperties to object schemas.
4344

44-
public override void Visit(OpenApiSchema schema)
45+
public override void Visit(IOpenApiSchema schema)
4546
{
4647
AddAdditionalPropertiesToSchema(schema);
4748
ResolveAnyOfSchema(schema);
@@ -50,7 +51,7 @@ public override void Visit(OpenApiSchema schema)
5051
base.Visit(schema);
5152
}
5253

53-
public override void Visit(OpenApiPathItem pathItem)
54+
public override void Visit(IOpenApiPathItem pathItem)
5455
{
5556
if (pathItem.Operations.TryGetValue(OperationType.Put, out var value) &&
5657
value.OperationId != null)
@@ -69,24 +70,24 @@ public override void Visit(OpenApiOperation operation)
6970

7071
var operationId = operation.OperationId;
7172
var operationTypeExtension = operation.Extensions?.GetExtension("x-ms-docs-operation-type");
72-
if (operationTypeExtension.IsEquals("function"))
73-
operation.Parameters = ResolveFunctionParameters(operation.Parameters ?? new List<OpenApiParameter>());
73+
if (operationTypeExtension.IsEquals("function") && operation.Parameters is { Count :> 0})
74+
ResolveFunctionParameters(operation.Parameters);
7475

7576
// Order matters. Resolve operationId.
7677
operationId = RemoveHashSuffix(operationId);
7778
if (operationTypeExtension.IsEquals("action") || operationTypeExtension.IsEquals("function"))
78-
operationId = RemoveKeyTypeSegment(operationId, operation.Parameters ?? new List<OpenApiParameter>());
79+
operationId = RemoveKeyTypeSegment(operationId, operation.Parameters ?? new List<IOpenApiParameter>());
7980
operationId = SingularizeAndDeduplicateOperationId(operationId.SplitByChar('.'));
8081
operationId = ResolveODataCastOperationId(operationId);
8182
operationId = ResolveByRefOperationId(operationId);
8283
// Verb segment resolution should always be last. user.get -> user_Get
83-
operationId = ResolveVerbSegmentInOpertationId(operationId);
84+
operationId = ResolveVerbSegmentInOperationId(operationId);
8485

8586
operation.OperationId = operationId;
8687
base.Visit(operation);
8788
}
8889

89-
private static string ResolveVerbSegmentInOpertationId(string operationId)
90+
private static string ResolveVerbSegmentInOperationId(string operationId)
9091
{
9192
var charPos = operationId.LastIndexOf('.', operationId.Length - 1);
9293
if (operationId.Contains('_', StringComparison.OrdinalIgnoreCase) || charPos < 0)
@@ -143,7 +144,7 @@ private static string RemoveHashSuffix(string operationId)
143144
return s_hashSuffixRegex.Match(operationId).Value;
144145
}
145146

146-
private static string RemoveKeyTypeSegment(string operationId, IList<OpenApiParameter> parameters)
147+
private static string RemoveKeyTypeSegment(string operationId, IList<IOpenApiParameter> parameters)
147148
{
148149
var segments = operationId.SplitByChar('.');
149150
foreach (var parameter in parameters)
@@ -157,30 +158,29 @@ private static string RemoveKeyTypeSegment(string operationId, IList<OpenApiPara
157158
return string.Join('.', segments);
158159
}
159160

160-
private static IList<OpenApiParameter> ResolveFunctionParameters(IList<OpenApiParameter> parameters)
161+
private static void ResolveFunctionParameters(IList<IOpenApiParameter> parameters)
161162
{
162-
foreach (var parameter in parameters.Where(static p => p.Content?.Any() ?? false))
163+
foreach (var parameter in parameters.OfType<OpenApiParameter>().Where(static p => p.Content?.Any() ?? false))
163164
{
164165
// Replace content with a schema object of type array
165166
// for structured or collection-valued function parameters
166167
parameter.Content = null;
167-
parameter.Schema = new()
168+
parameter.Schema = new OpenApiSchema()
168169
{
169170
Type = JsonSchemaType.Array,
170-
Items = new()
171+
Items = new OpenApiSchema()
171172
{
172173
Type = JsonSchemaType.String
173174
}
174175
};
175176
}
176-
return parameters;
177177
}
178178

179-
private void AddAdditionalPropertiesToSchema(OpenApiSchema schema)
179+
private void AddAdditionalPropertiesToSchema(IOpenApiSchema schema)
180180
{
181-
if (schema != null && !_schemaLoop.Contains(schema) && schema.Type.Equals(JsonSchemaType.Object))
181+
if (schema is OpenApiSchema openApiSchema && !_schemaLoop.Contains(schema) && schema.Type.Equals(JsonSchemaType.Object))
182182
{
183-
schema.AdditionalProperties = new() { Type = JsonSchemaType.Object };
183+
openApiSchema.AdditionalProperties = new OpenApiSchema() { Type = JsonSchemaType.Object };
184184

185185
/* Because 'additionalProperties' are now being walked,
186186
* we need a way to keep track of visited schemas to avoid
@@ -190,39 +190,29 @@ private void AddAdditionalPropertiesToSchema(OpenApiSchema schema)
190190
}
191191
}
192192

193-
private static void ResolveOneOfSchema(OpenApiSchema schema)
193+
private static void ResolveOneOfSchema(IOpenApiSchema schema)
194194
{
195-
if (schema.OneOf?.FirstOrDefault() is { } newSchema)
195+
if (schema is OpenApiSchema openApiSchema && schema.OneOf?.FirstOrDefault() is OpenApiSchema newSchema)
196196
{
197-
schema.OneOf = null;
198-
FlattenSchema(schema, newSchema);
197+
openApiSchema.OneOf = null;
198+
FlattenSchema(openApiSchema, newSchema);
199199
}
200200
}
201201

202-
private static void ResolveAnyOfSchema(OpenApiSchema schema)
202+
private static void ResolveAnyOfSchema(IOpenApiSchema schema)
203203
{
204-
if (schema.AnyOf?.FirstOrDefault() is { } newSchema)
204+
if (schema is OpenApiSchema openApiSchema && schema.AnyOf?.FirstOrDefault() is OpenApiSchema newSchema)
205205
{
206-
schema.AnyOf = null;
207-
FlattenSchema(schema, newSchema);
206+
openApiSchema.AnyOf = null;
207+
FlattenSchema(openApiSchema, newSchema);
208208
}
209209
}
210210

211211
private static void FlattenSchema(OpenApiSchema schema, OpenApiSchema newSchema)
212212
{
213-
if (newSchema != null)
214-
{
215-
if (newSchema.Reference != null)
216-
{
217-
schema.Reference = newSchema.Reference;
218-
schema.UnresolvedReference = true;
219-
}
220-
else
221-
{
222-
// Copies schema properties based on https://github.com/microsoft/OpenAPI.NET.OData/pull/264.
223-
CopySchema(schema, newSchema);
224-
}
225-
}
213+
if (newSchema is null) return;
214+
// Copies schema properties based on https://github.com/microsoft/OpenAPI.NET.OData/pull/264.
215+
CopySchema(schema, newSchema);
226216
}
227217

228218
private static void CopySchema(OpenApiSchema schema, OpenApiSchema newSchema)
@@ -253,7 +243,6 @@ private static void CopySchema(OpenApiSchema schema, OpenApiSchema newSchema)
253243
schema.Enum ??= newSchema.Enum;
254244
schema.ReadOnly = !schema.ReadOnly ? newSchema.ReadOnly : schema.ReadOnly;
255245
schema.WriteOnly = !schema.WriteOnly ? newSchema.WriteOnly : schema.WriteOnly;
256-
schema.Nullable = !schema.Nullable ? newSchema.Nullable : schema.Nullable;
257246
schema.Deprecated = !schema.Deprecated ? newSchema.Deprecated : schema.Deprecated;
258247
}
259248
}

src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
<Nullable>enable</Nullable>
1010
<ToolCommandName>hidi</ToolCommandName>
1111
<PackageOutputPath>./../../artifacts</PackageOutputPath>
12-
<Version>2.0.0-preview5</Version>
1312
<Description>OpenAPI.NET CLI tool for slicing OpenAPI documents</Description>
1413
<SignAssembly>true</SignAssembly>
1514
<!-- https://github.com/dotnet/sourcelink/blob/main/docs/README.md#embeduntrackedsources -->

0 commit comments

Comments
 (0)