Open
Description
Description
APIM contains API with following openapi specification and Export-AzApiManagementApi command used to export openapi specification as yaml format. Exported specification contains decimal numbers even specification declared fields to be int32. See amount maximum and minimum properties. If openapi specification is exported via portal then numbers are correctly in int32 format. In demonstration I am using WSL2 Ubuntu 20.04.
APIM openapi specification:
openapi: 3.0.1
info:
title: demoapi
description: This is demo API
version: '1.0'
servers:
- <reduced>
paths:
/amount:
get:
summary: This is demo endpoint
description: This is demo endpoint
operationId: get-amount
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/AmountResponse'
example:
amount: 300
components:
schemas:
AmountResponse:
type: object
properties:
amount:
maximum: 300
minimum: 1
type: integer
format: int32
description: Amount response
securitySchemes:
apiKeyHeader:
type: apiKey
name: Ocp-Apim-Subscription-Key
in: header
apiKeyQuery:
type: apiKey
name: subscription-key
in: query
security:
- apiKeyHeader: []
- apiKeyQuery: []
Exported openapi specification:
openapi: 3.0.1
info:
title: demoapi
description: This is demo API
version: '1.0'
servers:
- <reduced>
paths:
/amount:
get:
summary: This is demo endpoint
description: This is demo endpoint
operationId: get-amount
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/AmountResponse'
example:
amount: 300
components:
schemas:
AmountResponse:
type: object
properties:
amount:
maximum: 300.0
minimum: 1.0
type: integer
format: int32
description: Amount response
securitySchemes:
apiKeyHeader:
type: apiKey
name: Ocp-Apim-Subscription-Key
in: header
apiKeyQuery:
type: apiKey
name: subscription-key
in: query
security:
- apiKeyHeader: [ ]
- apiKeyQuery: [ ]
Issue script & Debug output
Initial:
$apiId = "demoapi"
$subscriptionId = "<reduced>"
$resourceGroupName = "<reduced>"
$apimName = "<reduced>"
$serviceName = "<reduced>"
Connect-AzAccount
Set-AzContext -Subscription $subscriptionId
Script:
$DebugPreference='Continue'
$ApiMgmtContext = New-AzApiManagementContext -ResourceGroupName $resourceGroupName -ServiceName $serviceName
Export-AzApiManagementApi -Context $ApiMgmtContext -ApiId $apiId -SpecificationFormat OpenApi -SaveAs specification.yaml -Force
Output:
DEBUG: 15:56:46 - NewAzureApiManagementContext begin processing with ParameterSet 'ContextParameterSet'.
DEBUG: 15:56:46 - using account id '<reduced>'...
DEBUG: 15:56:46 - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 15:56:46 - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 15:56:46 - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: AzureQoSEvent: Module: Az.ApiManagement:4.0.2; CommandName: New-AzApiManagementContext; PSVersion: 7.4.1; IsSuccess: True; Duration: 00:00:00.0030144
DEBUG: 15:56:46 - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 15:56:46 - NewAzureApiManagementContext end processing.
DEBUG: 15:57:11 - ExportAzureApiManagementApi begin processing with ParameterSet 'ExportToFile'.
DEBUG: 15:57:11 - using account id '<reduced>'...
DEBUG: 15:57:11 - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: [Common.Authentication]: Authenticating using Account: '<reduced>', environment: 'AzureCloud', tenant: '<reduced>'
DEBUG: 15:57:11 - [ConfigManager] Got nothing from [EnableLoginByWam], Module = [], Cmdlet = []. Returning default value [False].
DEBUG: 15:57:11 - [SilentAuthenticator] Calling SharedTokenCacheCredential.GetTokenAsync - TenantId:'<reduced>', Scopes:'https://management.core.windows.net//.default', AuthorityHost:'https://login.microsoftonline.com/', UserId:'<reduced>'
DEBUG: SharedTokenCacheCredential.GetToken invoked. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId:
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Ubuntu 20.04.6 LTS [2024-02-19 13:57:11Z - <reduced>] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Ubuntu 20.04.6 LTS [2024-02-19 13:57:11Z - <reduced>] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Ubuntu 20.04.6 LTS [2024-02-19 13:57:11Z - <reduced>] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Ubuntu 20.04.6 LTS [2024-02-19 13:57:11Z - <reduced>] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Ubuntu 20.04.6 LTS [2024-02-19 13:57:11Z - <reduced>] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Ubuntu 20.04.6 LTS [2024-02-19 13:57:11Z] Found 1 cache accounts and 0 broker accounts
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Ubuntu 20.04.6 LTS [2024-02-19 13:57:11Z] Returning 1 accounts
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Ubuntu 20.04.6 LTS [2024-02-19 13:57:11Z - <reduced>] MSAL MSAL.CoreCLR with assembly version '4.56.0.0'. CorrelationId(<reduced>)
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Ubuntu 20.04.6 LTS [2024-02-19 13:57:11Z - <reduced>] === AcquireTokenSilent Parameters ===
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Ubuntu 20.04.6 LTS [2024-02-19 13:57:11Z - <reduced>] LoginHint provided: False
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Ubuntu 20.04.6 LTS [2024-02-19 13:57:11Z - <reduced>] Account provided: True
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Ubuntu 20.04.6 LTS [2024-02-19 13:57:11Z - <reduced>] ForceRefresh: False
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Ubuntu 20.04.6 LTS [2024-02-19 13:57:11Z - <reduced>]
=== Request Data ===
Authority Provided? - True
Scopes - https://management.core.windows.net//.default
Extra Query Params Keys (space separated) -
ApiId - AcquireTokenSilent
IsConfidentialClient - False
SendX5C - False
LoginHint ? False
IsBrokerConfigured - False
HomeAccountId - False
CorrelationId - <reduced>
UserAssertion set: False
LongRunningOboCacheKey set: False
Region configured:
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Ubuntu 20.04.6 LTS [2024-02-19 13:57:11Z - <reduced>] === Token Acquisition (SilentRequest) started:
Scopes: https://management.core.windows.net//.default
Authority Host: login.microsoftonline.com
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Ubuntu 20.04.6 LTS [2024-02-19 13:57:11Z - <reduced>] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Ubuntu 20.04.6 LTS [2024-02-19 13:57:11Z - <reduced>] Access token is not expired. Returning the found cache entry. [Current time (02/19/2024 13:57:11) - Expiration Time (02/19/2024 14:59:36 +00:00) - Extended Expiration Time (02/19/2024 14:59:36 +00:00)]
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Ubuntu 20.04.6 LTS [2024-02-19 13:57:11Z - <reduced>] Returning access token found in cache. RefreshOn exists ? False
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Ubuntu 20.04.6 LTS [2024-02-19 13:57:11Z - <reduced>] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Ubuntu 20.04.6 LTS [2024-02-19 13:57:11Z - <reduced>]
=== Token Acquisition finished successfully:
DEBUG: False MSAL 4.56.0.0 MSAL.CoreCLR .NET 8.0.1 Ubuntu 20.04.6 LTS [2024-02-19 13:57:11Z - <reduced>] AT expiration time: 02/19/2024 14:59:36 +00:00, scopes: https://management.core.windows.net//user_impersonation https://management.core.windows.net//.default. source: Cache
DEBUG: SharedTokenCacheCredential.GetToken succeeded. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId: ExpiresOn: 2024-02-19T14:59:36.0000000+00:00
DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: '<reduced>', UserId: '<reduced>'
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://management.azure.com/subscriptions/<reduced>/resourceGroups/<reduced>/providers/Microsoft.ApiManagement/service/<reduced>/apis/demoapi?format=openapi-link&export=true&api-version=2021-08-01
Headers:
Accept-Language : en-US
x-ms-client-request-id : <reduced>
Body:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
OK
Headers:
Cache-Control : no-cache
Pragma : no-cache
ETag : "AAAAAAACaeY="
Strict-Transport-Security : max-age=31536000; includeSubDomains
X-Content-Type-Options : nosniff
x-ms-request-id : <reduced>
Server : Microsoft-HTTPAPI/2.0
x-ms-ratelimit-remaining-subscription-reads: 11987
x-ms-correlation-request-id : <reduced>
x-ms-routing-request-id : SWEDENCENTRAL:20240219T135714Z:<reduced>
Date : Mon, 19 Feb 2024 13:57:13 GMT
Body:
{
"id": "/subscriptions/<reduced>/resourceGroups/<reduced>/providers/Microsoft.ApiManagement/service/<reduced>/apis/demoapi",
"format": "openapi-link",
"value": {
"link": "https://<reduced>.blob.core.windows.net/api-export/demoapi.yaml?sv=2017-04-17&sr=b&sig=<reduced>&se=2024-02-19T14:02:14Z&sp=r"
}
}
DEBUG: 15:57:13 - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 15:57:13 - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: AzureQoSEvent: Module: Az.ApiManagement:4.0.2; CommandName: Export-AzApiManagementApi; PSVersion: 7.4.1; IsSuccess: True; Duration: 00:00:01.5715022
DEBUG: 15:57:13 - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 15:57:13 - ExportAzureApiManagementApi end processing.
Environment data
Name Value
---- -----
PSVersion 7.4.1
PSEdition Core
GitCommitId 7.4.1
OS Ubuntu 20.04.6 LTS
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Module versions
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 2.15.1 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}
Script 4.0.2 Az.ApiManagement {Add-AzApiManagementApiToGateway, Add-AzApiManagementApiToProduct, Add-AzApiManagement…
Error output
DEBUG: 15:57:38 - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
DEBUG: 15:57:38 - using account id '<reduced>'...
DEBUG: 15:57:38 - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 15:57:38 - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 15:57:38 - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: AzureQoSEvent: Module: Az.Accounts:2.15.1; CommandName: Resolve-AzError; PSVersion: 7.4.1; IsSuccess: True; Duration: 00:00:00.0017554
DEBUG: 15:57:38 - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 15:57:38 - ResolveError end processing.