Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose ApiDOM components as public API #2828

Merged
merged 1 commit into from
Feb 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 */