Skip to content

open api python gen can't produce valid python client api based on https://admin.splunk.com/service/info/specs/v2/openapi.json #1

@bayeslearnerold

Description

@bayeslearnerold

I'm not a developer but it seems kinda weird. splunk admin openapi spec hosted at https://admin.splunk.com/service/info/specs/v2/openapi.json has issues (however small?). It's a pity that such a big company doesn't even bother testing it against popular client-gen tools.

As an example, the following code doesn't run with various problems.

import splunkacs
from splunkacs.apis.tags import indexes_api
from splunkacs.model.error import Error
from splunkacs.model.index_response import IndexResponse
from pprint import pprint
# Defining the host is optional and defaults to http://localhost
# See configuration.py for a list of all supported configuration parameters.
configuration = splunkacs.Configuration(
    host = "http://localhost"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

# Configure Bearer authorization (JWT): bearerAuth
configuration = splunkacs.Configuration(
    access_token = 'YOUR_BEARER_TOKEN'  # syntax error here. 
)
# Enter a context with an instance of the API client
with splunkacs.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = indexes_api.IndexesApi(api_client)

    # example passing only required values which don't have defaults set
    path_params = {
        'stack': "stack_example",
    }
    query_params = {
    }
    try:
        api_response = api_instance.list_indexes(
            path_params=path_params,
            query_params=query_params,
        )
        pprint(api_response)
    except splunkacs.ApiException as e:
        print("Exception when calling IndexesApi->list_indexes: %s\n" % e)

    # example passing only optional values
    path_params = {
        'stack': "stack_example",
    }
    query_params = {
        'count': 30,
        'offset': 0,
    }
    try:
        api_response = api_instance.list_indexes(
            path_params=path_params,
            query_params=query_params,
        )
        pprint(api_response)
    except splunkacs.ApiException as e:  # exception thrown here. 
        print("Exception when calling IndexesApi->list_indexes: %s\n" % e)

Errors include:

TypeError: Configuration.__init__() got an unexpected keyword argument 'access_token'
splunkacs.exceptions.ApiValueError: Invalid content_type returned. Content_type='application/json; charset=UTF-8' was returned when only {'application/json'} are defined for status_code=401

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions