Skip to content

Commit

Permalink
docs(parser-adapter-openapi-json-3-0): adapt to OpenAPI 3.0.4 support
Browse files Browse the repository at this point in the history
Refs #4612
  • Loading branch information
char0n committed Dec 24, 2024
1 parent b92891e commit 0b724f5
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/apidom-parser-adapter-openapi-json-3-0/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# @swagger-api/apidom-parser-adapter-openapi-json-3-0

`@swagger-api/apidom-parser-adapter-openapi-json-3-0` is a parser adapter for the [OpenAPI 3.0.x specification](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md) in [JSON format](https://www.json.org/json-en.html).
`@swagger-api/apidom-parser-adapter-openapi-json-3-0` is a parser adapter for the [OpenAPI 3.0.x specification](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.4.md) in [JSON format](https://www.json.org/json-en.html).
Under the hood this adapter uses [apidom-parser-adapter-json](https://github.com/swagger-api/apidom/tree/main/packages/apidom-parser-adapter-json)
to parse a source string into generic ApiDOM in [base ApiDOM namespace](https://github.com/swagger-api/apidom/tree/main/packages/apidom#base-namespace)
which is then refracted with [OpenAPI 3.0.x Refractors](https://github.com/swagger-api/apidom/tree/main/packages/apidom-ns-openapi-3-0#refractors).
Expand Down Expand Up @@ -33,6 +33,8 @@ Defines list of media types that this parser adapter recognizes.
'application/vnd.oai.openapi+json;version=3.0.2',
'application/vnd.oai.openapi;version=3.0.3',
'application/vnd.oai.openapi+json;version=3.0.3',
'application/vnd.oai.openapi;version=3.0.4',
'application/vnd.oai.openapi+json;version=3.0.4',
]
```

Expand Down Expand Up @@ -69,11 +71,11 @@ with [supported media types](#mediatypes).
import { parse, detect } from '@swagger-api/apidom-parser-adapter-openapi-json-3-0';

// detecting
await detect('{"openapi": "3.0.3"}'); // => true
await detect('{"openapi": "3.0.4"}'); // => true
await detect('test'); // => false

// parsing
const parseResult = await parse('{"openapi": "3.0.3"}', { sourceMap: true });
const parseResult = await parse('{"openapi": "3.0.4"}', { sourceMap: true });
```

### Indirect usage
Expand All @@ -88,5 +90,5 @@ const parser = new ApiDOMParser();

parser.use(openApiJsonAdapter);

const parseResult = await parser.parse('{"openapi": "3.0.3"}', { mediaType: openApiJsonAdapter.mediaTypes.latest('json') });
const parseResult = await parser.parse('{"openapi": "3.0.4"}', { mediaType: openApiJsonAdapter.mediaTypes.latest('json') });
```

0 comments on commit 0b724f5

Please sign in to comment.