You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(openapi): introduction of a new openapi:inspect command (#698)
* feat: introduction of a new `openapi:uses` command
* fix: clarifying that our openapi commands accept urls
* feat: swapping out the analysis work with it now living in `oas`
* fix: updating oas to move the reducer back to where it was
* feat: adding `--feature` args to `openapi:uses`
* feat: improvements to readme and circularRef reporting
* test: adding tests
* fix: fixing spacing bugs and adding tests
* fix: check for features length
* Update src/lib/softError.ts
Co-authored-by: Kanad Gupta <8854718+kanadgupta@users.noreply.github.com>
* Update src/cmds/openapi/uses.ts
Co-authored-by: Kanad Gupta <8854718+kanadgupta@users.noreply.github.com>
* fix: pr feedback
* fix: renaming the command to `openapi:uses`
* docs: `openapi:inspect` (#706)
* fix: file placeholders
* docs: add docs on inspect
Co-authored-by: Kanad Gupta <git@kanad.dev>
Co-authored-by: Kanad Gupta <8854718+kanadgupta@users.noreply.github.com>
`rdme` supports [OpenAPI 3.1](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md), [OpenAPI 3.0](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md), and [Swagger 2.x](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md).
145
146
146
147
<!--alex ignore postman-postwoman-->
147
148
148
-
You can also pass in [Postman Collections](https://www.postman.com/collection/). Postman Collections are converted to OpenAPI using [`postman-to-openapi`](https://github.com/joolfe/postman-to-openapi) prior to any syncing/validation/reduction.
149
+
You can also pass in [Postman Collections](https://www.postman.com/collection/). Postman Collections are converted to OpenAPI using [`postman-to-openapi`](https://github.com/joolfe/postman-to-openapi) prior to any syncing/validation/etc.
149
150
150
151
The following examples use JSON files, but `rdme` supports API Definitions that are written in either JSON or YAML.
151
152
@@ -175,32 +176,32 @@ rdme openapi
175
176
176
177
##### Uploading a New API Definition to ReadMe
177
178
178
-
This will upload `path-to-openapi.json` to your project and return an ID and URL for you to later update your file, and view it in the client.
179
+
This will upload the API definition at the given URL or path to your project and return an ID and URL for you to later update your file, and view it in the client.
179
180
180
181
```sh
181
-
rdme openapi [path-to-file.json]
182
+
rdme openapi [url-or-local-path-to-file]
182
183
```
183
184
184
185
If you want to bypass the prompt to create or update an API definition, you can pass the `--create` flag:
##### Editing (Re-Syncing) an Existing API Definition
191
192
192
193
This will edit (re-sync) an existing API definition (identified by `--id`) within your ReadMe project. **This is the recommended approach for usage in CI environments.**
##### Uploading or Editing an API Definition in a Project Version
199
200
200
201
You can additionally include a version flag, specifying the target version for your file's destination. This approach will provide you with CLI prompts, so we do not recommend this technique in CI environments.
If you wish to use the version specified [in the `info.version` field of your API definition](https://spec.openapis.org/oas/v3.1.0#fixed-fields-0), you can pass the `--useSpecVersion` option. For example, say [the `info` object](https://spec.openapis.org/oas/v3.1.0#info-object) of your API definition looks like this:
@@ -216,13 +217,13 @@ If you wish to use the version specified [in the `info.version` field of your AP
216
217
You can pass in the `--useSpecVersion` option, which would be equivalent to passing in `--version=1.2.3`:
You can add `--update` to the command so if there's only one API definition for the given project version to update, it will select it without any prompts:
@@ -238,7 +239,7 @@ rdme openapi petstore.json --workingDirectory=[path to directory]
238
239
You can also perform a local validation of your API definition (no ReadMe account required!), which can be useful when constructing or editing your API definition.
239
240
240
241
```sh
241
-
rdme openapi:validate [path-to-file.json]
242
+
rdme openapi:validate [url-or-local-path-to-file]
242
243
```
243
244
244
245
Similar to the `openapi` command, you can also [omit the file path](#omitting-the-file-path).
@@ -248,7 +249,7 @@ Similar to the `openapi` command, you can also [omit the file path](#omitting-th
248
249
We also offer a tool that allows you to reduce a large API definition down to a specific set of tags or paths (again, no ReadMe account required!). This can be useful if you're debugging a problematic schema somewhere, or if you have a file that is too big to maintain.
249
250
250
251
```sh
251
-
rdme openapi:reduce [path-to-file.json]
252
+
rdme openapi:reduce [url-or-local-path-to-file]
252
253
```
253
254
254
255
The command will ask you a couple questions about how you wish to reduce the file and then do so. If you wish to automate this command, you can pass in CLI arguments to bypass the prompts. Here's an example use case:
@@ -265,6 +266,22 @@ rdme openapi:reduce petstore.json --path /pet/{id} --method get --method put --o
265
266
266
267
As with the `openapi` command, you can also [omit the file path](#omitting-the-file-path).
267
268
269
+
#### Inspecting an API Definition
270
+
271
+
This tool can also perform a comprehensive analysis (again, no ReadMe account required!) of your API definition to determine how it's utilizing aspects of [the OpenAPI Specification](https://spec.openapis.org/oas/v3.1.0.html) (such as circular references, polymorphism, etc.) and any [ReadMe-specific extensions](https://docs.readme.com/main/docs/openapi-extensions) you might be using.
272
+
273
+
```sh
274
+
rdme openapi:inspect [url-or-local-path-to-file]
275
+
```
276
+
277
+
This command contains a `--feature` flag so you can filter for one or several specific features. If you pass in one or more `--feature` flags, the command returns a `0` exit code if your definition contains all of the given features and a `1` exit code if your definition lacks any of the given features.
As with the `openapi` command, you can also [omit the file path](#omitting-the-file-path).
284
+
268
285
### Docs (a.k.a. Guides) 📖
269
286
270
287
The Markdown files will require YAML front matter with certain ReadMe documentation attributes. Check out [our docs](https://docs.readme.com/docs/rdme#markdown-file-setup) for more info on setting up your front matter.
0 commit comments