Skip to content

Commit

Permalink
feat(parser): 基础解析
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudcome committed Apr 13, 2023
1 parent 83b24ef commit c91ba35
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/parsers/BaseParser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { OpenAPIV3 } from 'openapi-types';
import { Named } from './Named';
import { ParseOptions } from './types';

export class BaseParser {
named = new Named();

static defaults: ParseOptions = {
okCode: 200,
okMediaType: 'application/json',
};

options: ParseOptions;

constructor(protected readonly document: OpenAPIV3.Document, options?: Partial<ParseOptions>) {
this.options = Object.assign({}, BaseParser.defaults, options);
}

protected isReference(
object: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject | OpenAPIV3.ParameterObject | OpenAPIV3.RequestBodyObject
): object is OpenAPIV3.ReferenceObject {
return '$ref' in object;
}
}

0 comments on commit c91ba35

Please sign in to comment.