Skip to content

Commit

Permalink
feat: expose ApiDOM components as public API
Browse files Browse the repository at this point in the history
Refs #2827
  • Loading branch information
char0n committed Feb 15, 2023
1 parent 2ac1e9f commit 6e5537d
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable camelcase */
import Url from 'url';

import Http, { makeHttp, serializeRes, serializeHeaders } from './http/index.js';
Expand All @@ -7,6 +8,12 @@ import resolveSubtree from './subtree-resolver/index.js';
import { makeApisTagOperation } from './interfaces.js';
import { execute, buildRequest, baseUrl } from './execute/index.js';
import { opId } from './helpers/index.js';
import HttpResolverSwaggerClient from './resolver/apidom/reference/resolve/resolvers/http-swagger-client/index.js';
import JsonParser from './resolver/apidom/reference/parse/parsers/json/index.js';
import YamlParser from './resolver/apidom/reference/parse/parsers/yaml-1-2/index.js';
import OpenApiJson3_1Parser from './resolver/apidom/reference/parse/parsers/openapi-json-3-1/index.js';
import OpenApiYaml3_1Parser from './resolver/apidom/reference/parse/parsers/openapi-yaml-3-1/index.js';
import OpenApi3_1SwaggerClientDereferenceStrategy from './resolver/apidom/reference/dereference/strategies/openapi-3-1-swagger-client/index.js';

Swagger.http = Http;
Swagger.makeHttp = makeHttp.bind(null, Swagger.http);
Expand All @@ -20,6 +27,22 @@ Swagger.makeApisTagOperation = makeApisTagOperation;
Swagger.buildRequest = buildRequest;
Swagger.helpers = { opId };
Swagger.getBaseUrl = baseUrl;
Swagger.apidom = {
resolve: {
resolvers: { HttpResolverSwaggerClient },
},
parse: {
parsers: {
JsonParser,
YamlParser,
OpenApiJson3_1Parser,
OpenApiYaml3_1Parser,
},
},
dereference: {
strategies: { OpenApi3_1SwaggerClientDereferenceStrategy },
},
};

function Swagger(url, opts = {}) {
// Allow url as a separate argument
Expand Down Expand Up @@ -107,3 +130,4 @@ Swagger.prototype.applyDefaults = function applyDefaults() {
export const { helpers } = Swagger;

export default Swagger;
/* eslint-enable camelcase */

0 comments on commit 6e5537d

Please sign in to comment.