Skip to content

Commit

Permalink
use kiota search to download APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
andreaTP committed Mar 30, 2023
1 parent 923ae64 commit dc3980d
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 42 deletions.
59 changes: 30 additions & 29 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,29 @@ name: integration-tests
on:
workflow_dispatch:
push:
branches: [main]
paths-ignore:
[
"abstractions/**",
"authentication/**",
"serialization/**",
"http/**",
"**.md",
".vscode/**",
"**.svg",
]
pull_request:
paths-ignore:
[
"abstractions/**",
"authentication/**",
"serialization/**",
"http/**",
"**.md",
".vscode/**",
"**.svg",
]
# TEST IN CI
# branches: [main]
# paths-ignore:
# [
# "abstractions/**",
# "authentication/**",
# "serialization/**",
# "http/**",
# "**.md",
# ".vscode/**",
# "**.svg",
# ]
# pull_request:
# paths-ignore:
# [
# "abstractions/**",
# "authentication/**",
# "serialization/**",
# "http/**",
# "**.md",
# ".vscode/**",
# "**.svg",
# ]

concurrency:
# Only run once for latest commit per ref and cancel other (previous) runs.
Expand Down Expand Up @@ -70,15 +71,15 @@ jobs:
description:
- "./tests/Kiota.Builder.IntegrationTests/InheritingErrors.yaml"
- "./tests/Kiota.Builder.IntegrationTests/NoUnderscoresInModel.yaml"
- "https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.yaml"
- "https://raw.githubusercontent.com/APIs-guru/openapi-directory/main/APIs/twitter.com/current/2.61/openapi.yaml"
- "https://raw.githubusercontent.com/APIs-guru/openapi-directory/main/APIs/notion.com/1.0.0/openapi.yaml"
- "https://raw.githubusercontent.com/APIs-guru/openapi-directory/main/APIs/stripe.com/2022-11-15/openapi.yaml"
- "oas::petstore"
- "apisguru::twitter.com:current"
- "apisguru::notion.com"
- "apisguru::stripe.com"
- "https://raw.githubusercontent.com/googlemaps/openapi-specification/main/dist/google-maps-platform-openapi3.yml"
- "https://raw.githubusercontent.com/APIs-guru/openapi-directory/main/APIs/meraki.com/v1.31.0/openapi.yaml"
- "apisguru::meraki.com"
- "https://developers.pipedrive.com/docs/api/v1/openapi.yaml"
- "https://raw.githubusercontent.com/APIs-guru/openapi-directory/main/APIs/twilio.com/api/1.39.2/openapi.yaml"
- "https://api.apis.guru/v2/specs/docusign.net/v2.1/openapi.yaml"
- "apisguru::twilio.com:api"
- "apisguru::docusign.net"
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -447,3 +447,4 @@ reports/
*.prefs

samples/
it/openapi.yaml
14 changes: 7 additions & 7 deletions it/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"https://raw.githubusercontent.com/github/rest-api-description/main/descriptions/api.github.com/api.github.com.yaml": {
"oas::petstore": {
"ExcludePatterns": [
{
"Pattern": "/gists",
Expand Down Expand Up @@ -90,7 +90,7 @@
}
]
},
"https://raw.githubusercontent.com/APIs-guru/openapi-directory/main/APIs/notion.com/1.0.0/openapi.yaml": {
"apisguru::notion.com": {
"ExcludePatterns": [
{
"Pattern": "/v1/databases/**",
Expand Down Expand Up @@ -164,7 +164,7 @@
}
]
},
"https://raw.githubusercontent.com/APIs-guru/openapi-directory/main/APIs/twilio.com/api/1.39.2/openapi.yaml": {
"apisguru::twilio.com:api": {
"ExcludePatterns": [
{
"Pattern": "/2010-04-01/Accounts/*/Addresses/*/DependentPhoneNumbers.json",
Expand Down Expand Up @@ -234,23 +234,23 @@
}
]
},
"https://raw.githubusercontent.com/APIs-guru/openapi-directory/main/APIs/stripe.com/2022-11-15/openapi.yaml": {
"apisguru::stripe.com": {
"Suppressions": [
{
"Language": "all",
"Rationale": "https://github.com/microsoft/kiota/issues/2352"
}
]
},
"https://raw.githubusercontent.com/APIs-guru/openapi-directory/main/APIs/meraki.com/v1.31.0/openapi.yaml": {
"apisguru::meraki.com": {
"Suppressions": [
{
"Language": "all",
"Rationale": "https://github.com/microsoft/kiota/issues/2368"
}
]
},
"https://api.apis.guru/v2/specs/docusign.net/v2.1/openapi.yaml": {
"apisguru::docusign.net": {
"Suppressions": [
{
"Language": "csharp",
Expand All @@ -266,7 +266,7 @@
}
]
},
"https://raw.githubusercontent.com/APIs-guru/openapi-directory/main/APIs/twitter.com/current/2.61/openapi.yaml": {
"apisguru::twitter.com:current": {
"Suppressions": [
{
"Language": "typescript",
Expand Down
6 changes: 1 addition & 5 deletions it/exec-cmd.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,7 @@ if (!([string]::IsNullOrEmpty($mockSeverITFolder))) {
Pop-Location

# Provision Mock server with the right spec
$openapiUrl = $descriptionUrl
if ($openapiUrl.StartsWith("./")) {
$rootPath = Split-Path -parent $scriptPath
$openapiUrl = $openapiUrl.replace("./", "file:$rootPath/", 1)
}
$openapiUrl = Join-Path -Path $scriptPath -ChildPath "openapi.yaml"

# provision MockServer to mock the specific openapi description https://www.mock-server.com/mock_server/using_openapi.html#button_open_api_filepath
Retry({Invoke-WebRequest -Method PUT -Body "{ `"specUrlOrPayload`": `"$openapiUrl`" }" -Uri http://localhost:1080/mockserver/openapi -ContentType application/json})
Expand Down
12 changes: 11 additions & 1 deletion it/generate-code.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,14 @@ switch ($dev)
break
}
}
Start-Process "$kiotaExec" -ArgumentList "generate --clean-output --language ${language} --openapi ${descriptionUrl}${additionalArguments}" -Wait -NoNewWindow

$targetOpenapiPath = Join-Path -Path $scriptPath -ChildPath "openapi.yaml"
if (!$descriptionUrl.StartsWith("./")) {
Start-Process "$kiotaExec" -ArgumentList "download ${descriptionUrl} --clean-output --output $targetOpenapiPath" -Wait -NoNewWindow
} else if (!$descriptionUrl.StartsWith("http")) {
Invoke-WebRequest -Uri $descriptionUrl -OutFile "C:\path\file"
} else {
Copy-Item -Path $descriptionUrl -Destination $targetOpenapiPath
}

Start-Process "$kiotaExec" -ArgumentList "generate --clean-output --language ${language} --openapi ${targetOpenapiPath}${additionalArguments}" -Wait -NoNewWindow

0 comments on commit dc3980d

Please sign in to comment.