diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml
new file mode 100644
index 0000000000..8df0bcd307
--- /dev/null
+++ b/.azure-pipelines/ci-build.yml
@@ -0,0 +1,299 @@
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License.
+
+name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)$(Rev:.r)
+
+trigger:
+ tags:
+ include:
+ - v*
+
+pool:
+ name: Azure Pipelines
+ vmImage: windows-latest
+
+variables:
+ buildPlatform: 'Any CPU'
+ buildConfiguration: 'Release'
+ ProductBinPath: '$(Build.SourcesDirectory)\src\kiota\bin\$(BuildConfiguration)'
+
+
+stages:
+
+- stage: build
+ jobs:
+ - job: build
+ steps:
+ - task: UseDotNet@2
+ displayName: 'Use .NET 6'
+ inputs:
+ version: 6.x
+
+ - task: PoliCheck@1
+ displayName: 'Run PoliCheck "/src"'
+ inputs:
+ inputType: CmdLine
+ cmdLineArgs: '/F:$(Build.SourcesDirectory)/src /T:9 /Sev:"1|2" /PE:2 /O:poli_result_src.xml'
+
+ - task: PoliCheck@1
+ displayName: 'Run PoliCheck "/tests"'
+ inputs:
+ inputType: CmdLine
+ cmdLineArgs: '/F:$(Build.SourcesDirectory)/tests /T:9 /Sev:"1|2" /PE:2 /O:poli_result_test.xml'
+
+ # Install the nuget tool.
+ - task: NuGetToolInstaller@0
+ displayName: 'Use NuGet >=6.1.0'
+ inputs:
+ versionSpec: '>=6.1.0'
+ checkLatest: true
+
+ # Build the Product project
+ - task: DotNetCoreCLI@2
+ displayName: 'build'
+ inputs:
+ projects: '$(Build.SourcesDirectory)\kiota.sln'
+ arguments: '--configuration $(BuildConfiguration) --no-incremental'
+
+ # Run the Unit test
+ - task: DotNetCoreCLI@2
+ displayName: 'test'
+ inputs:
+ command: test
+ projects: '$(Build.SourcesDirectory)\kiota.sln'
+ arguments: '--configuration $(BuildConfiguration) --no-build'
+
+ # CredScan
+ - task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2
+ displayName: 'Run CredScan - Src'
+ inputs:
+ toolMajorVersion: 'V2'
+ scanFolder: '$(Build.SourcesDirectory)\src'
+ debugMode: false
+
+ - task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2
+ displayName: 'Run CredScan - Tests'
+ inputs:
+ toolMajorVersion: 'V2'
+ scanFolder: '$(Build.SourcesDirectory)\tests'
+ debugMode: false
+
+ - task: AntiMalware@3
+ displayName: 'Run MpCmdRun.exe - ProductBinPath'
+ inputs:
+ FileDirPath: '$(ProductBinPath)'
+ enabled: false
+
+ - task: BinSkim@3
+ displayName: 'Run BinSkim - Product Binaries'
+ inputs:
+ InputType: Basic
+ AnalyzeTarget: '$(ProductBinPath)\**\kiota.dll'
+ AnalyzeSymPath: '$(ProductBinPath)'
+ AnalyzeVerbose: true
+ AnalyzeHashes: true
+ AnalyzeEnvironment: true
+
+ - task: PublishSecurityAnalysisLogs@2
+ displayName: 'Publish Security Analysis Logs'
+ inputs:
+ ArtifactName: SecurityLogs
+
+ - task: PostAnalysis@1
+ displayName: 'Post Analysis'
+ inputs:
+ BinSkim: true
+ CredScan: true
+ PoliCheck: true
+
+ - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
+ displayName: 'ESRP CodeSigning'
+ inputs:
+ ConnectedServiceName: 'microsoftgraph ESRP CodeSign DLL and NuGet (AKV)'
+ FolderPath: src
+ signConfigType: inlineSignParams
+ inlineOperation: |
+ [
+ {
+ "keyCode": "CP-230012",
+ "operationSetCode": "SigntoolSign",
+ "parameters": [
+ {
+ "parameterName": "OpusName",
+ "parameterValue": "Microsoft"
+ },
+ {
+ "parameterName": "OpusInfo",
+ "parameterValue": "http://www.microsoft.com"
+ },
+ {
+ "parameterName": "FileDigest",
+ "parameterValue": "/fd \"SHA256\""
+ },
+ {
+ "parameterName": "PageHash",
+ "parameterValue": "/NPH"
+ },
+ {
+ "parameterName": "TimeStamp",
+ "parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256"
+ }
+ ],
+ "toolName": "sign",
+ "toolVersion": "1.0"
+ },
+ {
+ "keyCode": "CP-230012",
+ "operationSetCode": "SigntoolVerify",
+ "parameters": [ ],
+ "toolName": "sign",
+ "toolVersion": "1.0"
+ }
+ ]
+ SessionTimeout: 20
+
+ # Pack
+ - pwsh: dotnet pack $(Build.SourcesDirectory)/src/kiota/kiota.csproj -o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg
+ displayName: 'pack kiota'
+
+ # Pack
+ - pwsh: nuget pack $(Build.SourcesDirectory)/src/Microsoft.OpenApi.Kiota.ApiDescription.Client/Microsoft.OpenApi.Kiota.ApiDescription.Client.nuspec -OutputDirectory $(Build.ArtifactStagingDirectory)
+ displayName: 'pack targets'
+
+ - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1
+ displayName: 'ESRP CodeSigning Nuget Packages'
+ inputs:
+ ConnectedServiceName: 'microsoftgraph ESRP CodeSign DLL and NuGet (AKV)'
+ FolderPath: '$(Build.ArtifactStagingDirectory)'
+ Pattern: '*.nupkg'
+ signConfigType: inlineSignParams
+ inlineOperation: |
+ [
+ {
+ "keyCode": "CP-401405",
+ "operationSetCode": "NuGetSign",
+ "parameters": [ ],
+ "toolName": "sign",
+ "toolVersion": "1.0"
+ },
+ {
+ "keyCode": "CP-401405",
+ "operationSetCode": "NuGetVerify",
+ "parameters": [ ],
+ "toolName": "sign",
+ "toolVersion": "1.0"
+ }
+ ]
+ SessionTimeout: 20
+
+ - task: PowerShell@2
+ displayName: "Get Kiota's version-number from .csproj"
+ inputs:
+ targetType: 'inline'
+ script: |
+ $xml = [Xml] (Get-Content .\src\kiota\kiota.csproj)
+ $version = $xml.Project.PropertyGroup.Version
+ echo $version
+ echo "##vso[task.setvariable variable=kiotaversion]$version"
+
+ # publish kiota as an .exe
+ - pwsh: dotnet publish src/kiota/kiota.csproj -c Release --runtime win-x64 /p:PublishSingleFile=true --self-contained --output $(Build.ArtifactStagingDirectory)/kiota-v$(kiotaversion)
+ displayName: publish kiota as executable
+
+ - task: CopyFiles@2
+ displayName: Prepare staging folder for upload
+ inputs:
+ targetFolder: $(Build.ArtifactStagingDirectory)/Nugets
+ sourceFolder: $(Build.ArtifactStagingDirectory)
+ content: '*.nupkg'
+
+ - task: PublishBuildArtifacts@1
+ displayName: 'Publish Artifact: Nugets'
+ inputs:
+ ArtifactName: Nugets
+ PathtoPublish: '$(Build.ArtifactStagingDirectory)/Nugets'
+
+ - task: PublishBuildArtifacts@1
+ displayName: 'Publish Artifact: Kiota'
+ inputs:
+ ArtifactName: Kiota-v$(kiotaversion)
+ PathtoPublish: '$(Build.ArtifactStagingDirectory)/Kiota-v$(kiotaversion)'
+
+- stage: deploy
+ condition: and(contains(variables['build.sourceBranch'], 'refs/tags/v'), succeeded())
+ dependsOn: build
+ jobs:
+ - deployment: deploy_kiota
+ dependsOn: []
+ environment: nuget-org
+ strategy:
+ runOnce:
+ deploy:
+ pool:
+ vmImage: ubuntu-latest
+ steps:
+ - task: DownloadPipelineArtifact@2
+ displayName: Download nupkg from artifacts
+ inputs:
+ artifact: Nugets
+ source: current
+ - task: DownloadPipelineArtifact@2
+ displayName: Download kiota executable from artifacts
+ inputs:
+ source: current
+ - powershell: |
+ rm "$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Kiota.ApiDescription.*.nupkg" -Verbose
+ displayName: remove other nupkgs to avoid duplication
+ # - pwsh: |
+ # $artifactName = Get-ChildItem -Path $(Pipeline.Workspace)\Nugets -Filter Microsoft.OpenApi.Kiota.*.nupkg -recurse | select -First 1
+ # $artifactVersion= $artifactName.Name -replace "Microsoft.OpenApi.Kiota.", "" -replace ".nupkg", ""
+ # #Set Variable $artifactName and $artifactVersion
+ # Write-Host "##vso[task.setvariable variable=artifactVersion; isSecret=false; isOutput=true]$artifactVersion"
+ # Write-Host "##vso[task.setvariable variable=artifactName; isSecret=false; isOutput=true]$artifactName.FullName"
+ # echo "$artifactName"
+ # echo "$artifactVersion"
+ # displayName: 'Fetch Artifact Name'
+
+ - task: NuGetCommand@2
+ displayName: 'NuGet push'
+ inputs:
+ command: push
+ packagesToPush: '$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Kiota.*.nupkg'
+ nuGetFeedType: external
+ publishFeedCredentials: 'OpenAPI Nuget Connection'
+ # - task: GitHubRelease@1
+ # displayName: 'GitHub release (create)'
+ # inputs:
+ # gitHubConnection: 'Github-MaggieKimani1'
+ # tagSource: userSpecifiedTag
+ # tag: '$(artifactVersion)'
+ # title: '$(artifactVersion)'
+ # releaseNotesSource: inline
+ # assets: '$(Pipeline.Workspace)\**\*.exe'
+ # changeLogType: issueBased
+
+ - deployment: deploy_targets
+ dependsOn: []
+ environment: nuget-org
+ strategy:
+ runOnce:
+ deploy:
+ pool:
+ vmImage: ubuntu-latest
+ steps:
+ - task: DownloadPipelineArtifact@2
+ displayName: Download nupkg from artifacts
+ inputs:
+ artifact: Nugets
+ source: current
+ - powershell: |
+ rm "$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Kiota.*.nupkg" -Verbose -Exclude "*.ApiDescription.*"
+ displayName: remove other nupkgs to avoid duplication
+ - task: NuGetCommand@2
+ displayName: 'NuGet push'
+ inputs:
+ command: push
+ packagesToPush: '$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Kiota.ApiDescription.*.nupkg'
+ nuGetFeedType: external
+ publishFeedCredentials: 'OpenAPI Nuget Connection'
+
diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml
index 3ec25f3e1d..51679c19c8 100644
--- a/.github/workflows/docker.yml
+++ b/.github/workflows/docker.yml
@@ -6,13 +6,13 @@ on:
tags: ['v*']
paths: ['src/**', '.github/workflows/**']
env:
- REGISTRY: ghcr.io
- IMAGE_NAME: ${{ github.repository }}/generator
+ REGISTRY: msgraphprod.azurecr.io
+ IMAGE_NAME: public/${{ github.repository }}/generator
jobs:
push_to_registry:
environment:
- name: staging_feeds
- name: Push Docker image to GitHub Packages
+ name: acr
+ name: Push Docker image
runs-on: ubuntu-latest
steps:
- name: Check out the repo
@@ -20,8 +20,8 @@ jobs:
- name: Login to GitHub package feed
uses: docker/login-action@v1.14.1
with:
- username: ${{ github.actor }}
- password: ${{ secrets.GITHUB_TOKEN }}
+ username: ${{ secrets.ACR_USERNAME }}
+ password: ${{ secrets.ACR_PASSWORD }}
registry: ${{ env.REGISTRY }}
- run: |
$version = $Env:BRANCH_NAME -replace "refs/tags/v",""
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6c91224409..91cf507be2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
+### [0.1.0] - 2022-05-04
+
+### Added
+
+- The dotnet tool is now available on the public feed `dotnet tool install -g Microsoft.OpenApi.Kiota --prerelease`.
+- The dotnet OpenApi reference package is now available `Microsoft.OpenApi.Kiota.ApiDescription.Client`.
+- The container image is now available on mcr. `docker pull mcr.microsoft.com/kiota/generator:latest`.
+
+### Changed
+
- Revamped the api surface for request configuration. [#1494](https://github.com/microsoft/kiota/issues/1494)
- Fixed a bug in methods naming in Go after request configuration revamp.
- Fixes a bug where reserved names would not be updated for inheritance.
diff --git a/Dockerfile b/Dockerfile
index 8daa68a81f..3d658520c0 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -14,5 +14,5 @@ VOLUME /app/output
VOLUME /app/openapi.yml
ENTRYPOINT ["dotnet", "kiota.dll"]
LABEL description="# Welcome to Kiota Generator \
-To start generating SDKs checkout [the getting started documentation](https://github.com/microsoft/kiota/#running-kiota-with-docker) \
-[Source dockerfile](https://github.com/microsoft/kiota/blob/main/releases/Dockerfile)"
\ No newline at end of file
+To start generating SDKs checkout [the getting started documentation](https://microsoft.github.io/kiota/get-started/#run-in-docker) \
+[Source dockerfile](https://github.com/microsoft/kiota/blob/main/Dockerfile)"
\ No newline at end of file
diff --git a/docs/get-started/dotnet.md b/docs/get-started/dotnet.md
index 5f81b3327b..9847f22cb6 100644
--- a/docs/get-started/dotnet.md
+++ b/docs/get-started/dotnet.md
@@ -10,7 +10,7 @@ parent: Get started
## Target project requirements
-Before you can compile and run the generated files, you will need to make sure they are part of a project with the required dependencies. After creating a new project, or reusing an existing one, you will need to add references to the [abstraction](https://github.com/microsoft/kiota/tree/main/abstractions/dotnet), [authentication](https://github.com/microsoft/kiota/tree/main/authentication/dotnet/azure), [http](https://github.com/microsoft/kiota/tree/main/http/dotnet/httpclient), and [serialization](https://github.com/microsoft/kiota/tree/main/serialization/dotnet/json) packages from the GitHub feed.
+Before you can compile and run the generated files, you will need to make sure they are part of a project with the required dependencies. After creating a new project, or reusing an existing one, you will need to add references to the [abstraction](https://github.com/microsoft/kiota-abstractions-dotnet), [authentication](https://github.com/microsoft/kiota-authentication-azure-dotnet), [http](https://github.com/microsoft/kiota-http-dotnet), and [JSON](https://github.com/microsoft/kiota-serialization-json-dotnet) and [text](https://github.com/microsoft/kiota-serialization-text-dotnet) serialization packages from the GitHub feed.
## Creating target projects
diff --git a/docs/get-started/index.md b/docs/get-started/index.md
index e161d08a57..1921d7d995 100644
--- a/docs/get-started/index.md
+++ b/docs/get-started/index.md
@@ -21,39 +21,12 @@ You can download the latest version from the [releases page](https://github.com/
If you have the [.NET SDK](https://dotnet.microsoft.com/download) installed, you can install Kiota as a [.NET tool](https://docs.microsoft.com/dotnet/core/tools/global-tools).
-### Configure NuGet to access GitHub
-
-Before you can install Kiota as a .NET tool you need to create a NuGet configuration file to access the authenticated GitHub package feed. The following steps show you how to create this file. **This is a temporary step until we publish the Kiota tool to the public NuGet feed.**
-
-1. Navigate to [New personal access token](https://github.com/settings/tokens/new) and generate a new token. (permissions: `package:read`, `repo`).
-1. Copy the token, you will need it later.
-1. Enable the SSO on the token if you are a Microsoft employee.
-1. Create a `nuget.config` file in the current directory with the following content.
-
- ```xml
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ```
-
-### Install the .NET tool
+## Install the .NET tool
Execute the following command to install the tool.
```shell
-dotnet tool install --global --configfile nuget.config kiota
+dotnet tool install --global --prerelease Microsoft.OpenApi.Kiota
```
## Run in Docker
@@ -63,7 +36,7 @@ You can run Kiota in our Docker container with one of the following commands.
```shell
docker run -v /some/output/path:/app/output \
-v /some/input/description.yml:/app/openapi.yml \
-ghcr.io/microsoft/kiota/generator --language csharp -n samespaceprefix
+mcr.microsoft.com/kiota/generator --language csharp -n samespaceprefix
```
> **Note:** you can alternatively use the `--openapi` parameter with a URI instead of volume mapping.
@@ -71,7 +44,7 @@ ghcr.io/microsoft/kiota/generator --language csharp -n samespaceprefix
To generate a SDK from an online OpenAPI description and into the current directory:
```shell
-docker run -v ${PWD}:/app/output ghcr.io/microsoft/kiota/generator \
+docker run -v ${PWD}:/app/output mcr.microsoft.com/kiota/generator \
--language typescript -n gfx -d \
https://raw.githubusercontent.com/microsoftgraph/msgraph-sdk-powershell/dev/openApiDocs/v1.0/Mail.yml
```
diff --git a/docs/get-started/reference-openapi.md b/docs/get-started/reference-openapi.md
index 2f33077faa..45e4c976a5 100644
--- a/docs/get-started/reference-openapi.md
+++ b/docs/get-started/reference-openapi.md
@@ -10,6 +10,7 @@ The following is a minimal OpenAPI description that describes how to call the `/
- [Build SDKs for .NET](dotnet.md)
- [Build SDKs for Go](go.md)
- [Build SDKs for Java](java.md)
+- [Build SDKs for Ruby](ruby.md)
- [Build SDKs for TypeScript](typescript.md)
```yaml
diff --git a/serialization/dotnet/text/.editorconfig b/serialization/dotnet/text/.editorconfig
deleted file mode 100644
index 3ed46fbb34..0000000000
--- a/serialization/dotnet/text/.editorconfig
+++ /dev/null
@@ -1,119 +0,0 @@
-# Rules in this file were initially inferred by Visual Studio IntelliCode from the C:\Users\anomondi\Documents\kiota\serialization\dotnet\json codebase based on best match to current usage at 17/08/2021
-# You can modify the rules from these initially generated values to suit your own policies
-# You can learn more about editorconfig here: https://docs.microsoft.com/en-us/visualstudio/ide/editorconfig-code-style-settings-reference
-[*.cs]
-
-
-#Core editorconfig formatting - indentation
-
-#use soft tabs (spaces) for indentation
-indent_style = space
-
-#Formatting - indentation options
-
-#indent switch case contents.
-csharp_indent_case_contents = true
-#indent switch labels
-csharp_indent_switch_labels = true
-
-#Formatting - new line options
-
-#place else statements on a new line
-csharp_new_line_before_else = true
-#require members of object intializers to be on separate lines
-csharp_new_line_before_members_in_object_initializers = true
-
-#Formatting - organize using options
-
-#sort System.* using directives alphabetically, and place them before other usings
-dotnet_sort_system_directives_first = true
-
-#Formatting - spacing options
-
-#require NO space between a cast and the value
-csharp_space_after_cast = false
-#require a space before the colon for bases or interfaces in a type declaration
-csharp_space_after_colon_in_inheritance_clause = true
-#require NO space after a keyword in a control flow statement such as a for loop
-csharp_space_after_keywords_in_control_flow_statements = false
-#require a space before the colon for bases or interfaces in a type declaration
-csharp_space_before_colon_in_inheritance_clause = true
-#remove space within empty argument list parentheses
-csharp_space_between_method_call_empty_parameter_list_parentheses = false
-#remove space between method call name and opening parenthesis
-csharp_space_between_method_call_name_and_opening_parenthesis = false
-#do not place space characters after the opening parenthesis and before the closing parenthesis of a method call
-csharp_space_between_method_call_parameter_list_parentheses = false
-#remove space within empty parameter list parentheses for a method declaration
-csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
-#place a space character after the opening parenthesis and before the closing parenthesis of a method declaration parameter list.
-csharp_space_between_method_declaration_parameter_list_parentheses = false
-
-#Formatting - wrapping options
-
-#leave code block on single line
-csharp_preserve_single_line_blocks = true
-#leave statements and member declarations on the same line
-csharp_preserve_single_line_statements = true
-
-#Style - Code block preferences
-
-#prefer no curly braces if allowed
-csharp_prefer_braces = false:suggestion
-
-#Style - expression bodied member options
-
-#prefer block bodies for constructors
-csharp_style_expression_bodied_constructors = false:suggestion
-#prefer expression-bodied members for methods
-csharp_style_expression_bodied_methods = true:suggestion
-
-#Style - expression level options
-
-#prefer out variables to be declared inline in the argument list of a method call when possible
-csharp_style_inlined_variable_declaration = true:suggestion
-#prefer the language keyword for member access expressions, instead of the type name, for types that have a keyword to represent them
-dotnet_style_predefined_type_for_member_access = true:suggestion
-
-#Style - Expression-level preferences
-
-#prefer default over default(T)
-csharp_prefer_simple_default_expression = true:suggestion
-#prefer objects to be initialized using object initializers when possible
-dotnet_style_object_initializer = true:suggestion
-
-#Style - implicit and explicit types
-
-#prefer var over explicit type in all cases, unless overridden by another code style rule
-csharp_style_var_elsewhere = true:suggestion
-#prefer var when the type is already mentioned on the right-hand side of a declaration expression
-csharp_style_var_when_type_is_apparent = true:suggestion
-
-#Style - language keyword and framework type options
-
-#prefer the language keyword for local variables, method parameters, and class members, instead of the type name, for types that have a keyword to represent them
-dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
-
-#Style - Miscellaneous preferences
-
-#prefer anonymous functions over local functions
-csharp_style_pattern_local_over_anonymous_function = false:suggestion
-
-#Style - modifier options
-
-#prefer accessibility modifiers to be declared except for public interface members. This will currently not differ from always and will act as future proofing for if C# adds default interface methods.
-dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
-
-#Style - Modifier preferences
-
-#when this rule is set to a list of modifiers, prefer the specified ordering.
-csharp_preferred_modifier_order = public,private,static,readonly:suggestion
-
-#Style - qualification options
-
-#prefer fields not to be prefaced with this. or Me. in Visual Basic
-dotnet_style_qualification_for_field = false:suggestion
-#prefer methods not to be prefaced with this. or Me. in Visual Basic
-dotnet_style_qualification_for_method = false:suggestion
-#prefer properties not to be prefaced with this. or Me. in Visual Basic
-dotnet_style_qualification_for_property = false:suggestion
diff --git a/serialization/dotnet/text/.vscode/launch.json b/serialization/dotnet/text/.vscode/launch.json
deleted file mode 100644
index f771e4cd9d..0000000000
--- a/serialization/dotnet/text/.vscode/launch.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "version": "0.2.0",
- "configurations": [
- {
- // Use IntelliSense to find out which attributes exist for C# debugging
- // Use hover for the description of the existing attributes
- // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
- "name": ".NET Core Launch (console)",
- "type": "coreclr",
- "request": "launch",
- "preLaunchTask": "build",
- // If you have changed target frameworks, make sure to update the program path.
- "program": "${workspaceFolder}/Microsoft.Kiota.Serialization.Text.Tests/bin/Debug/net6.0/Microsoft.Kiota.Serialization.Text.Tests.dll",
- "args": [],
- "cwd": "${workspaceFolder}/Microsoft.Kiota.Serialization.Text.Tests",
- // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
- "console": "internalConsole",
- "stopAtEntry": false
- },
- {
- "name": ".NET Core Attach",
- "type": "coreclr",
- "request": "attach"
- }
- ]
-}
\ No newline at end of file
diff --git a/serialization/dotnet/text/.vscode/tasks.json b/serialization/dotnet/text/.vscode/tasks.json
deleted file mode 100644
index 1563eed509..0000000000
--- a/serialization/dotnet/text/.vscode/tasks.json
+++ /dev/null
@@ -1,24 +0,0 @@
-{
- // See https://go.microsoft.com/fwlink/?LinkId=733558
- // for the documentation about the tasks.json format
- "version": "2.0.0",
- "tasks": [
- {
- "label": "build",
- "command": "dotnet",
- "type": "shell",
- "args": [
- "build",
- // Ask dotnet build to generate full paths for file names.
- "/property:GenerateFullPaths=true",
- // Do not generate summary otherwise it leads to duplicate errors in Problems panel
- "/consoleloggerparameters:NoSummary"
- ],
- "group": "build",
- "presentation": {
- "reveal": "silent"
- },
- "problemMatcher": "$msCompile"
- }
- ]
-}
\ No newline at end of file
diff --git a/serialization/dotnet/text/Microsoft.Kiota.Serialization.Text.Tests/Microsoft.Kiota.Serialization.Text.Tests.csproj b/serialization/dotnet/text/Microsoft.Kiota.Serialization.Text.Tests/Microsoft.Kiota.Serialization.Text.Tests.csproj
deleted file mode 100644
index ef63386983..0000000000
--- a/serialization/dotnet/text/Microsoft.Kiota.Serialization.Text.Tests/Microsoft.Kiota.Serialization.Text.Tests.csproj
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
- net6.0
- enable
-
- false
-
-
-
-
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
-
-
-
-
-
-
-
diff --git a/serialization/dotnet/text/Microsoft.Kiota.Serialization.Text.Tests/UnitTest1.cs b/serialization/dotnet/text/Microsoft.Kiota.Serialization.Text.Tests/UnitTest1.cs
deleted file mode 100644
index af7f54cc92..0000000000
--- a/serialization/dotnet/text/Microsoft.Kiota.Serialization.Text.Tests/UnitTest1.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using Xunit;
-
-namespace Microsoft.Kiota.Serialization.Text.Tests;
-
-public class UnitTest1
-{
- [Fact]
- public void Test1()
- {
-
- }
-}
\ No newline at end of file
diff --git a/serialization/dotnet/text/Microsoft.Kiota.Serialization.Text.sln b/serialization/dotnet/text/Microsoft.Kiota.Serialization.Text.sln
deleted file mode 100644
index 8a5f6acae1..0000000000
--- a/serialization/dotnet/text/Microsoft.Kiota.Serialization.Text.sln
+++ /dev/null
@@ -1,33 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 16
-VisualStudioVersion = 16.0.30114.105
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Kiota.Serialization.Text", "src\Microsoft.Kiota.Serialization.Text.csproj", "{29CEB2E3-93C5-4AFF-BAE1-DFF7BADF9A4D}"
-EndProject
-Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{89E4E773-D199-4D1A-A8D6-24EF61CBACED}"
- ProjectSection(SolutionItems) = preProject
- .editorconfig = .editorconfig
- EndProjectSection
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Kiota.Serialization.Text.Tests", "Microsoft.Kiota.Serialization.Text.Tests\Microsoft.Kiota.Serialization.Text.Tests.csproj", "{53A7CB1A-280A-4BEB-B064-91065436CD4C}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {29CEB2E3-93C5-4AFF-BAE1-DFF7BADF9A4D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {29CEB2E3-93C5-4AFF-BAE1-DFF7BADF9A4D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {29CEB2E3-93C5-4AFF-BAE1-DFF7BADF9A4D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {29CEB2E3-93C5-4AFF-BAE1-DFF7BADF9A4D}.Release|Any CPU.Build.0 = Release|Any CPU
- {53A7CB1A-280A-4BEB-B064-91065436CD4C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {53A7CB1A-280A-4BEB-B064-91065436CD4C}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {53A7CB1A-280A-4BEB-B064-91065436CD4C}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {53A7CB1A-280A-4BEB-B064-91065436CD4C}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
-EndGlobal
diff --git a/serialization/dotnet/text/README.md b/serialization/dotnet/text/README.md
deleted file mode 100644
index 12b5053e50..0000000000
--- a/serialization/dotnet/text/README.md
+++ /dev/null
@@ -1,13 +0,0 @@
-# To-do
-
-
-
-- [x] coverage code
-- [ ] analyzers
-- [x] unit test project
-- [x] docs comments
-
-## Using the text Serialization implementations
-
-1. [Add the package feed](https://docs.github.com/en/packages/guides/configuring-dotnet-cli-for-use-with-github-packages#authenticating-to-github-packages) in the `nuget.config` file. (owner microsoft).
-1. `dotnet add package Microsoft.Kiota.Serialization.Text`.
diff --git a/serialization/dotnet/text/src/Microsoft.Kiota.Serialization.Text.csproj b/serialization/dotnet/text/src/Microsoft.Kiota.Serialization.Text.csproj
deleted file mode 100644
index 30c51560df..0000000000
--- a/serialization/dotnet/text/src/Microsoft.Kiota.Serialization.Text.csproj
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- netstandard2.1
- latest
- true
- https://github.com/microsoft/kiota
- 1.0.0
- true
- true
-
-
-
-
-
-
-
-
-
diff --git a/serialization/dotnet/text/src/TextParseNode.cs b/serialization/dotnet/text/src/TextParseNode.cs
deleted file mode 100644
index 406ade0cbc..0000000000
--- a/serialization/dotnet/text/src/TextParseNode.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Xml;
-using Microsoft.Kiota.Abstractions;
-using Microsoft.Kiota.Abstractions.Serialization;
-
-namespace Microsoft.Kiota.Serialization.Text;
-///
-/// The implementation for the text/plain content type
-///
-public class TextParseNode : IParseNode
-{
- internal const string NoStructuredDataMessage = "text does not support structured data";
- private readonly string Text;
- ///
- /// Initializes a new instance of the class.
- ///
- /// The text value.
- public TextParseNode(string text)
- {
- Text = text?.Trim('"');
- }
- ///
- public Action OnBeforeAssignFieldValues { get; set; }
- ///
- public Action OnAfterAssignFieldValues { get; set; }
- ///
- public bool? GetBoolValue() => bool.TryParse(Text, out var result) ? result : null;
- ///
- public byte[] GetByteArrayValue() => string.IsNullOrEmpty(Text) ? null : Convert.FromBase64String(Text);
- ///
- public byte? GetByteValue() => byte.TryParse(Text, out var result) ? result : null;
- ///
- public IParseNode GetChildNode(string identifier) => throw new InvalidOperationException(NoStructuredDataMessage);
- ///
- public IEnumerable GetCollectionOfObjectValues(ParsableFactory factory) where T : IParsable => throw new InvalidOperationException(NoStructuredDataMessage);
- ///
- public IEnumerable GetCollectionOfPrimitiveValues() => throw new InvalidOperationException(NoStructuredDataMessage);
- ///
- public DateTimeOffset? GetDateTimeOffsetValue() => DateTimeOffset.TryParse(Text, out var result) ? result : null;
- ///
- public Date? GetDateValue() => DateTime.TryParse(Text, out var result) ? new Date(result) : null;
- ///
- public decimal? GetDecimalValue() => decimal.TryParse(Text, out var result) ? result : null;
- ///
- public double? GetDoubleValue() => double.TryParse(Text, out var result) ? result : null;
- ///
- public float? GetFloatValue() => float.TryParse(Text, out var result) ? result : null;
- ///
- public Guid? GetGuidValue() => Guid.TryParse(Text, out var result) ? result : null;
- ///
- public int? GetIntValue() => int.TryParse(Text, out var result) ? result : null;
- ///
- public long? GetLongValue() => long.TryParse(Text, out var result) ? result : null;
- ///
- public T GetObjectValue(ParsableFactory factory) where T : IParsable => throw new InvalidOperationException(NoStructuredDataMessage);
- ///
- public sbyte? GetSbyteValue() => sbyte.TryParse(Text, out var result) ? result : null;
- ///
- public string GetStringValue() => Text;
- ///
- public TimeSpan? GetTimeSpanValue() => string.IsNullOrEmpty(Text) ? null : XmlConvert.ToTimeSpan(Text);
- ///
- public Time? GetTimeValue() => DateTime.TryParse(Text, out var result) ? new Time(result) : null;
- ///
- IEnumerable IParseNode.GetCollectionOfEnumValues() => throw new InvalidOperationException(NoStructuredDataMessage);
- ///
- T? IParseNode.GetEnumValue() => Enum.TryParse(Text, true, out var result) ? result : null;
-}
diff --git a/serialization/dotnet/text/src/TextParseNodeFactory.cs b/serialization/dotnet/text/src/TextParseNodeFactory.cs
deleted file mode 100644
index 92526c80db..0000000000
--- a/serialization/dotnet/text/src/TextParseNodeFactory.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using System;
-using System.IO;
-using Microsoft.Kiota.Abstractions.Serialization;
-
-namespace Microsoft.Kiota.Serialization.Text;
-
-///
-/// The implementation for text/plain content types
-///
-public class TextParseNodeFactory : IParseNodeFactory
-{
- ///
- public string ValidContentType => "text/plain";
- ///
- public IParseNode GetRootParseNode(string contentType, Stream content) {
- if(string.IsNullOrEmpty(contentType))
- throw new ArgumentNullException(nameof(contentType));
- else if(!ValidContentType.Equals(contentType, StringComparison.OrdinalIgnoreCase))
- throw new ArgumentOutOfRangeException($"expected a {ValidContentType} content type");
-
- _ = content ?? throw new ArgumentNullException(nameof(content));
- using var reader = new StreamReader(content);
- var stringContent = reader.ReadToEnd();
- return new TextParseNode(stringContent);
- }
-}
diff --git a/serialization/dotnet/text/src/TextSerializationWriter.cs b/serialization/dotnet/text/src/TextSerializationWriter.cs
deleted file mode 100644
index 9a4403c8bd..0000000000
--- a/serialization/dotnet/text/src/TextSerializationWriter.cs
+++ /dev/null
@@ -1,100 +0,0 @@
-using System;
-using System.IO;
-using System.Collections.Generic;
-using System.Xml;
-using Microsoft.Kiota.Abstractions;
-using Microsoft.Kiota.Abstractions.Serialization;
-using System.Text;
-using Microsoft.Kiota.Abstractions.Extensions;
-using System.Linq;
-
-namespace Microsoft.Kiota.Serialization.Text;
-
-///
-/// The implementation for text content types.
-///
-public class TextSerializationWriter : ISerializationWriter, IDisposable {
- private readonly MemoryStream _stream = new MemoryStream();
- private readonly StreamWriter writer;
- ///
- /// Initializes a new instance of the class.
- ///
- public TextSerializationWriter()
- {
- writer = new(_stream);
- }
- private bool written;
- ///
- public Action OnBeforeObjectSerialization { get; set; }
- ///
- public Action OnAfterObjectSerialization { get; set; }
- ///
- public Action OnStartObjectSerialization { get; set; }
- ///
- public void Dispose()
- {
- _stream?.Dispose();
- writer?.Dispose();
- GC.SuppressFinalize(this);
- }
- ///
- public Stream GetSerializedContent() {
- writer.Flush();
- return _stream;
- }
- ///
- public void WriteAdditionalData(IDictionary value) => throw new InvalidOperationException(TextParseNode.NoStructuredDataMessage);
- ///
- public void WriteBoolValue(string key, bool? value) => WriteStringValue(key, value?.ToString());
- ///
- public void WriteByteArrayValue(string key, byte[] value) => WriteStringValue(key, value.Any() ? Convert.ToBase64String(value) : string.Empty);
- ///
- public void WriteByteValue(string key, byte? value) => WriteStringValue(key, value?.ToString());
- ///
- public void WriteCollectionOfObjectValues(string key, IEnumerable values) where T : IParsable => throw new InvalidOperationException(TextParseNode.NoStructuredDataMessage);
- ///
- public void WriteCollectionOfPrimitiveValues(string key, IEnumerable values) => throw new InvalidOperationException(TextParseNode.NoStructuredDataMessage);
- ///
- public void WriteDateTimeOffsetValue(string key, DateTimeOffset? value) => WriteStringValue(key, value.HasValue ? value.Value.ToString() : null);
- ///
- public void WriteDateValue(string key, Date? value) => WriteStringValue(key, value?.ToString());
- ///
- public void WriteDecimalValue(string key, decimal? value) => WriteStringValue(key, value?.ToString());
- ///
- public void WriteDoubleValue(string key, double? value) => WriteStringValue(key, value?.ToString());
- ///
- public void WriteFloatValue(string key, float? value) => WriteStringValue(key, value?.ToString());
- ///
- public void WriteGuidValue(string key, Guid? value) => WriteStringValue(key, value?.ToString());
- ///
- public void WriteIntValue(string key, int? value) => WriteStringValue(key, value?.ToString());
- ///
- public void WriteLongValue(string key, long? value) => WriteStringValue(key, value?.ToString());
- ///
- public void WriteNullValue(string key) => WriteStringValue(key, "null");
- ///
- public void WriteObjectValue(string key, T value) where T : IParsable => throw new InvalidOperationException(TextParseNode.NoStructuredDataMessage);
- ///
- public void WriteSbyteValue(string key, sbyte? value) => WriteStringValue(key, value?.ToString());
- ///
- public void WriteStringValue(string key, string value)
- {
- if(!string.IsNullOrEmpty(key))
- throw new InvalidOperationException(TextParseNode.NoStructuredDataMessage);
- if(!string.IsNullOrEmpty(value))
- if(written)
- throw new InvalidOperationException("a value was already written for this serialization writer, text content only supports a single value");
- else {
- writer.Write(value);
- written = true;
- }
- }
- ///
- public void WriteTimeSpanValue(string key, TimeSpan? value) => WriteStringValue(key, value.HasValue ? XmlConvert.ToString(value.Value) : null);
- ///
- public void WriteTimeValue(string key, Time? value) => WriteStringValue(key, value?.ToString());
- ///
- void ISerializationWriter.WriteCollectionOfEnumValues(string key, IEnumerable values) => throw new InvalidOperationException(TextParseNode.NoStructuredDataMessage);
- ///
- void ISerializationWriter.WriteEnumValue(string key, T? value) => WriteStringValue(key, value.HasValue ? value.Value.ToString().ToFirstCharacterLowerCase() : null);
-}
diff --git a/serialization/dotnet/text/src/TextSerializationWriterFactory.cs b/serialization/dotnet/text/src/TextSerializationWriterFactory.cs
deleted file mode 100644
index 91e9a45ffb..0000000000
--- a/serialization/dotnet/text/src/TextSerializationWriterFactory.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-using Microsoft.Kiota.Abstractions.Serialization;
-
-namespace Microsoft.Kiota.Serialization.Text;
-
-///
-/// The implementation for the text content type
-///
-public class TextSerializationWriterFactory : ISerializationWriterFactory {
- ///
- public string ValidContentType { get; } = "text/plain";
-
- ///
- public ISerializationWriter GetSerializationWriter(string contentType)
- {
- if(string.IsNullOrEmpty(contentType))
- throw new ArgumentNullException(nameof(contentType));
- else if(!ValidContentType.Equals(contentType, StringComparison.OrdinalIgnoreCase))
- throw new ArgumentOutOfRangeException($"expected a {ValidContentType} content type");
-
- return new TextSerializationWriter();
- }
-}
diff --git a/src/Kiota.Builder/CodeDOM/CodeTypeBase.cs b/src/Kiota.Builder/CodeDOM/CodeTypeBase.cs
index c4380e2700..9579c2b27a 100644
--- a/src/Kiota.Builder/CodeDOM/CodeTypeBase.cs
+++ b/src/Kiota.Builder/CodeDOM/CodeTypeBase.cs
@@ -25,7 +25,7 @@ protected ChildType BaseClone(CodeTypeBase source) where ChildType :
ActionOf = source.ActionOf;
IsNullable = source.IsNullable;
CollectionKind = source.CollectionKind;
- Name = source.Name.Clone() as string;
+ Name = source.Name?.Clone() as string;
Parent = source.Parent;
return this as ChildType;
}
diff --git a/src/Kiota.Builder/Kiota.Builder.csproj b/src/Kiota.Builder/Kiota.Builder.csproj
index add1953249..6afb2601f5 100644
--- a/src/Kiota.Builder/Kiota.Builder.csproj
+++ b/src/Kiota.Builder/Kiota.Builder.csproj
@@ -2,6 +2,8 @@
net6.0
+ true
+ ..\Microsoft.OpenApi.snk
diff --git a/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs b/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs
index 1fe9ea86c8..952f1ff421 100644
--- a/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs
+++ b/src/Kiota.Builder/Refiners/CommonLanguageRefiner.cs
@@ -306,7 +306,7 @@ protected static void ReplaceBinaryByNativeType(CodeElement currentElement, stri
currentMethod.ReturnType.Name = symbol;
shouldInsertUsing = !string.IsNullOrWhiteSpace(ns);
}
- var binaryParameter = currentMethod.Parameters.FirstOrDefault(x => x.Type.Name.Equals(BinaryType));
+ var binaryParameter = currentMethod.Parameters.FirstOrDefault(x => x.Type?.Name?.Equals(BinaryType) ?? false);
if(binaryParameter != null) {
binaryParameter.Type.Name = symbol;
shouldInsertUsing = !string.IsNullOrWhiteSpace(ns);
diff --git a/src/Kiota.Builder/Refiners/PhpRefiner.cs b/src/Kiota.Builder/Refiners/PhpRefiner.cs
index 7d5f4aee40..db1cb2313f 100644
--- a/src/Kiota.Builder/Refiners/PhpRefiner.cs
+++ b/src/Kiota.Builder/Refiners/PhpRefiner.cs
@@ -118,8 +118,8 @@ public override void Refine(CodeNamespace generatedCode)
new (x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestExecutor), "Http\\Promise", "Promise", "RejectedPromise"),
new (x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.RequestExecutor), "", "Exception"),
new (x => x is CodeEnum, "Microsoft\\Kiota\\Abstractions\\", "Enum"),
- new(x => x is CodeProperty property && property.Type.Name.Equals("DateTime", StringComparison.OrdinalIgnoreCase), "", "DateTime"),
- new(x => x is CodeProperty property && property.Type.Name.Equals("DateTimeOffset", StringComparison.OrdinalIgnoreCase), "", "DateTime"),
+ new(x => x is CodeProperty property && (property.Type?.Name?.Equals("DateTime", StringComparison.OrdinalIgnoreCase) ?? false), "", "DateTime"),
+ new(x => x is CodeProperty property && (property.Type?.Name?.Equals("DateTimeOffset", StringComparison.OrdinalIgnoreCase) ?? false), "", "DateTime"),
new(x => x is CodeMethod method && method.IsOfKind(CodeMethodKind.ClientConstructor), "Microsoft\\Kiota\\Abstractions", "ApiClientBuilder")
};
private static void CorrectPropertyType(CodeProperty currentProperty) {
@@ -145,7 +145,7 @@ private static void CorrectPropertyType(CodeProperty currentProperty) {
} else if (currentProperty.IsOfKind(CodePropertyKind.RequestBuilder))
{
currentProperty.Type.Name = currentProperty.Type.Name.ToFirstCharacterUpperCase();
- } else if (currentProperty.Type.Name.Equals("DateTimeOffset", StringComparison.OrdinalIgnoreCase))
+ } else if (currentProperty.Type?.Name?.Equals("DateTimeOffset", StringComparison.OrdinalIgnoreCase) ?? false)
{
currentProperty.Type.Name = "DateTime";
} else if (currentProperty.IsOfKind(CodePropertyKind.Options, CodePropertyKind.Headers))
diff --git a/src/Kiota.Builder/Writers/Go/GoConventionService.cs b/src/Kiota.Builder/Writers/Go/GoConventionService.cs
index ed249a7542..003028520c 100644
--- a/src/Kiota.Builder/Writers/Go/GoConventionService.cs
+++ b/src/Kiota.Builder/Writers/Go/GoConventionService.cs
@@ -67,7 +67,7 @@ currentType.TypeDefinition is not CodeInterface &&
#pragma warning disable CA1822 // Method should be static
public string TranslateType(CodeTypeBase type, bool includeImportSymbol)
{
- if(type.Name.StartsWith("map[")) return type.Name; //casing hack
+ if(type.Name?.StartsWith("map[") ?? false) return type.Name; //casing hack
return type.Name switch {
"void" => string.Empty,
@@ -100,8 +100,8 @@ public bool IsPrimitiveType(string typeName) {
};
}
public bool IsScalarType(string typeName) {
- if(typeName.StartsWith("map[")) return true;
- return typeName.ToLowerInvariant() switch {
+ if(typeName?.StartsWith("map[") ?? false) return true;
+ return typeName?.ToLowerInvariant() switch {
"binary" or "void" or "[]byte" => true,
_ => false,
};
@@ -125,7 +125,7 @@ currentEnumDefinition.Parent is CodeNamespace enumNS &&
(targetTypeDef as CodeClass)?.StartBlock as BlockDeclaration ??
(targetTypeDef as CodeInterface)?.StartBlock as BlockDeclaration)
.Usings
- .FirstOrDefault(x => currentBaseType.Name.Equals(x.Name, StringComparison.OrdinalIgnoreCase));
+ .FirstOrDefault(x => currentBaseType.Name?.Equals(x.Name, StringComparison.OrdinalIgnoreCase) ?? false);
return symbolUsing == null ? string.Empty : symbolUsing.Declaration.Name.GetNamespaceImportSymbol();
}
}
diff --git a/src/Kiota.Builder/Writers/Php/CodeMethodWriter.cs b/src/Kiota.Builder/Writers/Php/CodeMethodWriter.cs
index b239a9a2cd..2686b7ac71 100644
--- a/src/Kiota.Builder/Writers/Php/CodeMethodWriter.cs
+++ b/src/Kiota.Builder/Writers/Php/CodeMethodWriter.cs
@@ -264,7 +264,7 @@ private string GetSerializationMethodName(CodeTypeBase propType) {
}
}
- var lowerCaseProp = propertyType.ToLower();
+ var lowerCaseProp = propertyType?.ToLower();
return lowerCaseProp switch
{
"string" or "guid" => "writeStringValue",
@@ -295,7 +295,7 @@ private string GetDeserializationMethodName(CodeTypeBase propType, CodeMethod me
return $"$n->getEnumValue({propertyType.ToFirstCharacterUpperCase()}::class)";
}
- var lowerCaseType = propertyType.ToLower();
+ var lowerCaseType = propertyType?.ToLower();
return lowerCaseType switch
{
"int" => "$n->getIntegerValue()",
diff --git a/src/Kiota.Builder/Writers/Php/PhpConventionService.cs b/src/Kiota.Builder/Writers/Php/PhpConventionService.cs
index 35bca7bc2a..a24ff19a16 100644
--- a/src/Kiota.Builder/Writers/Php/PhpConventionService.cs
+++ b/src/Kiota.Builder/Writers/Php/PhpConventionService.cs
@@ -57,7 +57,7 @@ public override string GetTypeString(CodeTypeBase code, CodeElement targetElemen
public override string TranslateType(CodeType type)
{
string typeName = type.Name;
- return typeName.ToLowerInvariant() switch
+ return typeName?.ToLowerInvariant() switch
{
"boolean" => "bool",
"double" or "decimal" => "float",
diff --git a/src/Microsoft.OpenApi.Kiota.ApiDescription.Client/Microsoft.OpenApi.Kiota.ApiDescription.Client.nuspec b/src/Microsoft.OpenApi.Kiota.ApiDescription.Client/Microsoft.OpenApi.Kiota.ApiDescription.Client.nuspec
new file mode 100644
index 0000000000..037faeb284
--- /dev/null
+++ b/src/Microsoft.OpenApi.Kiota.ApiDescription.Client/Microsoft.OpenApi.Kiota.ApiDescription.Client.nuspec
@@ -0,0 +1,23 @@
+
+
+
+ Microsoft.OpenApi.Kiota.ApiDescription.Client
+ 0.5.0-preview
+ Microsoft
+ true
+ false
+ MIT
+ https://microsoft.github.io/kiota
+ Kiota: An OpenAPI SDK generator
+ © Microsoft Corporation. All rights reserved.
+ OpenAPI Swagger AspNetCore CodeGen TypeScript WebApi AspNet
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Microsoft.OpenApi.Kiota.ApiDescription.Client/Microsoft.OpenApi.Kiota.ApiDescription.Client.props b/src/Microsoft.OpenApi.Kiota.ApiDescription.Client/Microsoft.OpenApi.Kiota.ApiDescription.Client.props
new file mode 100644
index 0000000000..6f8f5488cf
--- /dev/null
+++ b/src/Microsoft.OpenApi.Kiota.ApiDescription.Client/Microsoft.OpenApi.Kiota.ApiDescription.Client.props
@@ -0,0 +1,12 @@
+
+
+
+
+
+ KiotaCSharp
+
+
+ KiotaCSharp
+
+
+
diff --git a/src/Microsoft.OpenApi.Kiota.ApiDescription.Client/Microsoft.OpenApi.Kiota.ApiDescription.Client.targets b/src/Microsoft.OpenApi.Kiota.ApiDescription.Client/Microsoft.OpenApi.Kiota.ApiDescription.Client.targets
new file mode 100644
index 0000000000..29ad334bb3
--- /dev/null
+++ b/src/Microsoft.OpenApi.Kiota.ApiDescription.Client/Microsoft.OpenApi.Kiota.ApiDescription.Client.targets
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+ kiota -d %(FullPath) -o %(OutputPath) -l CSharp -c %(ClassName) -n %(Namespace)
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Microsoft.OpenApi.snk b/src/Microsoft.OpenApi.snk
new file mode 100644
index 0000000000..c5e0df3364
Binary files /dev/null and b/src/Microsoft.OpenApi.snk differ
diff --git a/src/kiota/kiota.csproj b/src/kiota/kiota.csproj
index d580def7af..32c0ddb879 100644
--- a/src/kiota/kiota.csproj
+++ b/src/kiota/kiota.csproj
@@ -2,13 +2,29 @@
Exe
+ Latest
net6.0
true
+ https://github.com/microsoft/kiota
+ MIT
+ true
kiota
+ Microsoft
+ Microsoft
+ Microsoft.OpenApi.Kiota
+ Microsoft.OpenApi.Kiota
./nupkg
- 0.0.23
+ 0.1.0-preview
+
+ - Initial public release
+
true
https://github.com/microsoft/kiota
+ OpenAPI based client generator.
+ © Microsoft Corporation. All rights reserved.
+ OpenAPI .NET CSharp TypeScript Java Go PHP Python REST API
+ true
+ ..\Microsoft.OpenApi.snk
@@ -24,6 +40,7 @@
+
diff --git a/tests/Kiota.Builder.IntegrationTests/GenerateSample.cs b/tests/Kiota.Builder.IntegrationTests/GenerateSample.cs
index d4bd62daeb..80e43486c2 100644
--- a/tests/Kiota.Builder.IntegrationTests/GenerateSample.cs
+++ b/tests/Kiota.Builder.IntegrationTests/GenerateSample.cs
@@ -22,9 +22,59 @@ public async Task GeneratesTodo(GenerationLanguage language, bool backingStore)
var backingStoreSuffix = backingStore ? string.Empty : "BackingStore";
var configuration = new GenerationConfiguration
{
- Language = GenerationLanguage.CSharp,
+ Language = language,
OpenAPIFilePath = "ToDoApi.yaml",
- OutputPath = $".\\Generated\\{language}{backingStoreSuffix}",
+ OutputPath = $".\\Generated\\Todo\\{language}{backingStoreSuffix}",
+ UsesBackingStore = backingStore,
+ };
+ await new KiotaBuilder(logger, configuration).GenerateSDK(new());
+ }
+ [InlineData(GenerationLanguage.CSharp, false)]
+ [InlineData(GenerationLanguage.Java, false)]
+ [InlineData(GenerationLanguage.TypeScript, false)]
+ [InlineData(GenerationLanguage.Go, false)]
+ [InlineData(GenerationLanguage.Ruby, false)]
+ [InlineData(GenerationLanguage.CSharp, true)]
+ [InlineData(GenerationLanguage.Java, true)]
+ [InlineData(GenerationLanguage.PHP, false)]
+ [InlineData(GenerationLanguage.TypeScript, true)]
+ [Theory]
+ public async Task GeneratesModelWithDictionary(GenerationLanguage language, bool backingStore)
+ {
+ var logger = LoggerFactory.Create((builder) => {
+ }).CreateLogger();
+
+ var backingStoreSuffix = backingStore ? "BackingStore" : string.Empty;
+ var configuration = new GenerationConfiguration
+ {
+ Language = language,
+ OpenAPIFilePath = "ModelWithDictionary.yaml",
+ OutputPath = $".\\Generated\\ModelWithDictionary\\{language}{backingStoreSuffix}",
+ UsesBackingStore = backingStore,
+ };
+ await new KiotaBuilder(logger, configuration).GenerateSDK(new());
+ }
+ [InlineData(GenerationLanguage.CSharp, false)]
+ [InlineData(GenerationLanguage.Java, false)]
+ [InlineData(GenerationLanguage.TypeScript, false)]
+ [InlineData(GenerationLanguage.Go, false)]
+ [InlineData(GenerationLanguage.Ruby, false)]
+ [InlineData(GenerationLanguage.CSharp, true)]
+ [InlineData(GenerationLanguage.Java, true)]
+ [InlineData(GenerationLanguage.PHP, false)]
+ [InlineData(GenerationLanguage.TypeScript, true)]
+ [Theory]
+ public async Task GeneratesResponseWithMultipleReturnFormats(GenerationLanguage language, bool backingStore)
+ {
+ var logger = LoggerFactory.Create((builder) => {
+ }).CreateLogger();
+
+ var backingStoreSuffix = backingStore ? "BackingStore" : string.Empty;
+ var configuration = new GenerationConfiguration
+ {
+ Language = language,
+ OpenAPIFilePath = "ResponseWithMultipleReturnFormats.yaml",
+ OutputPath = $".\\Generated\\ResponseWithMultipleReturnFormats\\{language}{backingStoreSuffix}",
UsesBackingStore = backingStore,
};
await new KiotaBuilder(logger, configuration).GenerateSDK(new());
diff --git a/tests/Kiota.Builder.IntegrationTests/Kiota.Builder.IntegrationTests.csproj b/tests/Kiota.Builder.IntegrationTests/Kiota.Builder.IntegrationTests.csproj
index f23cdc5e77..55b7f2b179 100644
--- a/tests/Kiota.Builder.IntegrationTests/Kiota.Builder.IntegrationTests.csproj
+++ b/tests/Kiota.Builder.IntegrationTests/Kiota.Builder.IntegrationTests.csproj
@@ -28,6 +28,15 @@
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
PreserveNewest
diff --git a/tests/Kiota.Builder.IntegrationTests/ModelWithDerivedTypes.yaml b/tests/Kiota.Builder.IntegrationTests/ModelWithDerivedTypes.yaml
new file mode 100644
index 0000000000..75ffb99d84
--- /dev/null
+++ b/tests/Kiota.Builder.IntegrationTests/ModelWithDerivedTypes.yaml
@@ -0,0 +1,81 @@
+openapi: 3.0.0
+info:
+ title: "Derived Types API"
+ version: "1.0.0"
+servers:
+ - url: https://example.org/
+paths:
+ /fruits: # this method will not downcast to OpenAPI v2 because oneOf is not supported
+ get:
+ responses:
+ 200:
+ description: ok
+ content:
+ application/json:
+ # The code generator will need to be clever and instead of generating a fruitResponse class
+ # with a property for each of the properties, it needs to detect that apple and orange derive from fruit.
+ # It can then declare the requestExecutors as returning the base type.
+ schema:
+ oneOf:
+ - $ref: "#/components/schemas/fruit" # Allowing the base class allows enables evolvabilty
+ - $ref: "#/components/schemas/apple"
+ - $ref: "#/components/schemas/orange"
+ /fruitsWithDiscriminator:
+ get:
+ responses:
+ 200:
+ description: ok
+ content:
+ application/json:
+ schema:
+ discriminator:
+ propertyName: fruitType # This only works if fruitType has the exact schema name
+ allOf:
+ - $ref: "#/components/schemas/fruit" # Allowing the base class allows enables evolvabilty
+ /fruitsWithDiscriminatorWithMapping:
+ get:
+ responses:
+ 200:
+ description: ok
+ content:
+ application/json:
+ schema:
+ discriminator:
+ propertyName: fruitType
+ mapping: # If mapping doesn't exist, then fallback to base type'
+ apple: '#/components/schemas/apple'
+ orange: '#/components/schemas/orange'
+ allOf:
+ - $ref: "#/components/schemas/fruit" # Allowing the base class allows enables evolvabilty
+
+components:
+ schemas:
+ fruit:
+ type: object
+ title: fruit # required temporarily due to a bug in Kiota codemodel
+ properties:
+ name:
+ type: string
+ fruitType:
+ type: string
+ apple:
+ allOf:
+ - $ref: '#/components/schemas/fruit'
+ type: object
+ title: apple
+ properties:
+ edible:
+ type: boolean
+ fruitType:
+ x-const: apple # the const keyword is only supported int OpenAPI 3.1
+ orange:
+ allOf:
+ - $ref: '#/components/schemas/fruit'
+ type: object
+ title: orange
+ properties:
+ seedless:
+ type: boolean
+ fruitType:
+ x-const: orange
+
diff --git a/tests/Kiota.Builder.IntegrationTests/ModelWithDictionary.yaml b/tests/Kiota.Builder.IntegrationTests/ModelWithDictionary.yaml
new file mode 100644
index 0000000000..95be111ba4
--- /dev/null
+++ b/tests/Kiota.Builder.IntegrationTests/ModelWithDictionary.yaml
@@ -0,0 +1,32 @@
+openapi: 3.0.0
+info:
+ title: "Dictionary API"
+ version: "1.0.0"
+servers:
+ - url: https://example.org/
+paths:
+ /resource:
+ get:
+ responses:
+ 200:
+ description: ok
+ content:
+ application/json:
+ schema:
+ $ref: "#/components/schemas/resource"
+components:
+ schemas:
+ resource:
+ type: object
+ properties:
+ info:
+ type: string
+ # customSettings: Dictionary
+ customSettings:
+ type: object
+ patternProperties:
+ ".*":
+ type: string
+
+
+
diff --git a/tests/Kiota.Builder.IntegrationTests/ResponseWithMultipleReturnFormats.yaml b/tests/Kiota.Builder.IntegrationTests/ResponseWithMultipleReturnFormats.yaml
new file mode 100644
index 0000000000..dc69b9f184
--- /dev/null
+++ b/tests/Kiota.Builder.IntegrationTests/ResponseWithMultipleReturnFormats.yaml
@@ -0,0 +1,38 @@
+openapi: 3.0.0
+info:
+ title: "API that returns multiple response formats"
+ version: "1.0.0"
+servers:
+ - url: https://example.org/
+paths:
+ /report:
+ get:
+ responses:
+ 200:
+ description: ok
+ content:
+ application/json: {} # Response is JSON but no schema is defined
+ text/csv: {}
+ /reportWithSchema:
+ get:
+ responses:
+ 200:
+ description: ok
+ content:
+ application/json: # Response is JSON but no schema is defined
+ schema:
+ $ref: "#/components/schemas/weatherReport"
+ text/csv: {}
+components:
+ schemas:
+ weatherReport:
+ type: array
+ items:
+ type: object
+ properties:
+ date:
+ type: string
+ temperature:
+ type: string
+ conditions:
+ type: string