Azure / Azure/oav

`oav generate-examples generated.json` fails to parse x-ms-paths

Open
#1,006 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
104
Forks
62
Avg merge
2d 12h
Merged PRs (30d)
5

Description

I have a set of TypeSpec files (see this draft PR into azure-rest-api-specs): https://github.com/Azure/azure-rest-api-specs/pull/26146

I run "npx tsp compile" to create an OpenAPI file named "generated.json" from these TypeSpec files.

You can find "generated.json" in the mentioned PR.

I now run "oav generate-examples generated.json". I got a console spew that looks like one example is being generated, but at the end, I got the error below.

```console
{
message: "fatal error: Cannot read properties of undefined (reading 'post'), {}",
level: '\x1B[31merror\x1B[39m'
}
fatal error: Cannot read properties of undefined (reading 'post'), {}
```

Looking at generated.json, I see I have:

```json
"paths": {},
"x-ms-paths": { ... }
```

I had to delete the empty "paths" element and rename "x-ms-paths" to "paths" to make the error go away. So I just ended up with:

```json
"paths": {...},
```

On IM Timothee G. wrote, "Sounds like a bug in oav those paths should be in x-ms-paths it is invalid to have query parameters in paths in swagger which is why x-ms-paths was created". He suggested I open a GitHub issue here on this.

I'm using the latest version of oav (version 3.2.13)

Thanks,

Darren

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the failure with the generated.json from the linked azure-rest-api-specs draft PR using `oav generate-examples generated.json`. Compare behavior with the `paths` and `x-ms-paths` sections, and consider the issue resolved when examples generate without manually deleting or renaming either section.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.