Skip to content

Commit

Permalink
chore: minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleh Shumov committed Dec 6, 2024
1 parent da5b0ad commit 9249d2a
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ $ npm install -g rdme
$ rdme COMMAND
running command...
$ rdme (--version)
rdme/9.0.0-next.35 linux-x64 node-v20.18.1
rdme/9.0.0-next.35 darwin-arm64 node-v20.13.1
$ rdme --help [COMMAND]
USAGE
$ rdme COMMAND
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"openapi": "3.0.0",
"info": {
"title": "Complex Cyclic Example",
"version": "1.0.0"
},
"paths": {
"/example": {
"get": {
"summary": "Example endpoint with unresolved references",
"responses": {
"200": {
"description": "Successful response"
}
}
}
}
},
"components": {
"schemas": {
"Entity": {
"type": "object",
"properties": {
"relatedEntity": {
"$ref": "#/components/schemas/RelatedEntity"
},
"Entity": {
"$ref": "#/components/schemas/EntityRef"
}
}
},
"RelatedEntity": {
"type": "object",
"properties": {
"entity": {
"$ref": "#/components/schemas/EntityRef"
},
"RelatedEntity": {
"$ref": "#/components/schemas/RelatedEntityRef"
}
}
},
"RelatedEntityRef": {
"type": "object",
"properties": {
"entity": {
"type": "object"
},
"RelatedEntity": {
"type": "object"
}
}
},
"EntityRef": {
"type": "object",
"properties": {
"relatedEntity": {
"$ref": "#/components/schemas/RelatedEntityRef"
},
"Entity": {
"type": "object"
}
}
}
}
}
}
11 changes: 6 additions & 5 deletions documentation/commands/openapi.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Manage your API definition (e.g., syncing, validation, analysis, conversion, etc
* [`rdme openapi convert [SPEC]`](#rdme-openapi-convert-spec)
* [`rdme openapi inspect [SPEC]`](#rdme-openapi-inspect-spec)
* [`rdme openapi reduce [SPEC]`](#rdme-openapi-reduce-spec)
* [`rdme openapi refs [SPEC]`](#rdme-openapi-refs-spec)
* [`rdme openapi validate [SPEC]`](#rdme-openapi-validate-spec)

## `rdme openapi [SPEC]`
Expand Down Expand Up @@ -226,13 +227,13 @@ EXAMPLES
$ rdme openapi reduce petstore.json --path /pet/{id} --method get --method put --out petstore.reduced.json
```

## `rdme openapi:refs [SPEC]`
## `rdme openapi refs [SPEC]`

Resolves circular and recursive references in OpenAPI by replacing them with object schemas.

```
USAGE
$ rdme openapi:refs [SPEC] [--out <value>] [--workingDirectory <value>]
$ rdme openapi refs [SPEC] [--out <value>] [--workingDirectory <value>]
ARGUMENTS
SPEC A file/URL to your API definition
Expand All @@ -254,16 +255,16 @@ DESCRIPTION
EXAMPLES
This will resolve circular and recursive references in the OpenAPI definition at the given file or URL:
$ rdme openapi:refs [url-or-local-path-to-file]
$ rdme openapi refs [url-or-local-path-to-file]
You can omit the file name and `rdme` will scan your working directory (and any subdirectories) for OpenAPI files.
This approach will provide you with CLI prompts, so we do not recommend this technique in CI environments.
$ rdme openapi:refs
$ rdme openapi refs
If you wish to automate this command, you can pass in CLI arguments to bypass the prompts:
$ rdme openapi:refs petstore.json --out petstore.openapi.json
$ rdme openapi refs petstore.json --out petstore.openapi.json
```

## `rdme openapi validate [SPEC]`
Expand Down
2 changes: 1 addition & 1 deletion src/lib/prepareOas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const capitalizeSpecType = (type: string) =>
*/
export default async function prepareOas(
path: string | undefined,
command: 'openapi convert' | 'openapi inspect' | 'openapi reduce' | 'openapi validate' | 'openapi',
command: 'openapi convert' | 'openapi inspect' | 'openapi reduce' | 'openapi refs' | 'openapi validate' | 'openapi',
opts: {
/**
* Optionally convert the supplied or discovered API definition to the latest OpenAPI release.
Expand Down

0 comments on commit 9249d2a

Please sign in to comment.