• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

panates / opra / 29494915195

16 Jul 2026 11:33AM UTC coverage: 83.024% (+0.4%) from 82.653%
29494915195

push

github

erayhanoglu
1.29.1

4118 of 5238 branches covered (78.62%)

Branch coverage included in aggregate %.

34348 of 41093 relevant lines covered (83.59%)

239.47 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

96.91
/packages/common/src/document/http/http-parameter.ts
1
import { omitUndefined } from '@jsopen/objects';
1✔
2
import {
1✔
3
  asMutable,
1✔
4
  type Combine,
1✔
5
  type StrictOmit,
1✔
6
  type Type,
1✔
7
  type TypeThunkAsync,
1✔
8
} from 'ts-gems';
1✔
9
import { type Validator, vg } from 'valgen';
1✔
10
import type { OpraSchema } from '../../schema/index.js';
1✔
11
import type { ApiDocument } from '../api-document.js';
1,165!
12
import { DocumentElement } from '../common/document-element.js';
1,165✔
13
import { Value } from '../common/value.js';
1,165✔
14
import { DataType } from '../data-type/data-type.js';
1,165✔
15
import type { EnumType } from '../data-type/enum-type.js';
1,165✔
16
import { parseRegExp } from '../utils/parse-regexp.util.js';
1,151✔
17

2✔
18
/**
2✔
19
 * @namespace HttpParameter
2✔
20
 */
2✔
21
export namespace HttpParameter {
1,151✔
22
  export interface Metadata extends StrictOmit<
1,165✔
23
    OpraSchema.HttpParameter,
1,165✔
24
    'type'
1,165✔
25
  > {
1,165✔
26
    name: string | RegExp;
1,165✔
27
    type?:
1,165✔
28
      | string
1,165✔
29
      | TypeThunkAsync
1,165✔
30
      | EnumType.EnumObject
1,165✔
31
      | EnumType.EnumArray
1,165✔
32
      | object;
1,165✔
33
    keyParam?: boolean;
1,165✔
34
    designType?: Type;
1,165✔
35
  }
1,165✔
36

1,165✔
37
  export interface Options extends Partial<StrictOmit<Metadata, 'type'>> {
1,165✔
38
    type?: string | TypeThunkAsync | object;
1,165✔
39
    parser?: (v: any) => any;
1,165✔
40
  }
1✔
41

1✔
42
  export interface InitArguments extends Combine<
1✔
43
    {
1✔
44
      type?: DataType;
1✔
45
    },
1✔
46
    Metadata
1✔
47
  > {
1,253✔
48
    parser?: (v: any) => any;
1,253✔
49
  }
1,253✔
50
}
1,253✔
51

1,253✔
52
/**
1,253✔
53
 * Type definition for HttpParameter
1,253✔
54
 * @class HttpParameter
1,253✔
55
 */
1,253✔
56
interface HttpParameterStatic {
1,253✔
57
  new (
1,253✔
58
    owner: DocumentElement,
1,253✔
59
    args: HttpParameter.InitArguments,
1,253✔
60
  ): HttpParameter;
1,253✔
61

1,253✔
62
  prototype: HttpParameter;
1,253✔
63
}
1,253✔
64

1,253✔
65
/**
1,253✔
66
 * Type definition of HttpParameter prototype
1,253✔
67
 * @interface HttpParameter
1,253✔
68
 */
1,253✔
69
export interface HttpParameter extends HttpParameterClass {}
1✔
70

50✔
71
export const HttpParameter = function (
50✔
72
  this: HttpParameter,
50✔
73
  owner: DocumentElement,
50✔
74
  initArgs: HttpParameter.InitArguments,
50✔
75
) {
50✔
76
  if (!this)
50!
77
    throw new TypeError('"this" should be passed to call class constructor');
50!
78
  Value.call(this, owner, initArgs);
×
79
  const _this = asMutable(this);
×
80
  if (initArgs.name) {
50✔
81
    _this.name =
1✔
82
      initArgs.name instanceof RegExp
1✔
83
        ? initArgs.name
1✔
84
        : initArgs.name.startsWith('/')
1✔
85
          ? parseRegExp(initArgs.name, {
1✔
86
              includeFlags: 'i',
1✔
87
              excludeFlags: 'm',
1✔
88
            })
1✔
89
          : initArgs.name;
1✔
90
  }
1✔
91
  _this.location = initArgs.location;
1✔
92
  _this.deprecated = initArgs.deprecated;
1✔
93
  _this.required = initArgs.required;
1✔
94
  if (_this.required == null && initArgs.location === 'path')
1✔
95
    _this.required = true;
1✔
96
  _this.default = initArgs.default;
1✔
97
  _this.arraySeparator = initArgs.arraySeparator;
1✔
98
  _this.keyParam = initArgs.keyParam;
1✔
99
  _this.parser = initArgs.parser;
1✔
100
  _this.designType = initArgs.designType;
1✔
101
} as Function as HttpParameterStatic;
1✔
102

1✔
103
/**
1✔
104
 * @class HttpParameter
1✔
105
 */
1✔
106
class HttpParameterClass extends Value {
1✔
107
  declare readonly owner: DocumentElement;
1✔
108
  declare location: OpraSchema.HttpParameterLocation;
1✔
109
  declare keyParam?: boolean;
1✔
110
  declare deprecated?: boolean | string;
1✔
111
  declare required?: boolean;
1✔
112
  declare readonly default?: any;
1✔
113
  declare arraySeparator?: string;
1✔
114
  declare parser?: (v: any) => any;
1✔
115
  declare designType?: Type;
1✔
116

1✔
117
  toJSON(options?: ApiDocument.ExportOptions): OpraSchema.HttpParameter {
1✔
118
    return omitUndefined<OpraSchema.HttpParameter>({
1✔
119
      ...super.toJSON(options),
1✔
120
      name: this.name,
1✔
121
      location: this.location,
1✔
122
      arraySeparator: this.arraySeparator,
1✔
123
      keyParam: this.keyParam,
1✔
124
      required: this.required,
1✔
125
      default: this.default,
1✔
126
      deprecated: this.deprecated,
1✔
127
    });
1✔
128
  }
1✔
129

1✔
130
  generateCodec(
1✔
131
    codec: 'encode' | 'decode',
1✔
132
    options?: DataType.GenerateCodecOptions,
1✔
133
    properties?: any,
1✔
134
  ): Validator {
1✔
135
    const fn =
1✔
136
      this.type?.generateCodec(codec, options, {
1✔
137
        ...properties,
1✔
138
        designType: this.designType,
1✔
139
      }) || vg.isAny();
1✔
140
    if (this.default !== undefined) {
1✔
141
      return vg.required(fn, {
1✔
142
        default: this.default,
1✔
143
      });
1✔
144
    }
1✔
145
    return fn;
1✔
146
  }
1✔
147
}
1✔
148

1✔
149
HttpParameter.prototype = HttpParameterClass.prototype;
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc