Azure / Azure/azure-rest-api-specs

[EventGrid] Swagger ModelValidation INVALID_TYPE

Open
#25,381 3 comments 0 reactions 1 assignee Assigned to @mikeharder View on GitHub
Dominant language
TypeSpec
Stars
3.1k
Forks
5.9k
Avg merge
2d 22h
Merged PRs (30d)
444

Description

Check `Swagger ModelValidation` is failing on EventGrid with this error:

```
##[error]Validating "examples" and "x-ms-examples" in specification/eventgrid/data-plane/Microsoft.EventGrid/preview/2023-06-01-preview/EventGrid.json:
error :
code: INVALID_TYPE
message: Expected type but found type object
schemaUrl: >-
specification/eventgrid/data-plane/Microsoft.EventGrid/preview/2023-06-01-preview/EventGrid.json
exampleUrl: >-
specification/eventgrid/data-plane/Microsoft.EventGrid/preview/2023-06-01-preview/examples/publish.json
schemaPosition:
line: 82
column: 22
schemaJsonPath: ! ''
examplePosition:
line: 24
column: 16
exampleJsonPath: $response.200/body
severity: 0
source: response
operationId: PublishCloudEvents
level: error
```

https://github.com/Azure/azure-rest-api-specs/pull/25323/checks?check_run_id=15930723858

From @johanste:

> It looks to me like validation of examples of APIs that return an empty object may be incorrect. There is (or at least was) some ambiguity between not returning anything and returning an empty object in x-ms-examples. For the longest time it didn't matter, but at some point it was decided by the REST API review board that returning nothing was bad and empty object preferred.

I believe this behavior is coded here:

https://github.com/Azure/oav/blob/760a3352a04ebfcd2e9a1d05c7ad4925f20caa2c/lib/swaggerValidator/modelValidator.ts#L744

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.