| @@ -76,11 +76,12 @@ type OpenApiOperationObject = { · 75 unmodified lines |
| 76 | readonly responses: { | 76 | readonly responses: { |
| 77 | readonly "200": { | 77 | readonly "200": { |
| 78 | readonly description: "Successful response"; | 78 | readonly description: "Successful response"; |
| 79 | readonly content: { | 79 | readonly content: Record< |
| 80 | readonly "application/json": { | 80 | string, |
| | 81 | { |
| 81 | readonly schema: OpenApiSchemaObject; | 82 | readonly schema: OpenApiSchemaObject; |
| 82 | }; | 83 | } |
| 83 | }; | 84 | >; |
| 84 | }; | 85 | }; |
| 85 | }; | 86 | }; |
| 86 | readonly security?: readonly Record<string, readonly string[]>[]; | 87 | readonly security?: readonly Record<string, readonly string[]>[]; |
| @@ -174,6 +175,8 @@ const DiscoveryMethod = Schema.Struct({ · 87 unmodified lines |
| 174 | request: Schema.optional(DiscoveryRef), | 175 | request: Schema.optional(DiscoveryRef), |
| 175 | response: Schema.optional(DiscoveryRef), | 176 | response: Schema.optional(DiscoveryRef), |
| 176 | scopes: TextArray, | 177 | scopes: TextArray, |
| | 178 | supportsMediaDownload: Schema.optional(Schema.Boolean), |
| | 179 | useMediaDownloadService: Schema.optional(Schema.Boolean), |
| 177 | }); | 180 | }); |
| 178 | type DiscoveryMethod = typeof DiscoveryMethod.Type; | 181 | type DiscoveryMethod = typeof DiscoveryMethod.Type; |
| 179 | | 182 | |
| @@ -570,6 +573,33 @@ const discoveryDocumentInfo = ( · 390 unmodified lines |
| 570 | }; | 573 | }; |
| 571 | }); | 574 | }); |
| 572 | | 575 | |
| | 576 | const googleDiscoveryResponseContent = ( |
| | 577 | method: DiscoveryMethod, |
| | 578 | schemaNameForRef: (name: string) => string, |
| | 579 | ): OpenApiOperationObject["responses"]["200"]["content"] => { |
| | 580 | if ( |
| | 581 | (method.supportsMediaDownload === true || method.useMediaDownloadService === true) && |
| | 582 | method.response === undefined |
| | 583 | ) { |
| | 584 | return { |
| | 585 | "application/octet-stream": { |
| | 586 | schema: { |
| | 587 | type: "string", |
| | 588 | format: "binary", |
| | 589 | }, |
| | 590 | }, |
| | 591 | }; |
| | 592 | } |
| | 593 | |
| | 594 | return { |
| | 595 | "application/json": { |
| | 596 | schema: method.response?.$ref |
| | 597 | ? { $ref: schemaRef(schemaNameForRef(method.response.$ref)) } |
| | 598 | : {}, |
| | 599 | }, |
| | 600 | }; |
| | 601 | }; |
| | 602 | |
| 573 | const buildDiscoveryOperation = (input: { | 603 | const buildDiscoveryOperation = (input: { |
| 574 | readonly document: DiscoveryDocument; | 604 | readonly document: DiscoveryDocument; |
| 575 | readonly method: DiscoveryMethod; | 605 | readonly method: DiscoveryMethod; |
| @@ -635,13 +665,7 @@ const buildDiscoveryOperation = (input: { · 59 unmodified lines |
| 635 | responses: { | 665 | responses: { |
| 636 | "200": { | 666 | "200": { |
| 637 | description: "Successful response", | 667 | description: "Successful response", |
| 638 | content: { | 668 | content: googleDiscoveryResponseContent(input.method, schemaNameForRef), |
| 639 | "application/json": { | | |
| 640 | schema: input.method.response?.$ref | | |
| 641 | ? { $ref: schemaRef(schemaNameForRef(input.method.response.$ref)) } | | |
| 642 | : {}, | | |
| 643 | }, | | |
| 644 | }, | | |
| 645 | }, | 669 | }, |
| 646 | }, | 670 | }, |
| 647 | ...(methodScopes.length > 0 ? { security: [{ googleOAuth2: methodScopes }] } : {}), | 671 | ...(methodScopes.length > 0 ? { security: [{ googleOAuth2: methodScopes }] } : {}), |