Skip to content

Commit b002225

Browse files
committed
Merge branch 'main' into dependabot/nuget/PublicApiGenerator-11.4.1
2 parents 55e10fe + 4a6547d commit b002225

File tree

234 files changed

+3080
-2703
lines changed

Some content is hidden

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

234 files changed

+3080
-2703
lines changed

.azure-pipelines/ci-build.yml

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,14 @@ trigger:
66
branches:
77
include:
88
- main
9-
- dev
109
- support/v1
10+
tags:
11+
include:
12+
- 'v*'
1113
pr:
1214
branches:
1315
include:
1416
- main
15-
- dev
1617
- support/v1
1718
variables:
1819
buildPlatform: 'Any CPU'
@@ -194,7 +195,7 @@ extends:
194195
content: '*.nupkg'
195196

196197
- stage: deploy
197-
condition: and(or(contains(variables['build.sourceBranch'], 'refs/heads/main'),contains(variables['build.sourceBranch'], 'refs/heads/support/v1')), succeeded())
198+
condition: and(contains(variables['build.sourceBranch'], 'refs/tags/v'), succeeded())
198199
dependsOn: build
199200
jobs:
200201
- deployment: deploy_hidi
@@ -305,18 +306,10 @@ extends:
305306
condition: succeededOrFailed()
306307
inputs:
307308
gitHubConnection: 'Github-MaggieKimani1'
308-
action: create
309+
action: edit
309310
tagSource: userSpecifiedTag
310-
tag: '$(artifactVersion)'
311-
title: '$(artifactVersion)'
311+
tag: 'v$(artifactVersion)'
312312
releaseNotesSource: inline
313313
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-
]'
314+
addChangeLog: false
322315

.github/release-please.yml

Lines changed: 7 additions & 0 deletions
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/codeql-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: CodeQL Analysis
22

33
on:
44
push:
5-
branches: [ main, dev ]
5+
branches: [ main, support/v1 ]
66
pull_request:
77
schedule:
88
- cron: '0 8 * * *'

.github/workflows/docker.yml

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ name: Publish Docker image
22
on:
33
workflow_dispatch:
44
push:
5-
branches: [main, dev, support/v1]
6-
paths: ['src/Microsoft.OpenApi.Hidi/**', '.github/workflows/**']
5+
tags: ["v*"]
6+
branches: [main]
7+
pull_request:
78
env:
89
REGISTRY: msgraphprod.azurecr.io
910
IMAGE_NAME: public/openapi/hidi
11+
PREVIEW_BRANCH: "refs/heads/main"
1012
jobs:
1113
push_to_registry:
1214
environment:
@@ -28,14 +30,24 @@ jobs:
2830
echo "::set-output name=version::${version}"
2931
shell: pwsh
3032
id: getversion
33+
- name: Get truncated run number
34+
if: contains(github.ref, env.PREVIEW_BRANCH)
35+
id: runnumber
36+
run: echo "runnumber=$(echo ${{ github.run_number }} | awk '{ print substr($0, length($0)-3, length($0)) }')" >> $GITHUB_OUTPUT
37+
- name: Get current date
38+
if: contains(github.ref, env.PREVIEW_BRANCH)
39+
id: date
40+
run: echo "date=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT
3141
- name: Push to registry - Nightly
32-
if: ${{ github.ref == 'refs/heads/dev' }}
42+
if: contains(github.ref, env.PREVIEW_BRANCH)
3343
uses: docker/build-push-action@v6.13.0
3444
with:
3545
push: true
36-
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly
46+
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:nightly,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.getversion.outputs.version }}-preview.${{ steps.date.outputs.date }}${{ steps.runnumber.outputs.runnumber }}
47+
build-args: |
48+
version_suffix=preview.${{ steps.date.outputs.date }}${{ steps.runnumber.outputs.runnumber }}
3749
- name: Push to registry - Release
38-
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/support/v1' }}
50+
if: contains(github.ref, 'refs/tags/v')
3951
uses: docker/build-push-action@v6.13.0
4052
with:
4153
push: true

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "2.0.0-preview7"
3+
}

CHANGELOG.md

Lines changed: 153 additions & 0 deletions
Large diffs are not rendered by default.

CONTRIBUTING.md

Lines changed: 52 additions & 0 deletions
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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@
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-preview7</Version>
1516
</PropertyGroup>
1617
<!-- https://github.com/clairernovotny/DeterministicBuilds#deterministic-builds -->
1718
<PropertyGroup Condition="'$(TF_BUILD)' == 'true'">
1819
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
1920
</PropertyGroup>
2021
<ItemGroup>
21-
<PackageReference
22-
Condition="!$(MSBuildProjectName.EndsWith('Tests'))"
23-
Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>
22+
<PackageReference Condition="!$(MSBuildProjectName.EndsWith('Tests'))" Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All"/>
2423
</ItemGroup>
2524
</Project>

release-please-config.json

Lines changed: 33 additions & 0 deletions
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

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ internal class PowerShellFormatter : OpenApiVisitorBase
1616
{
1717
private const string DefaultPutPrefix = ".Update";
1818
private const string PowerShellPutPrefix = ".Set";
19-
private readonly Stack<OpenApiSchema> _schemaLoop = new();
19+
private readonly Stack<IOpenApiSchema> _schemaLoop = new();
2020
private static readonly Regex s_oDataCastRegex = new("(.*(?<=[a-z]))\\.(As(?=[A-Z]).*)", RegexOptions.Compiled, TimeSpan.FromSeconds(5));
2121
private static readonly Regex s_hashSuffixRegex = new(@"^[^-]+", RegexOptions.Compiled, TimeSpan.FromSeconds(5));
2222
private static readonly Regex s_oDataRefRegex = new("(?<=[a-z])Ref(?=[A-Z])", RegexOptions.Compiled, TimeSpan.FromSeconds(5));
@@ -42,7 +42,7 @@ static PowerShellFormatter()
4242
// 5. Fix anyOf and oneOf schema.
4343
// 6. Add AdditionalProperties to object schemas.
4444

45-
public override void Visit(OpenApiSchema schema)
45+
public override void Visit(IOpenApiSchema schema)
4646
{
4747
AddAdditionalPropertiesToSchema(schema);
4848
ResolveAnyOfSchema(schema);
@@ -165,22 +165,22 @@ private static void ResolveFunctionParameters(IList<IOpenApiParameter> parameter
165165
// Replace content with a schema object of type array
166166
// for structured or collection-valued function parameters
167167
parameter.Content = null;
168-
parameter.Schema = new()
168+
parameter.Schema = new OpenApiSchema()
169169
{
170170
Type = JsonSchemaType.Array,
171-
Items = new()
171+
Items = new OpenApiSchema()
172172
{
173173
Type = JsonSchemaType.String
174174
}
175175
};
176176
}
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
}

0 commit comments

Comments
 (0)