Azure / azure-sdk-for-python

This repository is for active development of the Azure SDK for Python. For consumers of the SDK we recommend visiting our public developer docs at https://learn.microsoft.com/python/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-python.
MIT License
4.58k stars 2.8k forks source link

[API Management] Python DSK not using all schema data #18788

Closed rupprecht1993 closed 2 years ago

rupprecht1993 commented 3 years ago

Describe the bug Trying to upload an openapi.json file via the sdk to the api management results in a loss of schema information (in that particular case the "minLength" property).

To Reproduce requirements.txt:

azure-mgmt-apimanagement==2.0.0
msrestazure==0.6.4

main.py:

import json

from azure.mgmt.apimanagement import ApiManagementClient
from azure.mgmt.apimanagement.models import ApiCreateOrUpdateParameter, ContentFormat
from msrestazure.azure_active_directory import ServicePrincipalCredentials

# variables
client_id = 'client_id'
client_secret = 'client_secret'
tenant_id = 'tenant_id'
subscription_id = 'subscription_id'
api_path = 'test_path'
rg_name = 'rg_name'
service_name = 'service_name'

azureCredentials = ServicePrincipalCredentials(client_id, client_secret, tenant=tenant_id)
apim_client = ApiManagementClient(azureCredentials, subscription_id)

with open('openapi.json') as json_file:
    swagger_spec_json = json.load(json_file)
swagger_spec = json.dumps(swagger_spec_json)

api_params = ApiCreateOrUpdateParameter(value=swagger_spec, format=ContentFormat.openapijson, path=api_path)
apim_client.api.create_or_update(rg_name, service_name, api_path, api_params)

openapi.json:

{
  "openapi": "3.0.1",
  "info": {
    "title": "TEST",
    "version": "1.0"
  },
  "paths": {
    "/": {
      "get": {
        "summary": "TEST",
        "parameters": [
          {
            "name": "param",
            "in": "query",
            "required": true,
            "schema":{
              "type": "string",
              "minLength": 1
            }
          }
        ],
        "responses": {
          "200": {
            "description": "null"
          }
        }
      }
    }
  }
}

Steps to reproduce the behavior:

  1. replace variables for specific use case
  2. execute main.py

Expected behavior All of the properties listed under "schema" are getting deployed.

Screenshots After execution in the API Management, not every schema property was deployed: image

swathipil commented 3 years ago

@lowmann15 Thanks for reporting this issue! Directing it to the right people.

msyyc commented 3 years ago

similar issue : https://github.com/Azure/azure-sdk-for-python/issues/16984

rupprecht1993 commented 3 years ago

@swathipil is there any chance to get a planned fixxing date? We are very dependent on that fix in an operational sense. Thanks!

swathipil commented 3 years ago

@msyyc - Would you be able to reply to the above message with updates? Thanks!

msyyc commented 3 years ago

The problem is caused by the difference between track1(version < 1.0.0b1) and track2(version >= 1.0.0b1). Track1 is deprecated and new content will be only published with track2. Please follow the guidance of https://github.com/Azure/azure-sdk-for-python/issues/16984 to complete migration.

some other useful guidance: https://devblogs.microsoft.com/azure-sdk/migrating-python-management-libraries/ https://github.com/Azure/azure-cli/blob/dev/doc/track_2_migration_guidance.md

ghost commented 2 years ago

Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

ghost commented 2 years ago

Hi @lowmann15. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

ghost commented 2 years ago

Hi @lowmann15, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.