vmware / vmware-openapi-generator

VMware-openapi-generator tool generates open-api documents from vapi metamodel format.
Other
22 stars 19 forks source link

compute policy create spec properties schema defined only as object #38

Open VamshikShetty opened 5 years ago

VamshikShetty commented 5 years ago

Path:

"/vcenter/compute/policies": {
            "post": {
                "tags": [
                    "compute/policies"
                ],
                "summary": "Creates a new compute policy. Warning: This operation is available as technical preview. It may be changed in a future release.",
                "parameters": [
                    {
                        "in": "body",
                        "name": "request_body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/vcenter.compute.policies_create"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "The identifier of the newly created policy. Use this identifier to get or destroy the policy.\nThe result will be an identifier for the resource type: vcenter.compute.Policy.",
                        "schema": {
                            "$ref": "#/definitions/vcenter.compute.policies.create_result"
                        }
                    },
                    "400": {
                        "description": "if more than 100 policies are created.",
                        "schema": {
                            "$ref": "#/definitions/vapi.std.errors.unable_to_allocate_resource_error"
                        }
                    },
                    "403": {
                        "description": "if the user doesn't have the required privileges.",
                        "schema": {
                            "$ref": "#/definitions/vapi.std.errors.unauthorized_error"
                        }
                    }
                },
                "consumes": [
                    "application/json"
                ],
                "operationId": "create"
            },
            "get": {
                "tags": [
                    "compute/policies"
                ],
                "summary": "Returns information about the compute policies available in this vCenter server. Warning: This operation is available as technical preview. It may be changed in a future release.",
                "parameters": [],
                "responses": {
                    "200": {
                        "description": "The list of compute policies available on this vCenter server.",
                        "schema": {
                            "$ref": "#/definitions/vcenter.compute.policies.list_result"
                        }
                    },
                    "403": {
                        "description": "if the user doesn't have the required privileges.",
                        "schema": {
                            "$ref": "#/definitions/vapi.std.errors.unauthorized_error"
                        }
                    }
                },
                "operationId": "list"
            }
        }

/vcenter/compute/policies has a post request which takes a parameters input named request_body and the definition of the request body describes its property as of type object with no other ref to use from.

Definition:

        "vcenter.compute.policies_create": {
            "type": "object",
            "properties": {
                "spec": {
                    "type": "object",
                    "description": "Specification for the new policy to be created. The new policy will be an instance of the capability that has the creation type (see Capabilities.Info.create-spec-type) equal to the type of the specified value (see spec).\nThe parameter must contain all the attributes defined in CreateSpec."
                }
            },
            "required": [
                "spec"
            ]
        }

But on closer look at its description it states

Specification for the new policy to be created. The new policy will be an instance of the capability that has the creation type (see Capabilities.Info.create-spec-type) equal to the type of the specified value (see spec).\nThe parameter must contain all the attributes defined in CreateSpec

Which in-fact points to the correct type to be used, but is not reflected in schema def vcenter.compute.policies_create. types = { 'name': 'VapiStdLocalizableMessage', 'description': 'VapiStdLocalizableMessage', 'create_spec_type': 'str', 'info_type': 'str' }

i.e


"vcenter.compute.policies.capabilities.info": {
            "type": "object",
            "properties": {
                "name": {
                    "description": "Name of the capability. Warning: This attribute is available as technical preview. It may be changed in a future release.",
                    "$ref": "#/definitions/vapi.std.localizable_message"
                },
                "description": {
                    "description": "Description of the capability. Warning: This attribute is available as technical preview. It may be changed in a future release.",
                    "$ref": "#/definitions/vapi.std.localizable_message"
                },
                "create_spec_type": {
                    "description": "Identifier of the structure used to create a policy based on this capability. See Policies.create. Warning: This attribute is available as technical preview. It may be changed in a future release.\nWhen clients pass a value of this structure as a parameter, the field must be an identifier for the resource type: vapi.structure. When operations return a value of this structure as a result, the field will be an identifier for the resource type: vapi.structure.",
                    "type": "string"
                },
                "info_type": {
                    "description": "Identifier of the structure returned when retrieving information about a policy based on this capability. See Policies.get. Warning: This attribute is available as technical preview. It may be changed in a future release.\nWhen clients pass a value of this structure as a parameter, the field must be an identifier for the resource type: vapi.structure. When operations return a value of this structure as a result, the field will be an identifier for the resource type: vapi.structure.",
                    "type": "string"
                }
            },
            "required": [
                "name",
                "description",
                "create_spec_type",
                "info_type"
            ]
        }