@effect/platform 0.66.0 → 0.66.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/OpenApiJsonSchema/package.json +6 -0
- package/dist/cjs/OpenApi.js +7 -12
- package/dist/cjs/OpenApi.js.map +1 -1
- package/dist/cjs/OpenApiJsonSchema.js +492 -0
- package/dist/cjs/OpenApiJsonSchema.js.map +1 -0
- package/dist/cjs/index.js +3 -1
- package/dist/dts/OpenApi.d.ts +5 -10
- package/dist/dts/OpenApi.d.ts.map +1 -1
- package/dist/dts/OpenApiJsonSchema.d.ts +183 -0
- package/dist/dts/OpenApiJsonSchema.d.ts.map +1 -0
- package/dist/dts/index.d.ts +4 -0
- package/dist/dts/index.d.ts.map +1 -1
- package/dist/esm/OpenApi.js +7 -12
- package/dist/esm/OpenApi.js.map +1 -1
- package/dist/esm/OpenApiJsonSchema.js +482 -0
- package/dist/esm/OpenApiJsonSchema.js.map +1 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/package.json +11 -3
- package/src/OpenApi.ts +11 -23
- package/src/OpenApiJsonSchema.ts +714 -0
- package/src/index.ts +5 -0
package/src/OpenApi.ts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* @since 1.0.0
|
|
3
3
|
*/
|
|
4
4
|
import * as AST from "@effect/schema/AST"
|
|
5
|
-
import * as JSONSchema from "@effect/schema/JSONSchema"
|
|
6
5
|
import * as Schema from "@effect/schema/Schema"
|
|
7
6
|
import * as Context from "effect/Context"
|
|
8
7
|
import { dual } from "effect/Function"
|
|
@@ -13,6 +12,7 @@ import * as HttpApi from "./HttpApi.js"
|
|
|
13
12
|
import * as HttpApiSchema from "./HttpApiSchema.js"
|
|
14
13
|
import type { HttpApiSecurity } from "./HttpApiSecurity.js"
|
|
15
14
|
import * as HttpMethod from "./HttpMethod.js"
|
|
15
|
+
import * as JsonSchema from "./OpenApiJsonSchema.js"
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @since 1.0.0
|
|
@@ -234,7 +234,7 @@ export const fromApi = <A extends HttpApi.HttpApi.Any>(api: A): OpenAPISpec => {
|
|
|
234
234
|
op.requestBody = {
|
|
235
235
|
content: {
|
|
236
236
|
[HttpApiSchema.getMultipart(schema.ast) ? "multipart/form-data" : "application/json"]: {
|
|
237
|
-
schema:
|
|
237
|
+
schema: JsonSchema.make(schema)
|
|
238
238
|
}
|
|
239
239
|
},
|
|
240
240
|
required: true
|
|
@@ -245,13 +245,13 @@ export const fromApi = <A extends HttpApi.HttpApi.Any>(api: A): OpenAPISpec => {
|
|
|
245
245
|
Option.map((ast) => {
|
|
246
246
|
op.responses![successStatus].content = {
|
|
247
247
|
[successEncoding.contentType]: {
|
|
248
|
-
schema:
|
|
248
|
+
schema: JsonSchema.make(Schema.make(ast))
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
251
|
})
|
|
252
252
|
)
|
|
253
253
|
if (Option.isSome(endpoint.pathSchema)) {
|
|
254
|
-
const schema =
|
|
254
|
+
const schema = JsonSchema.make(endpoint.pathSchema.value) as JsonSchema.Object
|
|
255
255
|
if ("properties" in schema) {
|
|
256
256
|
Object.entries(schema.properties).forEach(([name, jsonSchema]) => {
|
|
257
257
|
op.parameters!.push({
|
|
@@ -264,7 +264,7 @@ export const fromApi = <A extends HttpApi.HttpApi.Any>(api: A): OpenAPISpec => {
|
|
|
264
264
|
}
|
|
265
265
|
}
|
|
266
266
|
if (!HttpMethod.hasBody(endpoint.method) && Option.isSome(endpoint.payloadSchema)) {
|
|
267
|
-
const schema =
|
|
267
|
+
const schema = JsonSchema.make(endpoint.payloadSchema.value) as JsonSchema.Object
|
|
268
268
|
if ("properties" in schema) {
|
|
269
269
|
Object.entries(schema.properties).forEach(([name, jsonSchema]) => {
|
|
270
270
|
op.parameters!.push({
|
|
@@ -277,7 +277,7 @@ export const fromApi = <A extends HttpApi.HttpApi.Any>(api: A): OpenAPISpec => {
|
|
|
277
277
|
}
|
|
278
278
|
}
|
|
279
279
|
if (Option.isSome(endpoint.headersSchema)) {
|
|
280
|
-
const schema =
|
|
280
|
+
const schema = JsonSchema.make(endpoint.headersSchema.value) as JsonSchema.Object
|
|
281
281
|
if ("properties" in schema) {
|
|
282
282
|
Object.entries(schema.properties).forEach(([name, jsonSchema]) => {
|
|
283
283
|
op.parameters!.push({
|
|
@@ -299,7 +299,7 @@ export const fromApi = <A extends HttpApi.HttpApi.Any>(api: A): OpenAPISpec => {
|
|
|
299
299
|
Option.map((ast) => {
|
|
300
300
|
op.responses![status].content = {
|
|
301
301
|
"application/json": {
|
|
302
|
-
schema:
|
|
302
|
+
schema: JsonSchema.make(Schema.make(ast))
|
|
303
303
|
}
|
|
304
304
|
}
|
|
305
305
|
})
|
|
@@ -361,12 +361,6 @@ const getDescriptionOrIdentifier = (ast: Option.Option<AST.PropertySignature | A
|
|
|
361
361
|
)
|
|
362
362
|
)
|
|
363
363
|
|
|
364
|
-
const makeJsonSchema = (schema: Schema.Schema.All): OpenAPIJSONSchema => {
|
|
365
|
-
const jsonSchema = JSONSchema.make(schema as any)
|
|
366
|
-
delete jsonSchema.$schema
|
|
367
|
-
return jsonSchema
|
|
368
|
-
}
|
|
369
|
-
|
|
370
364
|
/**
|
|
371
365
|
* @category models
|
|
372
366
|
* @since 1.0.0
|
|
@@ -478,12 +472,6 @@ export type OpenAPISpecPathItem =
|
|
|
478
472
|
readonly parameters?: Array<OpenAPISpecParameter>
|
|
479
473
|
}
|
|
480
474
|
|
|
481
|
-
/**
|
|
482
|
-
* @category models
|
|
483
|
-
* @since 1.0.0
|
|
484
|
-
*/
|
|
485
|
-
export type OpenAPIJSONSchema = JSONSchema.JsonSchema7
|
|
486
|
-
|
|
487
475
|
/**
|
|
488
476
|
* @category models
|
|
489
477
|
* @since 1.0.0
|
|
@@ -491,7 +479,7 @@ export type OpenAPIJSONSchema = JSONSchema.JsonSchema7
|
|
|
491
479
|
export interface OpenAPISpecParameter {
|
|
492
480
|
readonly name: string
|
|
493
481
|
readonly in: "query" | "header" | "path" | "cookie"
|
|
494
|
-
readonly schema:
|
|
482
|
+
readonly schema: JsonSchema.JsonSchema
|
|
495
483
|
readonly description?: string
|
|
496
484
|
readonly required?: boolean
|
|
497
485
|
readonly deprecated?: boolean
|
|
@@ -524,7 +512,7 @@ export type OpenApiSpecContent = {
|
|
|
524
512
|
*/
|
|
525
513
|
export interface OpenApiSpecResponseHeader {
|
|
526
514
|
readonly description?: string
|
|
527
|
-
readonly schema:
|
|
515
|
+
readonly schema: JsonSchema.JsonSchema
|
|
528
516
|
}
|
|
529
517
|
|
|
530
518
|
/**
|
|
@@ -551,7 +539,7 @@ export interface OpenApiSpecResponse {
|
|
|
551
539
|
* @since 1.0.0
|
|
552
540
|
*/
|
|
553
541
|
export interface OpenApiSpecMediaType {
|
|
554
|
-
readonly schema?:
|
|
542
|
+
readonly schema?: JsonSchema.JsonSchema
|
|
555
543
|
readonly example?: object
|
|
556
544
|
readonly description?: string
|
|
557
545
|
}
|
|
@@ -571,7 +559,7 @@ export interface OpenAPISpecRequestBody {
|
|
|
571
559
|
* @since 1.0.0
|
|
572
560
|
*/
|
|
573
561
|
export interface OpenAPIComponents {
|
|
574
|
-
readonly schemas?: ReadonlyRecord<string,
|
|
562
|
+
readonly schemas?: ReadonlyRecord<string, JsonSchema.JsonSchema>
|
|
575
563
|
readonly securitySchemes?: ReadonlyRecord<string, OpenAPISecurityScheme>
|
|
576
564
|
}
|
|
577
565
|
|