Azure / Azure/oav

Error when instantiating a subclass in x-ms-examples: Discriminator value "latency" not found

Open
#720 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
104
Forks
62
Avg merge
2d 12h
Merged PRs (30d)
5

Description

Hi,

I've been trying everything I could to figure out why "instantiating" a new instance of the discriminating schema didn't work for me. The below is my schema and x-ms-examples:

```json
"ipControl": {
"type": "object",
"description": "The control object that mutates the TCP traffic",
"discriminator": "controlType",
"properties": {
"controlType": {
"type": "string",
"enum": [
"latency",
"bandwidth",
"https",
"qos"
]
}
},
"required": [
"controlType"
]
},
...
"latency": {
"type": "object",
"description": "Model that represents the IP Latency Control",
"allOf": [
{
"$ref": "#/definitions/ipControl"
}
],
"properties": {
"delayMilliseconds": {
"type": "integer",
"description": "The latency in milliseconds"
},
"delaySigma": {
"type": "integer",
"description": "The latency sigma in milliseconds"
},
"correlationPercent": {
"type": "number",
"description": "the percentage of correlation"
},
"distribution": {
"type": "string",
"description": "The distribution of the latency"
}
},
"required": [
"delayMilliseconds",
"delaySigma",
"correlationPercent",
"distribution"
]
},
```

Usage in `x-ms-examples`:
```
"responses": {
"200": {
"headers": {},
"body": {
"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/exampleRG/providers/Microsoft.Moxy/vnetInterceptorConfigurations/exampleInterceptorConfig",
"type": "Microsoft.Moxy/vnetInterceptorConfigurations",
"name": "exampleInterceptorConfig",
"location": "westus2",
"properties": {
"routes": [
{
"name": "exampleRoute",
"priority": 1,
"destination": "10.140.1.2:8080",
"ipControls": [
{
"controlType": "latency",
"delayMilliseconds": 850,
"delaySigma": "100",
"correlationPercent": 10,
"distribution": "normal"
}
]
}
],
"provisioningState": "Succeeded"
},
...
```

When I ran the `oav validate-example` command, I get the following error:

> {
code: 'DISCRIMINATOR_VALUE_NOT_FOUND',
message: 'Discriminator value "latency" not found',
schemaUrl: 'types\\vnetInterceptorConfiguration.json',
exampleUrl: 'examples\\vnetInterceptorConfigurations\\CreateOrUpdateVnetInterceptorConfiguration.json',
schemaPosition: { line: 242, column: 18 },
schemaJsonPath: '#/discriminatorMap',
examplePosition: { line: 82, column: 34 },
exampleJsonPath: '$responses.201.body.properties.routes[0].ipControls[0].controlType',
severity: 0,
source: 'response',
operationId: 'VnetInterceptorConfiguration_CreateOrUpdate',
level: '\u001b[31merror\u001b[39m'
}

I wonder if anyone hit the same problem? Any help would be greatly appreciated!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.