Skip to content

Commit 2bc3eee

Browse files
committed
fix: use mutable arrays
1 parent 05207e0 commit 2bc3eee

7 files changed

Lines changed: 65 additions & 60 deletions

File tree

.changeset/clear-toes-enjoy.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hey-api/spec-types": patch
3+
---
4+
5+
**types**: fix: use mutable arrays

packages/spec-types/src/extensions/openapi.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ export interface EnumExtensions {
4646
/**
4747
* `x-enum-descriptions` are {@link https://stackoverflow.com/a/66471626 supported} by OpenAPI Generator.
4848
*/
49-
'x-enum-descriptions'?: ReadonlyArray<string>;
49+
'x-enum-descriptions'?: Array<string>;
5050
/**
5151
* `x-enum-varnames` are {@link https://stackoverflow.com/a/66471626 supported} by OpenAPI Generator.
5252
*/
53-
'x-enum-varnames'?: ReadonlyArray<string>;
53+
'x-enum-varnames'?: Array<string>;
5454
/**
5555
* {@link https://github.com/RicoSuter/NSwag NSwag} generates `x-enumNames` field containing custom enum names.
5656
*/
57-
'x-enumNames'?: ReadonlyArray<string>;
57+
'x-enumNames'?: Array<string>;
5858
}
5959

