Azure / Azure/azure-rest-api-specs

[Key Vault] Import Key API is inconsistent

Open
#1,747 8 comments 0 reactions 0 assignees View on GitHub
KeyVault Service Attention
Dominant language
TypeSpec
Stars
3.1k
Forks
5.9k
Avg merge
3d 37m
Merged PRs (30d)
446

Description

:wave:

We're attempting to manage Key Vault Key's via the Azure SDK for Go - here's the code generated from [the Swagger](https://github.com/Azure/azure-rest-api-specs/blob/current/specification/keyvault/data-plane/Microsoft.KeyVault/2016-10-01/keyvault.json).

```
# ...

// JSONWebKey is as of
// http://tools.ietf.org/html/draft-ietf-jose-json-web-key-18
type JSONWebKey struct {
Kid *string `json:"kid,omitempty"`
Kty JSONWebKeyType `json:"kty,omitempty"`
KeyOps *[]string `json:"key_ops,omitempty"`
# ...
# ...
T *string `json:"key_hsm,omitempty"`
}

type KeyCreateParameters struct {
Kty JSONWebKeyType `json:"kty,omitempty"`
KeySize *int32 `json:"key_size,omitempty"`
KeyOps *[]JSONWebKeyOperation `json:"key_ops,omitempty"`
KeyAttributes *KeyAttributes `json:"attributes,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
}

// KeyImportParameters is the key import parameters.
type KeyImportParameters struct {
Hsm *bool `json:"Hsm,omitempty"`
Key *JSONWebKey `json:"key,omitempty"`
KeyAttributes *KeyAttributes `json:"attributes,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
}

// KeyUpdateParameters is the key update parameters.
type KeyUpdateParameters struct {
KeyOps *[]JSONWebKeyOperation `json:"key_ops,omitempty"`
KeyAttributes *KeyAttributes `json:"attributes,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
}

# ...
```

Note that for the KeyCreateParameters (and the KeyUpdateParameters, which isn't included) - [the `KeyOps` is an array of `JSONWebKeyOperation`](https://github.com/Azure/azure-rest-api-specs/blob/current/specification/keyvault/data-plane/Microsoft.KeyVault/2016-10-01/keyvault.json#L3831). However, when Importing a Key via the `KeyImportParameters` - [this is a list of Strings (since it's reusing the `JSONWebKey` model)](https://github.com/Azure/azure-rest-api-specs/blob/current/specification/keyvault/data-plane/Microsoft.KeyVault/2016-10-01/keyvault.json#L2936).

Is there a particular reason this isn't using the Enum? If not - given it's the same values, would it be possible to update the Swagger so that these are the same type?

Thanks!

Contributor guide

Open the contributing guide

Research direction

Start in specification/keyvault/data-plane/Microsoft.KeyVault/2016-10-01/keyvault.json, comparing the KeyCreateParameters and KeyUpdateParameters definitions with KeyImportParameters and JSONWebKey.key_ops at the referenced locations. Check whether the differing array item types are intentional; done means the specification consistently represents the shared values and generated Go models no longer expose an unexplained mismatch.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, openapi
Domain
api
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.