fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

test: fix typecheck

Lubos b4a8afe0 12fa7d62

+46 -31
+5
.changeset/deep-paws-call.md
··· 1 + --- 2 + "@hey-api/spec-types": minor 3 + --- 4 + 5 + **BREAKING**: rename `OpenAPIExtensions` to `SpecExtensions`
+5
.changeset/olive-sides-mate.md
··· 1 + --- 2 + "@hey-api/spec-types": minor 3 + --- 4 + 5 + **BREAKING**: remove OpenAPI types from JSON Schema documents
+5 -5
packages/shared/src/ir/types.ts
··· 1 1 /* eslint-disable @typescript-eslint/no-namespace */ 2 2 import type { Symbol } from '@hey-api/codegen-core'; 3 - import type { JSONSchemaDraft2020_12, OpenAPIExtensions, OpenAPIV3_1 } from '@hey-api/spec-types'; 3 + import type { JSONSchemaDraft2020_12, OpenAPIV3_1, SpecExtensions } from '@hey-api/spec-types'; 4 4 5 5 import type { IRMediaType } from './mediaType'; 6 6 ··· 22 22 schemas?: Record<string, IRSchemaObject>; 23 23 } 24 24 25 - export interface IROperationObject extends OpenAPIExtensions { 25 + export interface IROperationObject extends SpecExtensions { 26 26 body?: IRBodyObject; 27 27 deprecated?: boolean; 28 28 description?: string; ··· 46 46 } 47 47 48 48 export interface IRParameterObject 49 - extends Pick<JSONSchemaDraft2020_12.Document, 'deprecated' | 'description'>, OpenAPIExtensions { 49 + extends Pick<JSONSchemaDraft2020_12.Document, 'deprecated' | 'description'>, SpecExtensions { 50 50 /** 51 51 * Determines whether the parameter value SHOULD allow reserved characters, as defined by RFC3986 `:/?#[]@!$&'()*+,;=` to be included without percent-encoding. The default value is `false`. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded` or `multipart/form-data`. If a value is explicitly defined, then the value of `contentType` (implicit or explicit) SHALL be ignored. 52 52 */ ··· 130 130 | 'pattern' 131 131 | 'required' 132 132 | 'title' 133 - | 'example' 134 133 >, 135 - OpenAPIExtensions { 134 + Pick<OpenAPIV3_1.SchemaObject, 'example'>, 135 + SpecExtensions { 136 136 /** 137 137 * If the schema is intended to be used as an object property, it can be 138 138 * marked as read-only or write-only. This value controls whether the schema
+23 -20
packages/spec-types/src/json-schema/draft-2020-12/spec.ts
··· 1 1 import type { AnyString, MaybeArray } from '@hey-api/types'; 2 2 3 3 // TODO: left out some keywords related to structuring a complex schema and declaring a dialect 4 - export interface Document extends ArrayKeywords, NumberKeywords, ObjectKeywords, StringKeywords { 4 + export interface BaseDocument<TDocument = unknown> 5 + extends ArrayKeywords<TDocument>, NumberKeywords, ObjectKeywords<TDocument>, StringKeywords { 5 6 /** 6 7 * The `$comment` {@link https://json-schema.org/learn/glossary#keyword keyword} is strictly intended for adding comments to a schema. Its value must always be a string. Unlike the annotations `title`, `description`, and `examples`, JSON schema {@link https://json-schema.org/learn/glossary#implementation implementations} aren't allowed to attach any meaning or behavior to it whatsoever, and may even strip them at any time. Therefore, they are useful for leaving notes to future editors of a JSON schema, but should not be used to communicate to users of the schema. 7 8 */ ··· 19 20 * 20 21 * {@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. 21 22 */ 22 - allOf?: Array<Document>; 23 + allOf?: Array<TDocument>; 23 24 /** 24 25 * `anyOf`: (OR) Must be valid against _any_ of the subschemas 25 26 * 26 27 * To validate against `anyOf`, the given data must be valid against any (one or more) of the given subschemas. 27 28 */ 28 - anyOf?: Array<Document>; 29 + anyOf?: Array<TDocument>; 29 30 /** 30 31 * The `const` keyword is used to restrict a value to a single value. 31 32 */ ··· 55 56 /** 56 57 * 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. 57 58 */ 58 - dependentSchemas?: Record<string, Document>; 59 + dependentSchemas?: Record<string, TDocument>; 59 60 /** 60 61 * The `deprecated` keyword is a boolean that indicates that the {@link https://json-schema.org/learn/glossary#instance instance} value the keyword applies to should not be used and may be removed in the future. 61 62 */ ··· 73 74 * 74 75 * If `then` and/or `else` appear in a schema without `if`, `then` and `else` are ignored. 75 76 */ 76 - else?: Document; 77 + else?: TDocument; 77 78 /** 78 79 * The `enum` {@link https://json-schema.org/learn/glossary#keyword keyword} is used to restrict a value to a fixed set of values. It must be an array with at least one element, where each element is unique. 79 80 * ··· 101 102 * 102 103 * If `then` and/or `else` appear in a schema without `if`, `then` and `else` are ignored. 103 104 */ 104 - if?: Document; 105 + if?: TDocument; 105 106 /** 106 107 * `not`: (NOT) Must _not_ be valid against the given schema 107 108 * 108 109 * The `not` keyword declares that an instance validates if it doesn't validate against the given subschema. 109 110 */ 110 - not?: Document; 111 + not?: TDocument; 111 112 /** 112 113 * `oneOf`: (XOR) Must be valid against _exactly one_ of the subschemas 113 114 * ··· 115 116 * 116 117 * 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. 117 118 */ 118 - oneOf?: Array<Document>; 119 + oneOf?: Array<TDocument>; 119 120 /** 120 121 * 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. 121 122 */ ··· 129 130 * 130 131 * If `then` and/or `else` appear in a schema without `if`, `then` and `else` are ignored. 131 132 */ 132 - then?: Document; 133 + then?: TDocument; 133 134 /** 134 135 * 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. 135 136 */ ··· 144 145 writeOnly?: boolean; 145 146 } 146 147 147 - export interface ArrayKeywords { 148 + export type Document = BaseDocument<Document>; 149 + 150 + export interface ArrayKeywords<TDocument = unknown> { 148 151 /** 149 152 * While the `items` schema must be valid for every item in the array, the `contains` schema only needs to validate against one or more items in the array. 150 153 */ 151 - contains?: Document; 154 + contains?: TDocument; 152 155 /** 153 156 * List validation is useful for arrays of arbitrary length where each item matches the same schema. For this kind of array, set the `items` {@link https://json-schema.org/learn/glossary#keyword keyword} to a single schema that will be used to validate all of the items in the array. 154 157 * ··· 156 159 * 157 160 * Note that `items` doesn't "see inside" any {@link https://json-schema.org/learn/glossary#instance instances} of `allOf`, `anyOf`, or `oneOf` in the same {@link https://json-schema.org/learn/glossary#subschema subschema}. 158 161 */ 159 - items?: Document | false; 162 + items?: TDocument | false; 160 163 /** 161 164 * `minContains` and `maxContains` can be used with `contains` to further specify how many times a schema matches a `contains` constraint. These keywords can be any non-negative number including zero. 162 165 */ ··· 176 179 /** 177 180 * `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. 178 181 */ 179 - prefixItems?: Array<Document>; 182 + prefixItems?: Array<TDocument>; 180 183 /** 181 184 * The `unevaluatedItems` keyword is useful mainly when you want to add or disallow extra items to an array. 182 185 * ··· 186 189 * 187 190 * Like with `items`, if you set `unevaluatedItems` to false, you can disallow extra items in the array. 188 191 */ 189 - unevaluatedItems?: Document | false; 192 + unevaluatedItems?: TDocument | false; 190 193 /** 191 194 * A schema can ensure that each of the items in an array is unique. Simply set the `uniqueItems` keyword to `true`. 192 195 */ ··· 260 263 multipleOf?: number; 261 264 } 262 265 263 - export interface ObjectKeywords { 266 + export interface ObjectKeywords<TDocument = unknown> { 264 267 /** 265 268 * The `additionalProperties` keyword is used to control the handling of extra stuff, that is, properties whose names are not listed in the `properties` keyword or match any of the regular expressions in the `patternProperties` keyword. By default any additional properties are allowed. 266 269 * ··· 268 271 * 269 272 * It's important to note that `additionalProperties` only recognizes properties declared in the same {@link https://json-schema.org/learn/glossary#subschema subschema} as itself. So, `additionalProperties` can restrict you from "extending" a schema using {@link https://json-schema.org/understanding-json-schema/reference/combining combining} keywords such as {@link https://json-schema.org/understanding-json-schema/reference/combining#allof allOf}. 270 273 */ 271 - additionalProperties?: Document | false; 274 + additionalProperties?: TDocument | false; 272 275 /** 273 276 * The number of properties on an object can be restricted using the `minProperties` and `maxProperties` keywords. Each of these must be a non-negative integer. 274 277 */ ··· 280 283 /** 281 284 * Sometimes you want to say that, given a particular kind of property name, the value should match a particular schema. That's where `patternProperties` comes in: it maps regular expressions to schemas. If a property name matches the given regular expression, the property value must validate against the corresponding schema. 282 285 */ 283 - patternProperties?: Record<string, Document>; 286 + patternProperties?: Record<string, TDocument>; 284 287 /** 285 288 * The properties (key-value pairs) on an object are defined using the `properties` {@link https://json-schema.org/learn/glossary#keyword keyword}. The value of `properties` is an object, where each key is the name of a property and each value is a {@link https://json-schema.org/learn/glossary#schema schema} used to validate that property. Any property that doesn't match any of the property names in the `properties` keyword is ignored by this keyword. 286 289 */ 287 - properties?: Record<string, Document | true>; 290 + properties?: Record<string, TDocument | true>; 288 291 /** 289 292 * The names of properties can be validated against a schema, irrespective of their values. This can be useful if you don't want to enforce specific properties, but you want to make sure that the names of those properties follow a specific convention. You might, for example, want to enforce that all names are valid ASCII tokens so they can be used as attributes in a particular programming language. 290 293 * ··· 294 297 * { "type": "string" } 295 298 * ``` 296 299 */ 297 - propertyNames?: Document; 300 + propertyNames?: TDocument; 298 301 /** 299 302 * By default, the properties defined by the `properties` keyword are not required. However, one can provide a list of required properties using the `required` keyword. 300 303 * ··· 306 309 * 307 310 * `unevaluatedProperties` works by collecting any properties that are successfully validated when processing the schemas and using those as the allowed list of properties. This allows you to do more complex things like conditionally adding properties. 308 311 */ 309 - unevaluatedProperties?: Document | false; 312 + unevaluatedProperties?: TDocument | false; 310 313 } 311 314 312 315 export interface StringKeywords {
+1 -1
packages/spec-types/src/openapi/v2/spec.ts
··· 1 1 import type { CodeSampleObject } from '../../extensions/code-samples'; 2 2 import type { EnumExtensions } from '../../extensions/enum'; 3 - import type { Document as JSONSchemaDraft4 } from '../../json-schema/draft-4/spec'; 3 + import type { Document as JSONSchemaDraft4 } from '../../json-schema/draft-4'; 4 4 import type { OpenAPIV2NullableExtensions } from './extensions'; 5 5 6 6 /**
+7 -5
packages/spec-types/src/openapi/v3-1/spec.ts
··· 1 1 import type { CodeSampleObject } from '../../extensions/code-samples'; 2 2 import type { EnumExtensions } from '../../extensions/enum'; 3 3 import type { SpecExtensions } from '../../extensions/spec'; 4 - import type { Document as JSONSchemaDraft2020_12 } from '../../json-schema/draft-2020-12'; 4 + import type { BaseDocument as JSONSchemaDraft2020_12 } from '../../json-schema/draft-2020-12'; 5 5 import type { OpenAPIV3_1SchemaExtensions } from './extensions'; 6 6 7 7 /** ··· 1668 1668 * 1669 1669 * This object MAY be extended with {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions Specification Extensions}, though as noted, additional properties MAY omit the `x-` prefix within this object. 1670 1670 */ 1671 - export type SchemaObject = JSONSchemaDraft2020_12 & 1672 - OpenAPIV3_1SchemaExtensions & 1673 - SpecExtensions & 1674 - EnumExtensions; 1671 + export interface SchemaObject 1672 + extends 1673 + JSONSchemaDraft2020_12<SchemaObject>, 1674 + OpenAPIV3_1SchemaExtensions, 1675 + SpecExtensions, 1676 + EnumExtensions {} 1675 1677 1676 1678 /** 1677 1679 * Lists the required security schemes to execute this operation. The name used for each property MUST correspond to a security scheme declared in the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#componentsSecuritySchemes Security Schemes} under the {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#components-object Components Object}.