6060
/**

packages/spec-types/src/json-schema/draft-2020-12/spec.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ export interface Document
3030
*
3131
* {@link https://json-schema.org/understanding-json-schema/reference/combining#allof allOf} can not be used to "extend" a schema to add more details to it in the sense of object-oriented inheritance. {@link https://json-schema.org/learn/glossary#instance Instances} must independently be valid against "all of" the schemas in the `allOf`. See the section on {@link https://json-schema.org/understanding-json-schema/reference/object#extending Extending Closed Schemas} for more information.
3232
*/
33-
allOf?: ReadonlyArray<Document>;
33+
allOf?: Array<Document>;
3434
/**
3535
* `anyOf`: (OR) Must be valid against _any_ of the subschemas
3636
*
3737
* To validate against `anyOf`, the given data must be valid against any (one or more) of the given subschemas.
3838
*/
39-
anyOf?: ReadonlyArray<Document>;
39+
anyOf?: Array<Document>;
4040
/**
4141
* The `const` keyword is used to restrict a value to a single value.
4242
*/
@@ -62,7 +62,7 @@ export interface Document
6262
/**
6363
* The `dependentRequired` {@link https://json-schema.org/learn/glossary#keyword keyword} conditionally requires that certain properties must be present if a given property is present in an object. For example, suppose we have a {@link https://json-schema.org/learn/glossary#schema schema} representing a customer. If you have their credit card number, you also want to ensure you have a billing address. If you don't have their credit card number, a billing address would not be required. We represent this dependency of one property on another using the `dependentRequired` keyword. The value of the `dependentRequired` keyword is an object. Each entry in the object maps from the name of a property, _p_, to an array of strings listing properties that are required if _p_ is present.
6464
*/
65-
dependentRequired?: Record<string, ReadonlyArray<string>>;
65+
dependentRequired?: Record<string, Array<string>>;
6666
/**
6767
* The `dependentSchemas` keyword conditionally applies a {@link https://json-schema.org/learn/glossary#subschema subschema} when a given property is present. This schema is applied in the same way {@link https://json-schema.org/understanding-json-schema/reference/combining#allof allOf} applies schemas. Nothing is merged or extended. Both schemas apply independently.
6868
*/
@@ -90,11 +90,11 @@ export interface Document
9090
*
9191
* You can use `enum` even without a type, to accept values of different types.
9292
*/
93-
enum?: ReadonlyArray<unknown>;
93+
enum?: Array<unknown>;
9494
/**
9595
* The `examples` keyword is a place to provide an array of examples that validate against the schema. This isn't used for validation, but may help with explaining the effect and purpose of the schema to a reader. Each entry should validate against the schema in which it resides, but that isn't strictly required. There is no need to duplicate the `default` value in the `examples` array, since `default` will be treated as another example.
9696
*/
97-
examples?: ReadonlyArray<unknown>;
97+
examples?: Array<unknown>;
9898
/**
9999
* The `format` keyword allows for basic semantic identification of certain kinds of string values that are commonly used. For example, because JSON doesn't have a "DateTime" type, dates need to be encoded as strings. `format` allows the schema author to indicate that the string value should be interpreted as a date. By default, `format` is just an annotation and does not effect validation.
100100
*
@@ -126,7 +126,7 @@ export interface Document
126126
*
127127
* Careful consideration should be taken when using `oneOf` entries as the nature of it requires verification of _every_ sub-schema which can lead to increased processing times. Prefer `anyOf` where possible.
128128
*/
129-
oneOf?: ReadonlyArray<Document>;
129+
oneOf?: Array<Document>;
130130
/**
131131
* The boolean keywords `readOnly` and `writeOnly` are typically used in an API context. `readOnly` indicates that a value should not be modified. It could be used to indicate that a `PUT` request that changes a value would result in a `400 Bad Request` response. `writeOnly` indicates that a value may be set, but will remain hidden. In could be used to indicate you can set a value with a `PUT` request, but it would not be included when retrieving that record with a `GET` request.
132132
*/
@@ -187,7 +187,7 @@ export interface ArrayKeywords {
187187
/**
188188
* `prefixItems` is an array, where each item is a schema that corresponds to each index of the document's array. That is, an array where the first element validates the first element of the input array, the second element validates the second element of the input array, etc.
189189
*/
190-
prefixItems?: ReadonlyArray<Document>;
190+
prefixItems?: Array<Document>;
191191
/**
192192
* The `unevaluatedItems` keyword is useful mainly when you want to add or disallow extra items to an array.
193193
*
@@ -311,7 +311,7 @@ export interface ObjectKeywords {
311311
*
312312
* The `required` keyword takes an array of zero or more strings. Each of these strings must be unique.
313313
*/
314-
required?: ReadonlyArray<string>;
314+
required?: Array<string>;
315315
/**
316316
* The `unevaluatedProperties` keyword is similar to `additionalProperties` except that it can recognize properties declared in subschemas. So, the example from the previous section can be rewritten without the need to redeclare properties.
317317
*

packages/spec-types/src/json-schema/draft-4/spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export interface Document extends EnumExtensions {
2222
*
2323
* You can use `enum` even without a type, to accept values of different types.
2424
*/
25-
enum?: ReadonlyArray<unknown>;
25+
enum?: Array<unknown>;
2626
/**
2727
* Ranges of numbers are specified using a combination of the `minimum` and `maximum` keywords, (or `exclusiveMinimum` and `exclusiveMaximum` for expressing exclusive range).
2828
*
@@ -128,7 +128,7 @@ export interface Document extends EnumExtensions {
128128
*
129129
* The `required` keyword takes an array of zero or more strings. Each of these strings must be unique.
130130
*/
131-
required?: ReadonlyArray<string>;
131+
required?: Array<string>;
132132
/**
133133
* The `title` and `description` keywords must be strings. A "title" will preferably be short, whereas a "description" will provide a more lengthy explanation about the purpose of the data described by the schema.
134134
*/

packages/spec-types/src/openapi/v2/spec.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export interface Document {
1717
/**
1818
* A list of MIME types the APIs can consume. This is global to all APIs but can be overridden on specific API calls. Value MUST be as described under {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#mime-types Mime Types}.
1919
*/
20-
consumes?: ReadonlyArray<string>;
20+
consumes?: Array<string>;
2121
/**
2222
* An object to hold data types produced and consumed by operations.
2323
*/
@@ -45,19 +45,19 @@ export interface Document {
4545
/**
4646
* A list of MIME types the APIs can produce. This is global to all APIs but can be overridden on specific API calls. Value MUST be as described under {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#mime-types Mime Types}.
4747
*/
48-
produces?: ReadonlyArray<string>;
48+
produces?: Array<string>;
4949
/**
5050
* An object to hold responses that can be used across operations. This property _does not_ define global responses for all operations.
5151
*/
5252
responses?: ResponsesDefinitionsObject;
5353
/**
5454
* The transfer protocol of the API. Values MUST be from the list: `"http"`, `"https"`, `"ws"`, `"wss"`. If the `schemes` is not included, the default scheme to be used is the one used to access the Swagger definition itself.
5555
*/
56-
schemes?: ReadonlyArray<'http' | 'https' | 'ws' | 'wss'>;
56+
schemes?: Array<'http' | 'https' | 'ws' | 'wss'>;
5757
/**
5858
* A declaration of which security schemes are applied for the API as a whole. The list of values describes alternative security schemes that can be used (that is, there is a logical OR between the security requirements). Individual operations can override this definition.
5959
*/
60-
security?: ReadonlyArray<SecurityRequirementObject>;
60+
security?: Array<SecurityRequirementObject>;
6161
/**
6262
* Security scheme definitions that can be used across the specification.
6363
*/
@@ -69,7 +69,7 @@ export interface Document {
6969
/**
7070
* A list of tags used by the specification with additional metadata. The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#operation-object Operation Object} must be declared. The tags that are not declared may be organized randomly or based on the tools' logic. Each tag name in the list MUST be unique.
7171
*/
72-
tags?: ReadonlyArray<TagObject>;
72+
tags?: Array<TagObject>;
7373
}
7474

7575
/**
@@ -219,7 +219,7 @@ export interface HeaderObject extends EnumExtensions, OpenAPIV2NullableExtension
219219
/**
220220
* See {@link https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.1 https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.1}.
221221
*/
222-
enum?: ReadonlyArray<unknown>;
222+
enum?: Array<unknown>;
223223
/**
224224
* See {@link https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.1.2 https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.1.2}.
225225
*/
@@ -401,7 +401,7 @@ export interface ItemsObject extends EnumExtensions, OpenAPIV2NullableExtensions
401401
/**
402402
* See {@link https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.1 https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.1}.
403403
*/
404-
enum?: ReadonlyArray<unknown>;
404+
enum?: Array<unknown>;
405405
/**
406406
* See {@link https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.1.2 https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.1.2}.
407407
*/
@@ -534,7 +534,7 @@ export interface OperationObject {
534534
/**
535535
* A list of MIME types the operation can consume. This overrides the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#swaggerConsumes `consumes`} definition at the Swagger Object. An empty value MAY be used to clear the global definition. Value MUST be as described under {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#mime-types Mime Types}.
536536
*/
537-
consumes?: ReadonlyArray<string>;
537+
consumes?: Array<string>;
538538
/**
539539
* Declares this operation to be deprecated. Usage of the declared operation should be refrained. Default value is `false`.
540540
*/
@@ -554,35 +554,35 @@ export interface OperationObject {
554554
/**
555555
* A list of parameters that are applicable for this operation. If a parameter is already defined at the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#pathItemParameters Path Item}, the new definition will override it, but can never remove it. The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#parameterName name} and {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#parameterIn location}. The list can use the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#reference-object Reference Object} to link to parameters that are defined at the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#swaggerParameters Swagger Object's parameters}. There can be one "body" parameter at most.
556556
*/
557-
parameters?: ReadonlyArray<ParameterObject | ReferenceObject>;
557+
parameters?: Array<ParameterObject | ReferenceObject>;
558558
/**
559559
* A list of MIME types the operation can produce. This overrides the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#swaggerProduces `produces`} definition at the Swagger Object. An empty value MAY be used to clear the global definition. Value MUST be as described under {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#mime-types Mime Types}.
560560
*/
561-
produces?: ReadonlyArray<string>;
561+
produces?: Array<string>;
562562
/**
563563
* **Required**. The list of possible responses as they are returned from executing this operation.
564564
*/
565565
responses: ResponsesObject;
566566
/**
567567
* The transfer protocol for the operation. Values MUST be from the list: `"http"`, `"https"`, `"ws"`, `"wss"`. The value overrides the Swagger Object {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#swaggerSchemes `schemes`} definition.
568568
*/
569-
schemes?: ReadonlyArray<'http' | 'https' | 'ws' | 'wss'>;
569+
schemes?: Array<'http' | 'https' | 'ws' | 'wss'>;
570570
/**
571571
* A declaration of which security schemes are applied for this operation. The list of values describes alternative security schemes that can be used (that is, there is a logical OR between the security requirements). This definition overrides any declared top-level {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#swaggerSecurity `security`}. To remove a top-level security declaration, an empty array can be used.
572572
*/
573-
security?: ReadonlyArray<SecurityRequirementObject>;
573+
security?: Array<SecurityRequirementObject>;
574574
/**
575575
* A short summary of what the operation does. For maximum readability in the swagger-ui, this field SHOULD be less than 120 characters.
576576
*/
577577
summary?: string;
578578
/**
579579
* A list of tags for API documentation control. Tags can be used for logical grouping of operations by resources or any other qualifier.
580580
*/
581-
tags?: ReadonlyArray<string>;
581+
tags?: Array<string>;
582582
/**
583583
* A list of code samples associated with an operation.
584584
*/
585-
'x-codeSamples'?: ReadonlyArray<CodeSampleObject>;
585+
'x-codeSamples'?: Array<CodeSampleObject>;
586586
}
587587

588588
/**
@@ -739,7 +739,7 @@ export type ParameterObject = EnumExtensions &
739739
/**
740740
* See {@link https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.1 https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.5.1}.
741741
*/
742-
enum?: ReadonlyArray<unknown>;
742+
enum?: Array<unknown>;
743743
/**
744744
* See {@link https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.1.2 https://tools.ietf.org/html/draft-fge-json-schema-validation-00#section-5.1.2}.
745745
*/
@@ -897,7 +897,7 @@ export interface PathItemObject {
897897
/**
898898
* A list of parameters that are applicable for all the operations described under this path. These parameters can be overridden at the operation level, but cannot be removed there. The list MUST NOT include duplicated parameters. A unique parameter is defined by a combination of a {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#parameterName name} and {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#parameterIn location}. The list can use the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#reference-object Reference Object} to link to parameters that are defined at the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#swaggerParameters Swagger Object's parameters}. There can be one "body" parameter at most.
899899
*/
900-
parameters?: ReadonlyArray<ParameterObject | ReferenceObject>;
900+
parameters?: Array<ParameterObject | ReferenceObject>;
901901
/**
902902
* A definition of a PATCH operation on this path.
903903
*/
@@ -1326,7 +1326,7 @@ export interface SchemaObject extends JSONSchemaDraft4, OpenAPIV2NullableExtensi
13261326
*
13271327
* {@link https://json-schema.org/understanding-json-schema/reference/combining#allof allOf} can not be used to "extend" a schema to add more details to it in the sense of object-oriented inheritance. {@link https://json-schema.org/learn/glossary#instance Instances} must independently be valid against "all of" the schemas in the `allOf`. See the section on {@link https://json-schema.org/understanding-json-schema/reference/object#extending Extending Closed Schemas} for more information.
13281328
*/
1329-
allOf?: ReadonlyArray<SchemaObject>;
1329+
allOf?: Array<SchemaObject>;
13301330
/**
13311331
* Adds support for polymorphism. The discriminator is the schema property name that is used to differentiate between other schema that inherit this schema. The property name used MUST be defined at this schema and it MUST be in the `required` property list. When used, the value MUST be the name of this schema or any schema that inherits it.
13321332
*/
@@ -1441,7 +1441,7 @@ export interface SecurityRequirementObject {
14411441
/**
14421442
* Each name must correspond to a security scheme which is declared in the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/2.0.md#securityDefinitions Security Definitions}. If the security scheme is of type `"oauth2"`, then the value is a list of scope names required for the execution. For other security scheme types, the array MUST be empty.
14431443
*/
1444-
[name: string]: ReadonlyArray<string>;
1444+
[name: string]: Array<string>;
14451445
}
14461446

14471447
/**

0 commit comments

Comments
 (0)