<commit_before>import { autoService, name } from 'knifecycle';
import { readdir } from 'fs';
import YError from 'yerror';
import path from 'path';
import { noop } from '../libs/utils';
import { LogService } from 'common-services';
import { OpenAPIV3 } from 'openapi-types';

// Needed to avoid messing up babel builds 🤷
const _require = require;

/* Architecture Note #10: API definitions loader
The `API_DEFINITIONS` service provide a convenient way to
 gather your various API definitions from the handlers you
 created in the `src/handlers` folder.
*/

export type WhookAPIDefinitionsDependencies = {
  PROJECT_SRC: string;
  log?: LogService;
  require?: typeof _require;
  readDir?: typeof _readDir;
};
export type WhookAPIDefinitions = {
  paths: OpenAPIV3.PathsObject;
  components: OpenAPIV3.ComponentsObject;
};
export type WhookAPIOperationConfig = {
  disabled?: boolean;
};
export type WhookAPIOperationAddition = {
  'x-whook'?: WhookAPIOperationConfig;
};
export type WhookAPIHandlerDefinition = {
  path: string;
  method: string;
  operation: OpenAPIV3.OperationObject & WhookAPIOperationAddition;
};
export type WhookAPISchemaDefinition = {
  name: string;
  schema: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject;
};
export type WhookAPIParameterDefinition = {
  name: string;
  parameter: OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject;
};
export type WhookAPIHandlerModule = {<commit_msg>improvement(types): add an optional example property for schemas<commit_after>import { autoService, name } from 'knifecycle';
import { readdir } from 'fs';
import YError from 'yerror';
import path from 'path';
import { noop } from '../libs/utils';
import { LogService } from 'common-services';
import { OpenAPIV3 } from 'openapi-types';

// Needed to avoid messing up babel builds 🤷
const _require = require;

/* Architecture Note #10: API definitions loader
The `API_DEFINITIONS` service provide a convenient way to
 gather your various API definitions from the handlers you
 created in the `src/handlers` folder.
*/

export type WhookAPIDefinitionsDependencies = {
  PROJECT_SRC: string;
  log?: LogService;
  require?: typeof _require;
  readDir?: typeof _readDir;
};
export type WhookAPIDefinitions = {
  paths: OpenAPIV3.PathsObject;
  components: OpenAPIV3.ComponentsObject;
};
export type WhookAPIOperationConfig = {
  disabled?: boolean;
};
export type WhookAPIOperationAddition = {
  'x-whook'?: WhookAPIOperationConfig;
};
export type WhookAPIHandlerDefinition = {
  path: string;
  method: string;
  operation: OpenAPIV3.OperationObject & WhookAPIOperationAddition;
};
export type WhookAPISchemaDefinition = {
  name: string;
  schema: OpenAPIV3.ReferenceObject | OpenAPIV3.SchemaObject;
  example?: any;
};
export type WhookAPIParameterDefinition = {
  name: string;
  parameter: OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject;
};
export type WhookAPIHandlerModule = {
{'fraction_non_alphanumeric': 0.0956641431520991, 'fraction_numerical': 0.006882312456985547, 'mean_word_length': 5.403083700440528, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2359153', 'n_tokens_mistral': 874, 'n_tokens_neox': 878, 'n_words': 263}