From a60744958645178c6ede15346b7ed548f2b8197c Mon Sep 17 00:00:00 2001 From: Arda TANRIKULU Date: Wed, 3 Aug 2022 19:20:07 +0300 Subject: [PATCH] Fixes on JSON Machete and OpenAPI handler for #3942 --- .changeset/hot-kids-share.md | 5 + .changeset/serious-bags-visit.md | 5 + .changeset/silly-baboons-explain.md | 5 + .changeset/warm-pumas-warn.md | 13 + packages/json-machete/src/healJSONSchema.ts | 23 +- .../getJSONSchemaOptionsFromOpenAPIOptions.ts | 26 +- .../tests/__snapshots__/docusign.test.ts.snap | 1 - .../__snapshots__/example_api.test.ts.snap | 6 +- .../tests/__snapshots__/toto.test.ts.snap | 1254 +++++++++++++++++ .../loaders/openapi/tests/fixtures/toto.yml | 665 +++++++++ packages/loaders/openapi/tests/toto.test.ts | 19 + 11 files changed, 2005 insertions(+), 17 deletions(-) create mode 100644 .changeset/hot-kids-share.md create mode 100644 .changeset/serious-bags-visit.md create mode 100644 .changeset/silly-baboons-explain.md create mode 100644 .changeset/warm-pumas-warn.md create mode 100644 packages/loaders/openapi/tests/__snapshots__/toto.test.ts.snap create mode 100644 packages/loaders/openapi/tests/fixtures/toto.yml create mode 100644 packages/loaders/openapi/tests/toto.test.ts diff --git a/.changeset/hot-kids-share.md b/.changeset/hot-kids-share.md new file mode 100644 index 0000000000000..4b5068ca64011 --- /dev/null +++ b/.changeset/hot-kids-share.md @@ -0,0 +1,5 @@ +--- +"json-machete": patch +--- + +Respect "required" field in anyOf and allOf schemas and fix the bug that puts an Any schema if this kind of schema is present diff --git a/.changeset/serious-bags-visit.md b/.changeset/serious-bags-visit.md new file mode 100644 index 0000000000000..4d19650a6e350 --- /dev/null +++ b/.changeset/serious-bags-visit.md @@ -0,0 +1,5 @@ +--- +"@omnigraph/openapi": patch +--- + +Respect "\$ref" in parameters diff --git a/.changeset/silly-baboons-explain.md b/.changeset/silly-baboons-explain.md new file mode 100644 index 0000000000000..9476ced2bbfb7 --- /dev/null +++ b/.changeset/silly-baboons-explain.md @@ -0,0 +1,5 @@ +--- +"json-machete": patch +--- + +Use single "Any" schema for unknown types defined in "required" in order to prevent duplication diff --git a/.changeset/warm-pumas-warn.md b/.changeset/warm-pumas-warn.md new file mode 100644 index 0000000000000..e88220ffe5e87 --- /dev/null +++ b/.changeset/warm-pumas-warn.md @@ -0,0 +1,13 @@ +--- +"@omnigraph/openapi": patch +--- + +Respect global parameters object on top of method objects like; +```yml +parameters: # Take this as well + - name: foo + ... +get: + parameters: + - name: bar +``` diff --git a/packages/json-machete/src/healJSONSchema.ts b/packages/json-machete/src/healJSONSchema.ts index 398874e14a723..fe9e12bf9b6f8 100644 --- a/packages/json-machete/src/healJSONSchema.ts +++ b/packages/json-machete/src/healJSONSchema.ts @@ -24,6 +24,17 @@ const JSONSchemaStringFormats = [ 'uri', ]; +const AnySchema = { + title: 'Any', + oneOf: [ + { type: 'string' }, + { type: 'integer' }, + { type: 'boolean' }, + { type: 'number' }, + { type: 'object', additionalProperties: true }, + ], +}; + const titleResolvedRefReservedMap = new WeakMap< JSONSchemaObject, { @@ -216,19 +227,11 @@ export async function healJSONSchema( // Try to find the type if (!subSchema.type) { // If required exists without properties - if (subSchema.required && !subSchema.properties) { + if (subSchema.required && !subSchema.properties && !subSchema.anyOf && !subSchema.allOf) { // Add properties subSchema.properties = {}; for (const missingPropertyName of subSchema.required) { - subSchema.properties[missingPropertyName] = { - oneOf: [ - { type: 'string' }, - { type: 'integer' }, - { type: 'boolean' }, - { type: 'number' }, - { type: 'object', additionalProperties: true }, - ], - }; + subSchema.properties[missingPropertyName] = AnySchema; } } // Properties only exist in objects diff --git a/packages/loaders/openapi/src/getJSONSchemaOptionsFromOpenAPIOptions.ts b/packages/loaders/openapi/src/getJSONSchemaOptionsFromOpenAPIOptions.ts index 80b8fae2427b4..b44a33257790f 100644 --- a/packages/loaders/openapi/src/getJSONSchemaOptionsFromOpenAPIOptions.ts +++ b/packages/loaders/openapi/src/getJSONSchemaOptionsFromOpenAPIOptions.ts @@ -62,7 +62,11 @@ export async function getJSONSchemaOptionsFromOpenAPIOptions({ for (const relativePath in oasOrSwagger.paths) { const pathObj = oasOrSwagger.paths[relativePath]; + const pathParameters = pathObj.parameters; for (const method in pathObj) { + if (method === 'parameters') { + continue; + } const methodObj = pathObj[method] as OpenAPIV2.OperationObject | OpenAPIV3.OperationObject; const operationConfig = { method: method.toUpperCase() as HTTPMethod, @@ -77,8 +81,20 @@ export async function getJSONSchemaOptionsFromOpenAPIOptions({ responseByStatusCode: Record; }; operations.push(operationConfig); - for (const paramObjIndex in methodObj.parameters) { - const paramObj = methodObj.parameters[paramObjIndex] as OpenAPIV2.ParameterObject | OpenAPIV3.ParameterObject; + let allParams; + if (methodObj.parameters && Array.isArray(methodObj.parameters)) { + allParams = [...(pathParameters || []), ...methodObj.parameters]; + } else { + allParams = { + ...(pathParameters || {}), + ...((methodObj.parameters || {}) as any), + }; + } + for (const paramObjIndex in allParams) { + let paramObj = allParams[paramObjIndex] as OpenAPIV2.ParameterObject | OpenAPIV3.ParameterObject; + if ('$ref' in paramObj) { + paramObj = resolvePath(paramObj.$ref.split('#')[1], oasOrSwagger); + } const argName = sanitizeNameForGraphQL(paramObj.name); switch (paramObj.in) { case 'query': @@ -102,6 +118,12 @@ export async function getJSONSchemaOptionsFromOpenAPIOptions({ requestSchema.required = requestSchema.required || []; requestSchema.required.push(paramObj.name); } + // Fix the reference + if (requestSchema.properties[paramObj.name].$ref?.startsWith('#')) { + requestSchema.properties[paramObj.name].$ref = `${oasFilePath}${ + requestSchema.properties[paramObj.name].$ref + }`; + } } else { if (!operationConfig.path.includes('?')) { operationConfig.path += '?'; diff --git a/packages/loaders/openapi/tests/__snapshots__/docusign.test.ts.snap b/packages/loaders/openapi/tests/__snapshots__/docusign.test.ts.snap index 3af9c51889a32..b9d5f085af2d7 100644 --- a/packages/loaders/openapi/tests/__snapshots__/docusign.test.ts.snap +++ b/packages/loaders/openapi/tests/__snapshots__/docusign.test.ts.snap @@ -6097,7 +6097,6 @@ input LoginInformation_GetLoginInformation_request_Input { } type Mutation { - undefined: Any \\"Creates new DocuSign accounts.\\\\nYou can use this method to create\\\\na single account\\\\nor up to 100 accounts at a time.\\\\n\\\\nWhen creating a single account,\\\\nthe body of the request is a\\\\n[\`newAccountDefinition\`][newAccountDefinition]\\\\nobject.\\\\n\\\\nIf the request succeeds.\\\\nit returns a\\\\n201 (Created) code.\\\\nThe response returns the new account ID, password and the default user\\\\ninformation for each newly created account.\\\\n\\\\n\\\\nWhen creating multiple accounts,\\\\nthe body of the request is a\\\\n\`newAccountRequests\`\\\\nobject,\\\\nwhich contains one or more \\\\n[\`newAccountDefinition\`][newAccountDefinition]\\\\nobjects.\\\\nYou can create up to 100 new accounts\\\\nat a time this way.\\\\n\\\\nThe body for a multi-account\\\\ncreation request\\\\nlooks like this in JSON:\\\\n\\\\n\`\`\`\\\\n{\\\\n \\\\\\"newAccountRequests\\\\\\": [\\\\n {\\\\n \\\\\\"accountName\\\\\\": \\\\\\"accountone\\\\\\",\\\\n . . .\\\\n },\\\\n {\\\\n \\\\\\"accountName\\\\\\": \\\\\\"accounttwo\\\\\\",\\\\n . . .\\\\n }\\\\n ]\\\\n}\\\\n\`\`\`\\\\n\\\\nA multi-account request\\\\nlooks like this in XML:\\\\n\\\\n\`\`\`\\\\n\\\\n \\\\n \\\\n . . .\\\\n \\\\n \\\\n . . .\\\\n \\\\n \\\\n\\\\n\`\`\`\\\\n\\\\nA multi-account creation request\\\\nmay succeed (report a 201 code)\\\\neven if some accounts could not be created.\\\\nIn this case, the \`errorDetails\` property\\\\nin the response contains specific information\\\\nabout the failure.\\\\n\\\\n\\\\n\\\\nThe \`accountSettings\` property\\\\nis a [name/value][nameValue]\\\\nlist that can contain the following settings:\\\\n\\\\n| Name | Type | Authorization Required | Description | \\\\n| :------------------------------------------------- | :------ | :---------------------------------------------------------- | :----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | \\\\n| adoptSigConfig | Boolean | Admin | When **true**, the Signature Adoption Configuration page is available to account administrators. | \\\\n| allowAccessCodeFormat | Boolean | Admin | When **true**, the Access Code Format page is available to account administrators. | \\\\n| allowAccountManagementGranular | Boolean | Admin | When **true**, the Delegated Administration functionality is available to account. | \\\\n| allowBulkSend | Boolean | Admin | When **true**, the account can set if the bulk send feature can be used. | \\\\n| allowCDWithdraw | Boolean | Admin | When **true**, signers can withdraw their consent to use electronic signatures. | \\\\n| allowConnectSendFinishLater | Boolean | Reserved | Reserved for DocuSign. | \\\\n| allowDataDownload | Boolean | Admin | When **true**, the account can download envelope data. | \\\\n| allowEnvelopeCorrect | Boolean | Admin | When **true**, the account allows in process envelopes to be corrected. | \\\\n| allowEnvelopePublishReporting | Boolean | Admin | When **true**, the account can access the Envelope Publish section in Classic DocuSign Experience Account Administration. | \\\\n| allowExpressSignerCertificate | Boolean | Admin | When **true**, senders are allowed to use the DocuSign Express digital signatures. | \\\\n| allowExternalSignaturePad | Boolean | Admin | When **true**, an external signature pad can be used for signing. The signature pad type is set by the externalSignaturePadType property. | \\\\n| allowInPerson | Boolean | SysAdmin | When **true**, the account allows In Person Signing. | \\\\n| allowMarkup | Boolean | Admin | When **true**, the document markup feature is enabled for the account. | \\\\n| allowMemberTimezone | Boolean | Admin | When **true**, account users can set their own time zones. | \\\\n| allowMergeFields | Boolean | Admin | When **true**, the account can use merge fields in conjunction with DocuSign for Salesforce. | \\\\n| allowMultipleSignerAttachments | Boolean | Admin | When **true**, multiple signer attachments are allowed for an envelope. | \\\\n| allowOfflineSigning | Boolean | Admin | When **true**, the account can use Offline Signing and envelopes signed using offline signing on mobile devices are synchronized with this account. This option and the inSessionEnabled option must both be enabled (**true**) for a caller to use offline signing. | \\\\n| allowOpenTrustSignerCertificate | Boolean | Admin | When **true**, senders are allowed to use the OpenTrust digital signatures. | \\\\n| allowPaymentProcessing | Boolean | Admin | When **true**, the account can access the Payment Processing set up page. | \\\\n| allowPersonalSignerCertificate | Boolean | Admin | When **true**, the account can specify that signers must use personal signer certificates during signing. | \\\\n| allowPrivateSigningGroups | Boolean | SysAdmin Read Only | Reserved for DocuSign. This currently returns false in a response. This setting is only shown in the response when listing account settings. | \\\\n| allowReminders | Boolean | Admin | When **true**, the reminder and expiration functionality is available when sending envelops. | \\\\n| allowSafeBioPharmaSignerCertificate | Boolean | Admin | When **true**, senders are allowed to use the SAFE BioPharma digital signatures. | \\\\n| allowSharedTabs | Boolean | Admin | When **true**, the account allows users to share custom tabs (fields).
This setting is only shown when getting account settings. It cannot be modified. | \\\\n| allowSignDocumentFromHomePage | Boolean | Admin | When **true**, the Sign a Document Now button is available on the Home tab. | \\\\n| allowSignatureStamps | Boolean | Reserved | Reserved for DocuSign. | \\\\n| allowSignerReassign | Boolean | Admin | When **true**, the account allows signers to reassign an envelope. | \\\\n| allowSignerReassignOverride | Boolean | Admin | When **true**, the sender has the option override the default account setting for reassigning recipients. | \\\\n| allowSigningGroups | Boolean | SysAdmin Read Only | When **true**, the account can use signing groups. This setting is only shown in the response when listing account settings. | \\\\n| allowTabOrder | Boolean | Admin | When **true**, the Tab Order field is available for use when creating tabs. | \\\\n| allowWorkspaceComments | Boolean | Reserved | Reserved for DocuSign. | \\\\n| allowWorkspaceCreate | Boolean | Admin | When **true**, account users can create DocuSign Rooms. | \\\\n| attachCompletedEnvelope | Boolean | SysAdmin | When **true**, envelope documents are included as a PDF file attachment for signing completed emails. | \\\\n| authenticationCheck | String | Admin | Sets when authentication checks are applied for recipient envelope access. This setting only applies to the following ID checks: This setting takes one of the following options: | \\\\n| autoNavRule | String | Admin | The auto-navigation rule for the account. Enumeration values are: | \\\\n| bulkSend | Boolean | Admin | When **true**, the account allows bulk sending of envelopes. | \\\\n| canSelfBrandSend | Boolean | SysAdmin | When **true**, account administrators can self-brand their sending console through the DocuSign Console. | \\\\n| canSelfBrandSign | Boolean | SysAdmin | When **true**, account administrators can self-brand their signing console through the DocuSign Console. | \\\\n| conditionalFieldsEnabled | Boolean | Admin | When **true**, conditional fields can be used by the account. | \\\\n| consumerDisclosureFrequency | enum | Admin | Possible values are: | \\\\n| dataFieldRegexEnabled | Boolean | Admin | When **true**, the Regex field is available for tabs with that property. | \\\\n| dataFieldSizeEnabled | Boolean | Admin | When **true**, the maximum number of characters field is available for tabs with that property. | \\\\n| dataPopulationScope | String | Admin | Specifies how data is shared for tabs with the same tabLabel. There are two possible values: This setting applies to the following tab types: Changing this setting affects envelopes that have been sent but not completed. | \\\\n| disableMobilePushNotifications | Boolean | Admin | When **true**, mobile push notifications are disabled on the account. | \\\\n| disableMobileSending | Boolean | Admin | When **true**, sending from mobile applications is disabled. | \\\\n| disableMultipleSessions | Boolean | Admin | When **true**, account users cannot be logged into multiple sessions at once. | \\\\n| disableUploadSignature | Boolean | Admin | When **true**, signers cannot use the upload signature/initials image option when signing a document. | \\\\n| documentConversionRestrictions | String | Admin | Sets the account document upload restriction for non-account administrators. There are three possible values: | \\\\n| enableAutoNav | Boolean | SysAdmin or EnableAutoNavByDSAdmin is set | When **true**, the auto-navigation is enabled for the account. | \\\\n| enableCalculatedFields | Boolean | Admin & AllowExpression is set | When **true**, this account can use the Calculated Fields feature. | \\\\n| enableDSPro | Boolean | SysAdmin | When **true**, this account can send and manage envelopes from the DocuSign Desktop Client. | \\\\n| enableEnvelopeStampingByAccountAdmin | Boolean | SysAdmin or account has EnableEnvelopeStampingByDSAdmin set | When **true**, senders for this account can choose to have the envelope ID stamped in the document margins. | \\\\n| enablePaymentProcessing | Boolean | Admin & AllowPaymentProcessing is set. | When **true**, Payment Processing is enabled for the account. | \\\\n| enablePowerForm | Boolean | SysAdmin | When **true**, PowerForm access is enabled for the account. | \\\\n| enablePowerFormDirect | Boolean | Admin | When **true**, direct PowerForms are enabled for the account. | \\\\n| enableRecipientDomainValidation | Boolean | Admin | When **true**, validation on recipient email domains for DocuSign Access feature is enabled. | \\\\n| enableRequireSignOnPaper | Boolean | Admin | When **true**, the account can use the requireSignOnPaper option. | \\\\n| enableReservedDomain | Boolean | SysAdmin | When **true**, an account administrator can reserve web domain and users. | \\\\n| enableSMSAuthentication | Boolean | Admin | When **true**, the account can use SMS authentication. | \\\\n| enableSendToAgent | Boolean | SysAdmin | When **true**, this account can use the Agent Recipient Type. | \\\\n| enableSendToIntermediary | Boolean | Admin & AllowSendToIntermediary is set | When **true**, this account can use the Intermediary Recipient Type. | \\\\n| enableSendToManage | Boolean | Admin | When **true**, this account can use the Editor Recipient Type. | \\\\n| enableSequentialSigningAPI | Boolean | SysAdmin | When **true**, the account can define the routing order of recipients for envelopes sent using the DocuSign API. | \\\\n| enableSequentialSigningUI | Boolean | SysAdmin | When **true**, the account can define the routing order of recipients for envelopes sent using the DocuSign console. | \\\\n| enableSignOnPaper | Boolean | Admin | When **true**, a user can allow signers to use the sign on paper option. | \\\\n| enableSignOnPaperOverride | Boolean | Admin | When **true**, a user can override the default account setting for the sign on paper option. | \\\\n| enableSignerAttachments | Boolean | Admin | When **true**, a user can request attachments from a signer. | \\\\n| enableTransactionPoint | Boolean | SysAdmin | When **true**, Transaction Point is enabled for this account. | \\\\n| enableVaulting | Boolean | SysAdmin | When **true**, this account can use electronic vaulting for documents. | \\\\n| enableWorkspaces | Boolean | Admin | When **true**, DocuSign Rooms is enabled for the account. | \\\\n| envelopeIntegrationAllowed | String | SysAdmin | Shows the envelope integration rule for the account.
Enumeration values are: NotAllowed, Full, IntegrationSendOnly. | \\\\n| envelopeIntegrationEnabled | Boolean | Admin & EnvelopeIntegrationAllowed is set | When **true**, envelope integration is enabled for the account. | \\\\n| envelopeStamplingDefaultValue | Boolean | (GET only) | When **true**, envelopes sent by this account automatically have the envelope ID stamped in the margins, unless the sender selects not to have them stamped. | \\\\n| externalSignaturePadType | String | Admin | Sets the type of signature pad that can be used. Possible values are: | \\\\n| faxOutEnabled | Boolean | Admin | When **true**, the account can use the fax out feature. | \\\\n| idCheckExpire | String | Admin | Indicates when a user's authentication expires. Possible values are: | \\\\n| idCheckExpireDays | Integer | Admin | The number of days before a user's authentication expires. Valid only if the \`IDCheckExpire\` value is Variable. | \\\\n| idCheckRequired | String | Admin | Indicates if authentication is required by envelope signers. Possible values are: | \\\\n| inPersonIDCheckQuestion | String | Admin | The default question used by the In Person signing host for an In Person signing session. | \\\\n| inSessionEnabled | Boolean | Admin | When **true**, the account can use In Session (embedded) and offline signing. This option and the allowOfflineSigning option must both be enabled (**true**) for a caller to use offline signing. | \\\\n| inSessionSuppressEmails | Boolean | Admin | When **true**, emails are not sent to the embedded recipients on an envelope for the account. | \\\\n| maximumSigningGroups | String | SysAdmin Read Only | The maximum number of signing groups an account can have. The default value for this is 50. This setting is only shown in the response when listing account settings. | \\\\n| maximumUsersPerSigningGroup | String | SysAdmin Read Only | The maximum number of members in a signing group. The default value for this is 50. This setting is only shown in the response when listing account settings. | \\\\n| mobileSessionTimeout | String | Admin | Sets the amount of idle activity time, in minutes, before a mobile user is automatically logged off of the system. If the setting is 0, then DocuSign mobile application users are never automatically logged off the system. The minimum setting is 1 minute and the maximum setting is 120 minutes.
This setting only applies to the DocuSign for iOS v2.8.2 or later mobile app. | \\\\n| phoneAuthRecipientMayProvidePhoneNumber | Boolean | Admin | When **true**, senders can select to allow the recipient to provide a phone number for the Phone Authentication process. | \\\\n| pkiSignDownloadedPDFDocs | String | Admin | The policy for adding a digital certificate to downloaded, printed and emailed documents. Possible values are: | \\\\n| recipientsCanSignOffline | Boolean | Admin | When **true**, envelopes signed using offline signing on mobile devices are synchronized with this account. | \\\\n| requireDeclineReason | Boolean | Admin | When **true**, recipients that decline to sign an envelope must provide a reason. | \\\\n| requireSignerCertificateType | String | Admin | Sets which Digital Signature certificate is required when sending envelopes. There are three possible values: | \\\\n| rsaVeridAccountName | String | Admin | The RSA account name.
Modifying this value might inadvertently disrupt your ID Check capability. Ensure you have the correct value before changing this. | \\\\n| rsaVeridPassword | String | Admin | The password used with the RSA account.
Modifying this value might inadvertently disrupt your ID Check capability. Ensure you have the correct value before changing this. | \\\\n| rsaVeridRuleset | String | Admin | The RSA rule set used with the account.
Modifying this value might inadvertently disrupt your ID Check capability. Ensure you have the correct value before changing this. | \\\\n| rsaVeridUserId | String | Admin | The user ID for the RSA account.
Modifying this value might inadvertently disrupt your ID Check capability. Ensure you have the correct value before changing this. | \\\\n| savingCustomTabsEnabled | Boolean | Admin | When **true**, account users can save custom tabs. | \\\\n| selfSignedRecipientEmailDocument | String | Admin | Sets how self-signed documents are presented to the email recipients. Possible values are: | \\\\n| selfSignedRecipientEmailDocumentRights | Boolean | Admin | When **true**, account administrators can set the selfSignedRecipientEmailDocument option. | \\\\n| selfSignedRecipientEmailDocumentUserOverride | Boolean | Admin | When **true** the selfSignedRecipientEmailDocument userSetting can be set for an individual user. The userSetting will override the account setting. | \\\\n| selfSignedRecipientEmailDocumentUserOverrideRights | Boolean | Admin | When **true**, account administrators can set the selfSignedRecipientEmailDocumentOverride option. | \\\\n| sendToCertifiedDeliveryEnabled | Boolean | Admin | When **true**, the Certified Deliveries Recipient type can be used by the account. | \\\\n| senderMustAuthenticateSigning | Boolean | Admin | When **true**, a sender that is also a recipient of an envelope must follow the authentication requirements for the envelope. | \\\\n| sessionTimeout | Integer | Admin | The amount of idle activity time, in minutes, before a user is automatically logged out of the system. The minimum setting is 20 minutes and the maximum setting is 120 minutes. | \\\\n| setRecipEmailLang | Boolean | Admin | When **true**, senders can set the email languages for each recipient. | \\\\n| setRecipSignLang | Boolean | Admin | When **true**, senders can set the signing language used for each recipient. | \\\\n| sharedCustomTabsEnabled | Boolean | Admin | When **true**, saved custom tabs can be shared with account users. | \\\\n| signDateFormat | String | Admin | The date/time format applied to Date Signed fields for the account. | \\\\n| signTimeShowAmPm | Boolean | Admin | When **true**, AM or PM is shown as part of the time for signDateFormat. | \\\\n| signerAttachCertificateToEnvelopePDF | Boolean | AccountAdmin & account is selected in AccountSigningSettings| When **true**, the Certificate of Completion is included in the envelope documents PDF when it is downloaded. | \\\\n| signerAttachConcat | Boolean | Admin | When **true**, signer attachments are added to the parent document that the attachment tab is located on, instead of the default behavior that creates a new document in the envelope for every signer attachment. | \\\\n| signerCanCreateAccount | Boolean | AccountAdmin & account is selected in AccountSigningSettings| When **true**, the signer without a DocuSign account can create a DocuSign account after signing. | \\\\n| signerCanSignOnMobile | Boolean | AccountAdmin & account is selected in AccountSigningSettings| When **true**, signers can use the DocuSign mobile signing user interface. | \\\\n| signerInSessionUseEnvelopeCompleteEmail | Boolean | Admin | When **true**, an envelope complete email is sent to an In Session (embedded) or offline signer after DocuSign processes the envelope. | \\\\n| signerLoginRequirements | String | Admin | Sets the Login requirements for the signer. There are four options: If you use Direct PowerForms or captive/embedded signers, the \\\\\\"Account required\\\\\\" settings are bypassed for those signers. If your workflow requires that the signer have an account, you should not use those methods. | \\\\n| signerMustHaveAccount | Boolean | AccountAdmin & account is selected in AccountSigningSettings| When **true**, senders can only send an envelope to a recipient that has a DocuSign account. | \\\\n| signerMustLoginToSign | Boolean | AccountAdmin & account is selected in AccountSigningSettings| When **true**, an envelope signer must log in to the DocuSign console to sign an envelope. | \\\\n| signerShowSecureFieldInitialValues | Boolean | AccountAdmin & account is selected in AccountSigningSettings| When **true**, the initial value of all SecureFields is written to the document when sent. | \\\\n| tabDataLabelEnabled | Boolean | Admin | When **true**, senders can change the default tabLabel for tabs. | \\\\n| tabLockingEnabled | Boolean | Admin | When **true**, the locked option is available for tabs with that property. | \\\\n| tabTextFormattingEnabled | Boolean | Admin | When **true**, the formatting options (font type, font size, font color, bold, italic, and underline) are available for tabs with those properties. | \\\\n| universalSignatureOptIn | Boolean | Reserved | Reserved for DocuSign. | \\\\n| universalSignatureOptOut | Boolean | Reserved | Reserved for DocuSign. | \\\\n| useAccountLevelEmail | Boolean | AccountAdmin & account is selected in AccountSigningSettings| When **true**, the content of notification emails is determined at the account level. | \\\\n| useConsumerDisclosure | Boolean | Admin | When **true**, the account can use supplemental documents. | \\\\n| usesAPI | Boolean | SysAdmin | When **true**, the account can use the DocuSign API. | \\\\n\\\\n\\\\n\\\\n\\\\n\\\\n[newAccountDefinition]: #/definitions/newAccountDefinition\\\\n[nameValue]: #/definitions/nameValue\\\\n\\" Accounts_PostAccounts(input: newAccountDefinition_Input, preview_billing_plan: String): newAccountSummary \\"This closes the specified account. You must be an account admin to close your account. Once closed, an account must be reopened by DocuSign.\\" diff --git a/packages/loaders/openapi/tests/__snapshots__/example_api.test.ts.snap b/packages/loaders/openapi/tests/__snapshots__/example_api.test.ts.snap index a3bd29701b356..aa69c6a7edb86 100644 --- a/packages/loaders/openapi/tests/__snapshots__/example_api.test.ts.snap +++ b/packages/loaders/openapi/tests/__snapshots__/example_api.test.ts.snap @@ -291,6 +291,7 @@ type project_with_id { } input get_Status_request_Input { + globalquery: String! limit: Int! } @@ -316,8 +317,7 @@ type Mutation { \\"Used to test link parameters with variables\\" postScanner(input: String, path: String!, query: String): getCopier_200_response \\"Endpoint to test placeholder objects to wrap response objects.\\" - post_status(input: paths_status_post_requestBody_content_application_json_schema_Input): String - undefined: Any + post_status(input: paths_status_post_requestBody_content_application_json_schema_Input, globalquery: String!): String \\"Add new contents to the trashcan of a specific owner\\" postOfficeTrashCan(input: paths_trashcans__LEFT_CURLY_BRACE_username_RIGHT_CURLY_BRACE__post_requestBody_content_application_json_schema_Input, username: String!): trashcan } @@ -385,7 +385,5 @@ input paths_status_post_requestBody_content_application_json_schema_Input { hello: String } -scalar Any - scalar paths_trashcans__LEFT_CURLY_BRACE_username_RIGHT_CURLY_BRACE__post_requestBody_content_application_json_schema_Input" `; diff --git a/packages/loaders/openapi/tests/__snapshots__/toto.test.ts.snap b/packages/loaders/openapi/tests/__snapshots__/toto.test.ts.snap new file mode 100644 index 0000000000000..e774b84e36dde --- /dev/null +++ b/packages/loaders/openapi/tests/__snapshots__/toto.test.ts.snap @@ -0,0 +1,1254 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Toto should generate the correct bundle 1`] = ` +Object { + "baseUrl": "https://dev-api.test.com/api/v1", + "name": "toto", + "operationHeaders": undefined, + "operations": Array [ + Object { + "argTypeMap": Object { + "Accept_Language": "String", + "X_Correlation_Id": "String", + "companyId": "String!", + "directoryOnly": "Boolean", + "folderId": "String!", + "maxSize": "Int", + "minSize": "Int", + "publicationEndDate": "String", + "publicationStartDate": "String", + "querySearch": "String", + "size": "Int", + "startKey": "String", + }, + "description": "List Resources At Any Folder Level", + "field": "list_resources_at_any_folder_v1", + "headers": Object { + "Accept-Language": "{args.Accept_Language}", + "X-Correlation-Id": "{args.X_Correlation_Id}", + }, + "method": "GET", + "operationHeaders": undefined, + "path": "/api/v1/companies/{args.companyId}/knowledgecenter/folders/{args.folderId}/resources", + "requestSchema": Object { + "properties": Object { + "directoryOnly": Object { + "$ref": "#/definitions/queryInput_list_resources_at_any_folder_v1_directoryOnly", + }, + "maxSize": Object { + "$ref": "#/definitions/int323", + }, + "minSize": Object { + "$ref": "#/definitions/int322", + }, + "order": Object { + "description": "List of order", + "items": Object { + "$ref": "#/definitions/queryInput_list_resources_at_any_folder_v1_order_items", + }, + "name": "order", + "type": "array", + }, + "publicationEndDate": Object { + "$ref": "#/definitions/date2", + }, + "publicationStartDate": Object { + "$ref": "#/definitions/date", + }, + "querySearch": Object { + "description": "Text to search in title", + "name": "querySearch", + "type": "string", + }, + "size": Object { + "$ref": "#/definitions/int324", + }, + "startKey": Object { + "description": "The page number", + "name": "startKey", + "type": "string", + }, + "status": Object { + "$ref": "#/definitions/ResourceStatus", + }, + "targetAudience": Object { + "description": "Target of the resource (the resource need to have all of the target audience passed in the list)", + "items": Object { + "type": "string", + }, + "name": "targetAudience", + "type": "array", + }, + }, + "title": "list_resources_at_any_folder_v1_request", + "type": "object", + }, + "responseByStatusCode": Object { + "200": Object { + "responseSchema": "./fixtures/toto.yml#/paths/~1api~1v1~1companies~1{companyId}~1knowledgecenter~1folders~1{folderId}~1resources/get/responses/200/content/application~1json/schema", + }, + }, + "schemaHeaders": undefined, + "type": "query", + }, + Object { + "argTypeMap": Object { + "Accept_Language": "String", + "X_Correlation_Id": "String", + "companyId": "String!", + "folderId": "String!", + }, + "description": "Create resources at any folder level", + "field": "create_resource_at_any_folder_v1", + "headers": Object { + "Accept-Language": "{args.Accept_Language}", + "X-Correlation-Id": "{args.X_Correlation_Id}", + }, + "method": "POST", + "operationHeaders": undefined, + "path": "/api/v1/companies/{args.companyId}/knowledgecenter/folders/{args.folderId}/resources", + "requestSchema": "./fixtures/toto.yml#/paths/~1api~1v1~1companies~1{companyId}~1knowledgecenter~1folders~1{folderId}~1resources/post/requestBody/content/application~1json/schema", + "responseByStatusCode": Object { + "201": Object { + "responseSchema": "./fixtures/toto.yml#/paths/~1api~1v1~1companies~1{companyId}~1knowledgecenter~1folders~1{folderId}~1resources/post/responses/201/content/application~1json/schema", + }, + }, + "schemaHeaders": undefined, + "type": "mutation", + }, + Object { + "argTypeMap": Object { + "Accept_Language": "String", + "X_Correlation_Id": "String", + "companyId": "String!", + "folderId": "String!", + "resourceId": "String!", + }, + "description": "Update A Resource At Any Folder Level", + "field": "update_resource_at_any_folder_v1", + "headers": Object { + "Accept-Language": "{args.Accept_Language}", + "X-Correlation-Id": "{args.X_Correlation_Id}", + }, + "method": "PUT", + "operationHeaders": undefined, + "path": "/api/v1/companies/{args.companyId}/knowledgecenter/folders/{args.folderId}/resources/{args.resourceId}", + "requestSchema": "./fixtures/toto.yml#/paths/~1api~1v1~1companies~1{companyId}~1knowledgecenter~1folders~1{folderId}~1resources~1{resourceId}/put/requestBody/content/application~1json/schema", + "responseByStatusCode": Object { + "200": Object { + "responseSchema": "./fixtures/toto.yml#/paths/~1api~1v1~1companies~1{companyId}~1knowledgecenter~1folders~1{folderId}~1resources~1{resourceId}/put/responses/200/content/application~1json/schema", + }, + }, + "schemaHeaders": undefined, + "type": "mutation", + }, + Object { + "argTypeMap": Object { + "Accept_Language": "String", + "X_Correlation_Id": "String", + "companyId": "String!", + "directoryOnly": "Boolean", + "maxSize": "Int", + "minSize": "Int", + "publicationEndDate": "String", + "publicationStartDate": "String", + "querySearch": "String", + "size": "Int", + "startKey": "String", + }, + "description": "List All Resources At The Root Folder", + "field": "list_resources_at_the_root_folder_v1", + "headers": Object { + "Accept-Language": "{args.Accept_Language}", + "X-Correlation-Id": "{args.X_Correlation_Id}", + }, + "method": "GET", + "operationHeaders": undefined, + "path": "/api/v1/companies/{args.companyId}/knowledgecenter/resources", + "requestSchema": Object { + "properties": Object { + "directoryOnly": Object { + "default": false, + "description": undefined, + "name": "directoryOnly", + "title": "queryInput_list_resources_at_any_folder_v1_directoryOnly", + "type": "boolean", + }, + "maxSize": Object { + "description": "Maximum size of a resource", + "format": "int32", + "name": "maxSize", + "title": "int32", + "type": "integer", + }, + "minSize": Object { + "description": "Minimum size of a resource", + "format": "int32", + "name": "minSize", + "title": "int32", + "type": "integer", + }, + "order": Object { + "description": "List of order", + "items": Object { + "$ref": "#/definitions/queryInput_list_resources_at_any_folder_v1_order_items", + }, + "name": "order", + "type": "array", + }, + "publicationEndDate": Object { + "description": "Publication end date", + "format": "date", + "name": "publicationEndDate", + "title": "date", + "type": "string", + }, + "publicationStartDate": Object { + "description": "Publication start date", + "format": "date", + "name": "publicationStartDate", + "title": "date", + "type": "string", + }, + "querySearch": Object { + "description": "Text to search in title", + "name": "querySearch", + "type": "string", + }, + "size": Object { + "description": undefined, + "format": "int32", + "name": "size", + "title": "int32", + "type": "integer", + }, + "startKey": Object { + "description": "The page number", + "name": "startKey", + "type": "string", + }, + "status": Object { + "$resolvedRef": "/components/schemas/ResourceStatus", + "items": Object { + "enum": Array [ + "ACTIVE", + "INACTIVE", + "SCHEDULED", + ], + "title": "query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_status_items", + "type": "string", + }, + "title": "ResourceStatus", + "type": "array", + }, + "targetAudience": Object { + "description": "Target of the resource (the resource need to have all of the target audience passed in the list)", + "items": Object { + "type": "string", + }, + "name": "targetAudience", + "type": "array", + }, + }, + "title": undefined, + "type": "object", + }, + "responseByStatusCode": Object { + "200": Object { + "responseSchema": "./fixtures/toto.yml#/paths/~1api~1v1~1companies~1{companyId}~1knowledgecenter~1resources/get/responses/200/content/application~1json/schema", + }, + }, + "schemaHeaders": undefined, + "type": "query", + }, + Object { + "argTypeMap": Object { + "Accept_Language": "String", + "X_Correlation_Id": "String", + "companyId": "String!", + }, + "description": "Create A Resource At The Root Folder", + "field": "create_resource_at_the_root_folder_v1", + "headers": Object { + "Accept-Language": "{args.Accept_Language}", + "X-Correlation-Id": "{args.X_Correlation_Id}", + }, + "method": "POST", + "operationHeaders": undefined, + "path": "/api/v1/companies/{args.companyId}/knowledgecenter/resources", + "requestSchema": "./fixtures/toto.yml#/paths/~1api~1v1~1companies~1{companyId}~1knowledgecenter~1resources/post/requestBody/content/application~1json/schema", + "responseByStatusCode": Object { + "201": Object { + "responseSchema": "./fixtures/toto.yml#/paths/~1api~1v1~1companies~1{companyId}~1knowledgecenter~1resources/post/responses/201/content/application~1json/schema", + }, + }, + "schemaHeaders": undefined, + "type": "mutation", + }, + Object { + "argTypeMap": Object { + "Accept_Language": "String", + "X_Correlation_Id": "String", + "companyId": "String!", + "resourceId": "String!", + }, + "description": "Get Resource by ID", + "field": "get_resource_by_id_v1", + "headers": Object { + "Accept-Language": "{args.Accept_Language}", + "X-Correlation-Id": "{args.X_Correlation_Id}", + }, + "method": "GET", + "operationHeaders": undefined, + "path": "/api/v1/companies/{args.companyId}/knowledgecenter/resources/{args.resourceId}", + "responseByStatusCode": Object { + "200": Object { + "responseSchema": "./fixtures/toto.yml#/paths/~1api~1v1~1companies~1{companyId}~1knowledgecenter~1resources~1{resourceId}/get/responses/200/content/application~1json/schema", + }, + }, + "schemaHeaders": undefined, + "type": "query", + }, + Object { + "argTypeMap": Object { + "Accept_Language": "String", + "X_Correlation_Id": "String", + "companyId": "String!", + "resourceId": "String!", + }, + "description": "Update A Resource At The Root Folder", + "field": "update_resource_at_the_root_folder_v1", + "headers": Object { + "Accept-Language": "{args.Accept_Language}", + "X-Correlation-Id": "{args.X_Correlation_Id}", + }, + "method": "PUT", + "operationHeaders": undefined, + "path": "/api/v1/companies/{args.companyId}/knowledgecenter/resources/{args.resourceId}", + "requestSchema": "./fixtures/toto.yml#/paths/~1api~1v1~1companies~1{companyId}~1knowledgecenter~1resources~1{resourceId}/put/requestBody/content/application~1json/schema", + "responseByStatusCode": Object { + "200": Object { + "responseSchema": "./fixtures/toto.yml#/paths/~1api~1v1~1companies~1{companyId}~1knowledgecenter~1resources~1{resourceId}/put/responses/200/content/application~1json/schema", + }, + }, + "schemaHeaders": undefined, + "type": "mutation", + }, + Object { + "argTypeMap": Object { + "Accept_Language": "String", + "X_Correlation_Id": "String", + "companyId": "String!", + "resourceId": "String!", + }, + "description": "Delete A Resource At The Root Folder", + "field": "delete_resource_at_the_root_folder_v1", + "headers": Object { + "Accept-Language": "{args.Accept_Language}", + "X-Correlation-Id": "{args.X_Correlation_Id}", + }, + "method": "DELETE", + "operationHeaders": undefined, + "path": "/api/v1/companies/{args.companyId}/knowledgecenter/resources/{args.resourceId}", + "responseByStatusCode": Object { + "204": Object { + "responseSchema": Object { + "description": "No Content", + "title": "delete_resource_at_the_root_folder_v1_204_response", + "type": "null", + }, + }, + }, + "schemaHeaders": undefined, + "type": "mutation", + }, + ], + "referencedSchema": Object { + "$ref": "#/definitions/_schema", + "definitions": Object { + "BaseResourceDTO": Object { + "$resolvedRef": "/components/schemas/BaseResourceDTO", + "properties": Object { + "allowedTargetAudiences": Object { + "items": Object { + "type": "string", + }, + "type": "array", + }, + "geoFenced": Object { + "$ref": "#/definitions/query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_isShiftFenced", + }, + "parentFolderId": Object { + "type": "string", + }, + "pinned": Object { + "$ref": "#/definitions/query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_isShiftFenced", + }, + "previewUrl": Object { + "type": "string", + }, + "publicationEndTimestamp": Object { + "$ref": "#/definitions/date-time", + }, + "publicationStartTimestamp": Object { + "$ref": "#/definitions/date-time", + }, + "punchedFenced": Object { + "$ref": "#/definitions/query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_isShiftFenced", + }, + "shiftFenced": Object { + "$ref": "#/definitions/query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_isShiftFenced", + }, + "status": Object { + "$ref": "#/definitions/ResourceStatus", + }, + }, + "title": "BaseResourceDTO", + "type": "object", + }, + "BaseResourceUpdateDTO": Object { + "$resolvedRef": "/components/schemas/BaseResourceUpdateDTO", + "allOf": Array [ + Object { + "$ref": "#/definitions/BaseResourceDTO", + }, + Object { + "$ref": "#/definitions/query_get_resource_by_id_v1_oneOf_0_allOf_2", + }, + ], + "title": "BaseResourceUpdateDTO", + }, + "FileCreateDTO": Object { + "$resolvedRef": "/components/schemas/FileCreateDTO", + "allOf": Array [ + Object { + "$ref": "#/definitions/ResourceCreateDTO", + }, + Object { + "$ref": "#/definitions/FilePropertiesDTO", + }, + ], + "title": "FileCreateDTO", + }, + "FileGetWithI18nDTO": Object { + "$resolvedRef": "/components/schemas/FileGetWithI18nDTO", + "allOf": Array [ + Object { + "$ref": "#/definitions/ResourceGetDTO", + }, + Object { + "$ref": "#/definitions/FilePropertiesDTO", + }, + Object { + "$ref": "#/definitions/query_get_resource_by_id_v1_oneOf_0_allOf_2", + }, + ], + "required": Array [ + "size", + "url", + "contentType", + "i18n", + ], + "title": "FileGetWithI18nDTO", + }, + "FileGetWithLocalizedNameDTO": Object { + "$resolvedRef": "/components/schemas/FileGetWithLocalizedNameDTO", + "allOf": Array [ + Object { + "$ref": "#/definitions/ResourceGetDTO", + }, + Object { + "$ref": "#/definitions/FilePropertiesDTO", + }, + Object { + "$ref": "#/definitions/query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_2", + }, + ], + "required": Array [ + "size", + "url", + "contentType", + "name", + ], + "title": "FileGetWithLocalizedNameDTO", + }, + "FilePropertiesDTO": Object { + "$resolvedRef": "/components/schemas/FilePropertiesDTO", + "properties": Object { + "contentType": Object { + "type": "string", + }, + "size": Object { + "$ref": "#/definitions/int32", + }, + "url": Object { + "type": "string", + }, + }, + "title": "FilePropertiesDTO", + "type": "object", + }, + "FolderGetWithI18nDTO": Object { + "$resolvedRef": "/components/schemas/FolderGetWithI18nDTO", + "allOf": Array [ + Object { + "$ref": "#/definitions/ResourceGetDTO", + }, + Object { + "$ref": "#/definitions/FolderPropertiesDTO", + }, + Object { + "$ref": "#/definitions/query_get_resource_by_id_v1_oneOf_0_allOf_2", + }, + ], + "required": Array [ + "i18n", + ], + "title": "FolderGetWithI18nDTO", + }, + "FolderGetWithLocalizedNameDTO": Object { + "$resolvedRef": "/components/schemas/FolderGetWithLocalizedNameDTO", + "allOf": Array [ + Object { + "$ref": "#/definitions/ResourceGetDTO", + }, + Object { + "$ref": "#/definitions/FolderPropertiesDTO", + }, + Object { + "$ref": "#/definitions/query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_2", + }, + ], + "required": Array [ + "name", + ], + "title": "FolderGetWithLocalizedNameDTO", + }, + "FolderPropertiesDTO": Object { + "$resolvedRef": "/components/schemas/FolderPropertiesDTO", + "properties": Object { + "childFolderCount": Object { + "$ref": "#/definitions/int32", + }, + "fileCount": Object { + "$ref": "#/definitions/int32", + }, + }, + "title": "FolderPropertiesDTO", + "type": "object", + }, + "Mutation": Object { + "properties": Object { + "create_resource_at_any_folder_v1": Object { + "$ref": "#/definitions/get_resource_by_id_v1_200_response", + }, + "create_resource_at_the_root_folder_v1": Object { + "$ref": "#/definitions/get_resource_by_id_v1_200_response", + }, + "delete_resource_at_the_root_folder_v1": Object { + "$ref": "#/definitions/delete_resource_at_the_root_folder_v1_204_response", + }, + "update_resource_at_any_folder_v1": Object { + "$ref": "#/definitions/get_resource_by_id_v1_200_response", + }, + "update_resource_at_the_root_folder_v1": Object { + "$ref": "#/definitions/get_resource_by_id_v1_200_response", + }, + }, + "title": "Mutation", + "type": "object", + }, + "MutationInput": Object { + "properties": Object { + "create_resource_at_any_folder_v1": Object { + "$ref": "#/definitions/paths_api_v1_companies_{companyId}_knowledgecenter_folders_{folderId}_resources_post_requestBody_content_application_json_schema", + }, + "create_resource_at_the_root_folder_v1": Object { + "$ref": "#/definitions/paths_api_v1_companies_{companyId}_knowledgecenter_folders_{folderId}_resources_post_requestBody_content_application_json_schema", + }, + "update_resource_at_any_folder_v1": Object { + "$ref": "#/definitions/paths_api_v1_companies_{companyId}_knowledgecenter_folders_{folderId}_resources_post_requestBody_content_application_json_schema", + }, + "update_resource_at_the_root_folder_v1": Object { + "$ref": "#/definitions/paths_api_v1_companies_{companyId}_knowledgecenter_folders_{folderId}_resources_post_requestBody_content_application_json_schema", + }, + }, + "title": "MutationInput", + "type": "object", + }, + "ParentFolderGetWithLocalizedNameDTO": Object { + "$resolvedRef": "/components/schemas/ParentFolderGetWithLocalizedNameDTO", + "properties": Object { + "allowedTargetAudiences": Object { + "items": Object { + "type": "string", + }, + "type": "array", + }, + "childFolderCount": Object { + "$ref": "#/definitions/int32", + }, + "creationTimestamp": Object { + "$ref": "#/definitions/date-time", + }, + "creationUserId": Object { + "type": "string", + }, + "fileCount": Object { + "$ref": "#/definitions/int32", + }, + "id": Object { + "type": "string", + }, + "isGeoFenced": Object { + "$ref": "#/definitions/query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_isShiftFenced", + }, + "isPinned": Object { + "$ref": "#/definitions/query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_isShiftFenced", + }, + "isPunchedFenced": Object { + "$ref": "#/definitions/query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_isShiftFenced", + }, + "isShiftFenced": Object { + "$ref": "#/definitions/query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_isShiftFenced", + }, + "lastUpdateTimestamp": Object { + "$ref": "#/definitions/date-time", + }, + "lastUpdateUserId": Object { + "type": "string", + }, + "name": Object { + "type": "string", + }, + "previewUrl": Object { + "type": "string", + }, + "publicationEndTimestamp": Object { + "$ref": "#/definitions/date-time", + }, + "publicationStartTimestamp": Object { + "$ref": "#/definitions/date-time", + }, + "status": Object { + "$ref": "#/definitions/ResourceStatus", + }, + "type": Object { + "$ref": "#/definitions/ResourceType", + }, + }, + "required": Array [ + "name", + "id", + "status", + "type", + "lastUpdateTimestamp", + "lastUpdateUserId", + ], + "title": "ParentFolderGetWithLocalizedNameDTO", + "type": "object", + }, + "Query": Object { + "properties": Object { + "get_resource_by_id_v1": Object { + "$ref": "#/definitions/get_resource_by_id_v1_200_response", + }, + "list_resources_at_any_folder_v1": Object { + "$ref": "#/definitions/list_resources_at_any_folder_v1_200_response", + }, + "list_resources_at_the_root_folder_v1": Object { + "$ref": "#/definitions/list_resources_at_any_folder_v1_200_response", + }, + }, + "title": "Query", + "type": "object", + }, + "QueryInput": Object { + "properties": Object { + "list_resources_at_any_folder_v1": Object { + "$ref": "#/definitions/list_resources_at_any_folder_v1_request", + }, + "list_resources_at_the_root_folder_v1": Object { + "$ref": "#/definitions/list_resources_at_any_folder_v1_request", + }, + }, + "title": "QueryInput", + "type": "object", + }, + "ResourceCreateDTO": Object { + "$resolvedRef": "/components/schemas/ResourceCreateDTO", + "allOf": Array [ + Object { + "$ref": "#/definitions/BaseResourceUpdateDTO", + }, + Object { + "$ref": "#/definitions/mutationInput_create_resource_at_any_folder_v1_oneOf_0_allOf_0_allOf_1", + }, + ], + "title": "ResourceCreateDTO", + }, + "ResourceGetDTO": Object { + "$resolvedRef": "/components/schemas/ResourceGetDTO", + "allOf": Array [ + Object { + "$ref": "#/definitions/query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0", + }, + Object { + "$ref": "#/definitions/BaseResourceDTO", + }, + Object { + "$ref": "#/definitions/query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_2", + }, + Object { + "$ref": "#/definitions/ResourceTimestampDataDTO", + }, + ], + "required": Array [ + "id", + "status", + "type", + ], + "title": "ResourceGetDTO", + }, + "ResourceStatus": Object { + "$resolvedRef": "/components/schemas/ResourceStatus", + "items": Object { + "enum": Array [ + "ACTIVE", + "INACTIVE", + "SCHEDULED", + ], + "title": "query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_status_items", + "type": "string", + }, + "title": "ResourceStatus", + "type": "array", + }, + "ResourceTimestampDataDTO": Object { + "$resolvedRef": "/components/schemas/ResourceTimestampDataDTO", + "properties": Object { + "lastUpdateTimestamp": Object { + "$ref": "#/definitions/date-time", + }, + "lastUpdateUserId": Object { + "type": "string", + }, + }, + "title": "ResourceTimestampDataDTO", + "type": "object", + }, + "ResourceType": Object { + "$resolvedRef": "/components/schemas/ResourceType", + "items": Object { + "enum": Array [ + "FILE", + "FOLDER", + ], + "title": "query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_type_items", + "type": "string", + }, + "title": "ResourceType", + "type": "array", + }, + "_schema": Object { + "properties": Object { + "mutation": Object { + "$ref": "#/definitions/Mutation", + }, + "mutationInput": Object { + "$ref": "#/definitions/MutationInput", + }, + "query": Object { + "$ref": "#/definitions/Query", + }, + "queryInput": Object { + "$ref": "#/definitions/QueryInput", + }, + }, + "required": Array [ + "query", + ], + "title": "_schema", + "type": "object", + }, + "date": Object { + "description": "Publication start date", + "format": "date", + "name": "publicationStartDate", + "title": "date", + "type": "string", + }, + "date-time": Object { + "format": "date-time", + "title": "date-time", + "type": "string", + }, + "date2": Object { + "description": "Publication end date", + "format": "date", + "name": "publicationEndDate", + "title": "date", + "type": "string", + }, + "delete_resource_at_the_root_folder_v1_204_response": Object { + "description": "No Content", + "title": "delete_resource_at_the_root_folder_v1_204_response", + "type": "null", + }, + "get_resource_by_id_v1_200_response": Object { + "$resolvedRef": "/paths/~1api~1v1~1companies~1{companyId}~1knowledgecenter~1resources~1{resourceId}/get/responses/200/content/application~1json/schema", + "oneOf": Array [ + Object { + "$ref": "#/definitions/FileGetWithI18nDTO", + }, + Object { + "$ref": "#/definitions/FolderGetWithI18nDTO", + }, + ], + "title": "get_resource_by_id_v1_200_response", + }, + "int32": Object { + "format": "int32", + "title": "int32", + "type": "integer", + }, + "int322": Object { + "description": "Minimum size of a resource", + "format": "int32", + "name": "minSize", + "title": "int32", + "type": "integer", + }, + "int323": Object { + "description": "Maximum size of a resource", + "format": "int32", + "name": "maxSize", + "title": "int32", + "type": "integer", + }, + "int324": Object { + "description": undefined, + "format": "int32", + "name": "size", + "title": "int32", + "type": "integer", + }, + "list_resources_at_any_folder_v1_200_response": Object { + "$resolvedRef": "/paths/~1api~1v1~1companies~1{companyId}~1knowledgecenter~1folders~1{folderId}~1resources/get/responses/200/content/application~1json/schema", + "items": Object { + "anyOf": Array [ + Object { + "$ref": "#/definitions/FileGetWithLocalizedNameDTO", + }, + Object { + "$ref": "#/definitions/FolderGetWithLocalizedNameDTO", + }, + ], + "title": "query_list_resources_at_any_folder_v1_items", + }, + "title": "list_resources_at_any_folder_v1_200_response", + "type": "array", + }, + "list_resources_at_any_folder_v1_request": Object { + "properties": Object { + "directoryOnly": Object { + "$ref": "#/definitions/queryInput_list_resources_at_any_folder_v1_directoryOnly", + }, + "maxSize": Object { + "$ref": "#/definitions/int323", + }, + "minSize": Object { + "$ref": "#/definitions/int322", + }, + "order": Object { + "description": "List of order", + "items": Object { + "$ref": "#/definitions/queryInput_list_resources_at_any_folder_v1_order_items", + }, + "name": "order", + "type": "array", + }, + "publicationEndDate": Object { + "$ref": "#/definitions/date2", + }, + "publicationStartDate": Object { + "$ref": "#/definitions/date", + }, + "querySearch": Object { + "description": "Text to search in title", + "name": "querySearch", + "type": "string", + }, + "size": Object { + "$ref": "#/definitions/int324", + }, + "startKey": Object { + "description": "The page number", + "name": "startKey", + "type": "string", + }, + "status": Object { + "$ref": "#/definitions/ResourceStatus", + }, + "targetAudience": Object { + "description": "Target of the resource (the resource need to have all of the target audience passed in the list)", + "items": Object { + "type": "string", + }, + "name": "targetAudience", + "type": "array", + }, + }, + "title": "list_resources_at_any_folder_v1_request", + "type": "object", + }, + "mutationInput_create_resource_at_any_folder_v1_oneOf_0_allOf_0_allOf_1": Object { + "properties": Object { + "type": Object { + "$ref": "#/definitions/ResourceType", + }, + }, + "required": Array [ + "status", + "type", + "i18n", + "size", + "url", + "contentType", + ], + "title": "mutationInput_create_resource_at_any_folder_v1_oneOf_0_allOf_0_allOf_1", + "type": "object", + }, + "paths_api_v1_companies_{companyId}_knowledgecenter_folders_{folderId}_resources_post_requestBody_content_application_json_schema": Object { + "$resolvedRef": "/paths/~1api~1v1~1companies~1{companyId}~1knowledgecenter~1folders~1{folderId}~1resources/post/requestBody/content/application~1json/schema", + "oneOf": Array [ + Object { + "$ref": "#/definitions/FileCreateDTO", + }, + Object { + "$ref": "#/definitions/ResourceCreateDTO", + }, + ], + "title": "paths_api_v1_companies_{companyId}_knowledgecenter_folders_{folderId}_resources_post_requestBody_content_application_json_schema", + }, + "queryInput_list_resources_at_any_folder_v1_directoryOnly": Object { + "default": false, + "description": undefined, + "name": "directoryOnly", + "title": "queryInput_list_resources_at_any_folder_v1_directoryOnly", + "type": "boolean", + }, + "queryInput_list_resources_at_any_folder_v1_order_items": Object { + "pattern": "^(FILE_TYPE|NAME|LAST_UPDATE_DATE)(,(ASC|DESC))?$", + "title": "queryInput_list_resources_at_any_folder_v1_order_items", + "type": "string", + }, + "query_get_resource_by_id_v1_oneOf_0_allOf_2": Object { + "properties": Object { + "i18n": Object { + "$ref": "#/definitions/query_get_resource_by_id_v1_oneOf_0_allOf_2_i18n", + }, + }, + "title": "query_get_resource_by_id_v1_oneOf_0_allOf_2", + "type": "object", + }, + "query_get_resource_by_id_v1_oneOf_0_allOf_2_i18n": Object { + "additionalProperties": Object { + "additionalProperties": Object { + "type": "string", + }, + "title": "query_get_resource_by_id_v1_oneOf_0_allOf_2_i18n_additionalProperties", + "type": "object", + }, + "title": "query_get_resource_by_id_v1_oneOf_0_allOf_2_i18n", + "type": "object", + }, + "query_get_resource_by_id_v1_oneOf_0_allOf_2_i18n_additionalProperties": Object { + "additionalProperties": Object { + "type": "string", + }, + "title": "query_get_resource_by_id_v1_oneOf_0_allOf_2_i18n_additionalProperties", + "type": "object", + }, + "query_list_resources_at_any_folder_v1_items": Object { + "anyOf": Array [ + Object { + "$ref": "#/definitions/FileGetWithLocalizedNameDTO", + }, + Object { + "$ref": "#/definitions/FolderGetWithLocalizedNameDTO", + }, + ], + "title": "query_list_resources_at_any_folder_v1_items", + }, + "query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0": Object { + "properties": Object { + "parentHierarchy": Object { + "items": Object { + "$ref": "#/definitions/ParentFolderGetWithLocalizedNameDTO", + }, + "type": "array", + }, + }, + "title": "query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0", + "type": "object", + }, + "query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_isShiftFenced": Object { + "title": "query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_isShiftFenced", + "type": "boolean", + }, + "query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_status_items": Object { + "enum": Array [ + "ACTIVE", + "INACTIVE", + "SCHEDULED", + ], + "title": "query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_status_items", + "type": "string", + }, + "query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_type_items": Object { + "enum": Array [ + "FILE", + "FOLDER", + ], + "title": "query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_type_items", + "type": "string", + }, + "query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_2": Object { + "properties": Object { + "id": Object { + "type": "string", + }, + "type": Object { + "$ref": "#/definitions/ResourceType", + }, + }, + "title": "query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_2", + "type": "object", + }, + "query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_2": Object { + "properties": Object { + "name": Object { + "type": "string", + }, + }, + "title": "query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_2", + "type": "object", + }, + }, + }, +} +`; + +exports[`Toto should generate the correct schema 1`] = ` +"schema { + query: Query + mutation: Mutation +} + +directive @oneOf on INPUT_OBJECT | FIELD_DEFINITION + +type Query { + \\"List Resources At Any Folder Level\\" + list_resources_at_any_folder_v1(input: list_resources_at_any_folder_v1_request_Input, Accept_Language: String, X_Correlation_Id: String, companyId: String!, folderId: String!): [query_list_resources_at_any_folder_v1_items] + \\"List All Resources At The Root Folder\\" + list_resources_at_the_root_folder_v1(input: list_resources_at_any_folder_v1_request_Input, Accept_Language: String, X_Correlation_Id: String, companyId: String!): [query_list_resources_at_any_folder_v1_items] + \\"Get Resource by ID\\" + get_resource_by_id_v1(Accept_Language: String, X_Correlation_Id: String, companyId: String!, resourceId: String!): get_resource_by_id_v1_200_response +} + +type query_list_resources_at_any_folder_v1_items { + parentHierarchy: [ParentFolderGetWithLocalizedNameDTO] + parentFolderId: String + status: [query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_status_items] + publicationStartTimestamp: DateTime + publicationEndTimestamp: DateTime + previewUrl: String + allowedTargetAudiences: [String] + shiftFenced: Boolean + punchedFenced: Boolean + geoFenced: Boolean + pinned: Boolean + type: [query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_type_items] + id: String + lastUpdateTimestamp: DateTime + lastUpdateUserId: String + size: Int + url: String + contentType: String + name: String + fileCount: Int + childFolderCount: Int +} + +type ParentFolderGetWithLocalizedNameDTO { + type: [query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_type_items]! + id: String! + status: [query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_status_items]! + publicationStartTimestamp: DateTime + publicationEndTimestamp: DateTime + previewUrl: String + allowedTargetAudiences: [String] + isShiftFenced: Boolean + isPunchedFenced: Boolean + isGeoFenced: Boolean + isPinned: Boolean + name: String! + creationTimestamp: DateTime + creationUserId: String + lastUpdateTimestamp: DateTime! + lastUpdateUserId: String! + fileCount: Int + childFolderCount: Int +} + +enum query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_type_items { + FILE + FOLDER +} + +enum query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_status_items { + ACTIVE + INACTIVE + SCHEDULED +} + +\\"A date-time string at UTC, such as 2007-12-03T10:15:30Z, compliant with the \`date-time\` format outlined in section 5.6 of the RFC 3339 profile of the ISO 8601 standard for representation of dates and times using the Gregorian calendar.\\" +scalar DateTime + +input list_resources_at_any_folder_v1_request_Input { + \\"Text to search in title\\" + querySearch: String + \\"Minimum size of a resource\\" + minSize: Int + \\"Maximum size of a resource\\" + maxSize: Int + status: [query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_status_items] + directoryOnly: Boolean + \\"List of order\\" + order: [queryInput_list_resources_at_any_folder_v1_order_items] + \\"Target of the resource (the resource need to have all of the target audience passed in the list)\\" + targetAudience: [String] + \\"Publication start date\\" + publicationStartDate: Date + \\"Publication end date\\" + publicationEndDate: Date + \\"The page number\\" + startKey: String + size: Int +} + +\\"A field whose value matches /^(FILE_TYPE|NAME|LAST_UPDATE_DATE)(,(ASC|DESC))?$/.\\" +scalar queryInput_list_resources_at_any_folder_v1_order_items + +\\"Represents date values\\" +scalar Date + +union get_resource_by_id_v1_200_response = FileGetWithI18nDTO | FolderGetWithI18nDTO + +type FileGetWithI18nDTO { + parentHierarchy: [ParentFolderGetWithLocalizedNameDTO] + parentFolderId: String + status: [query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_status_items] + publicationStartTimestamp: DateTime + publicationEndTimestamp: DateTime + previewUrl: String + allowedTargetAudiences: [String] + shiftFenced: Boolean + punchedFenced: Boolean + geoFenced: Boolean + pinned: Boolean + type: [query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_type_items] + id: String + lastUpdateTimestamp: DateTime + lastUpdateUserId: String + size: Int + url: String + contentType: String + i18n: query_get_resource_by_id_v1_oneOf_0_allOf_2_i18n_additionalProperties +} + +type query_get_resource_by_id_v1_oneOf_0_allOf_2_i18n_additionalProperties { + additionalProperties: JSON +} + +\\"The \`JSON\` scalar type represents JSON values as specified by [ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf).\\" +scalar JSON @specifiedBy(url: \\"http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf\\") + +type FolderGetWithI18nDTO { + parentHierarchy: [ParentFolderGetWithLocalizedNameDTO] + parentFolderId: String + status: [query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_status_items] + publicationStartTimestamp: DateTime + publicationEndTimestamp: DateTime + previewUrl: String + allowedTargetAudiences: [String] + shiftFenced: Boolean + punchedFenced: Boolean + geoFenced: Boolean + pinned: Boolean + type: [query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_type_items] + id: String + lastUpdateTimestamp: DateTime + lastUpdateUserId: String + fileCount: Int + childFolderCount: Int + i18n: query_get_resource_by_id_v1_oneOf_0_allOf_2_i18n_additionalProperties +} + +type Mutation { + \\"Create resources at any folder level\\" + create_resource_at_any_folder_v1(input: paths_api_v1_companies__LEFT_CURLY_BRACE_companyId_RIGHT_CURLY_BRACE__knowledgecenter_folders__LEFT_CURLY_BRACE_folderId_RIGHT_CURLY_BRACE__resources_post_requestBody_content_application_json_schema_Input, Accept_Language: String, X_Correlation_Id: String, companyId: String!, folderId: String!): get_resource_by_id_v1_200_response + \\"Update A Resource At Any Folder Level\\" + update_resource_at_any_folder_v1(input: paths_api_v1_companies__LEFT_CURLY_BRACE_companyId_RIGHT_CURLY_BRACE__knowledgecenter_folders__LEFT_CURLY_BRACE_folderId_RIGHT_CURLY_BRACE__resources_post_requestBody_content_application_json_schema_Input, Accept_Language: String, X_Correlation_Id: String, companyId: String!, folderId: String!, resourceId: String!): get_resource_by_id_v1_200_response + \\"Create A Resource At The Root Folder\\" + create_resource_at_the_root_folder_v1(input: paths_api_v1_companies__LEFT_CURLY_BRACE_companyId_RIGHT_CURLY_BRACE__knowledgecenter_folders__LEFT_CURLY_BRACE_folderId_RIGHT_CURLY_BRACE__resources_post_requestBody_content_application_json_schema_Input, Accept_Language: String, X_Correlation_Id: String, companyId: String!): get_resource_by_id_v1_200_response + \\"Update A Resource At The Root Folder\\" + update_resource_at_the_root_folder_v1(input: paths_api_v1_companies__LEFT_CURLY_BRACE_companyId_RIGHT_CURLY_BRACE__knowledgecenter_folders__LEFT_CURLY_BRACE_folderId_RIGHT_CURLY_BRACE__resources_post_requestBody_content_application_json_schema_Input, Accept_Language: String, X_Correlation_Id: String, companyId: String!, resourceId: String!): get_resource_by_id_v1_200_response + \\"Delete A Resource At The Root Folder\\" + delete_resource_at_the_root_folder_v1(Accept_Language: String, X_Correlation_Id: String, companyId: String!, resourceId: String!): Void +} + +input paths_api_v1_companies__LEFT_CURLY_BRACE_companyId_RIGHT_CURLY_BRACE__knowledgecenter_folders__LEFT_CURLY_BRACE_folderId_RIGHT_CURLY_BRACE__resources_post_requestBody_content_application_json_schema_Input @oneOf { + FileCreateDTO_Input: FileCreateDTO_Input + ResourceCreateDTO_Input: ResourceCreateDTO_Input +} + +input FileCreateDTO_Input { + parentFolderId: String + status: [query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_status_items] + publicationStartTimestamp: DateTime + publicationEndTimestamp: DateTime + previewUrl: String + allowedTargetAudiences: [String] + shiftFenced: Boolean + punchedFenced: Boolean + geoFenced: Boolean + pinned: Boolean + i18n: query_get_resource_by_id_v1_oneOf_0_allOf_2_i18n_additionalProperties_Input2 + type: [query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_type_items]! + size: Int + url: String + contentType: String +} + +scalar query_get_resource_by_id_v1_oneOf_0_allOf_2_i18n_additionalProperties_Input2 + +input ResourceCreateDTO_Input { + parentFolderId: String + status: [query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_status_items] + publicationStartTimestamp: DateTime + publicationEndTimestamp: DateTime + previewUrl: String + allowedTargetAudiences: [String] + shiftFenced: Boolean + punchedFenced: Boolean + geoFenced: Boolean + pinned: Boolean + i18n: query_get_resource_by_id_v1_oneOf_0_allOf_2_i18n_additionalProperties_Input2 + type: [query_list_resources_at_any_folder_v1_items_anyOf_0_allOf_0_allOf_0_parentHierarchy_items_type_items]! +} + +\\"Represents empty values\\" +scalar Void" +`; diff --git a/packages/loaders/openapi/tests/fixtures/toto.yml b/packages/loaders/openapi/tests/fixtures/toto.yml new file mode 100644 index 0000000000000..9dae159d7b2c6 --- /dev/null +++ b/packages/loaders/openapi/tests/fixtures/toto.yml @@ -0,0 +1,665 @@ +openapi: 3.0.0 +info: + version: '2022.02' + title: Toto + description: |- + ## General + + High level documentation can be found in the [BitBucket Wiki](https://bitbucket.org/test/test-api-documentation/wiki/browse). + + Documentation that applies to all endpoints: + + * [Default Endpoint Behavior](https://bitbucket.org/test/test-api-documentation/wiki/Default%20Endpoint%20Behavior) + * [API Conventions](https://bitbucket.org/test/test-api-documentation/wiki/API%20Conventions) + * [Error Handling](https://bitbucket.org/test/test-api-documentation/wiki/Error%20Handling) + x-codegen-values: + apiVersionString: v1 + apiVersionInt: 1 + filePath: api/v1/v1_api-knowledge-center.yml +servers: + - url: https://dev-api.test.com/api/v1 + description: The dev API server +paths: + /api/v1/companies/{companyId}/knowledgecenter/folders/{folderId}/resources: + parameters: + - $ref: '#/components/parameters/companyId' + - $ref: '#/components/parameters/folderId' + - $ref: '#/components/parameters/Accept-Language' + - $ref: '#/components/parameters/X-Correlation-Id' + get: + operationId: list-resources-at-any-folder-v1 + summary: List Resources At Any Folder Level + tags: + - Resources controller + description: List Resources At Any Folder Level + parameters: + - $ref: '#/components/parameters/querySearch' + - $ref: '#/components/parameters/minSize' + - $ref: '#/components/parameters/maxSize' + - $ref: '#/components/parameters/status' + - $ref: '#/components/parameters/directoryOnly' + - $ref: '#/components/parameters/order' + - $ref: '#/components/parameters/targetAudience' + - $ref: '#/components/parameters/publicationStartDate' + - $ref: '#/components/parameters/publicationEndDate' + - $ref: '#/components/parameters/startKey' + - $ref: '#/components/parameters/size' + responses: + '200': + description: OK + content: + application/json: + schema: + type: array + items: + anyOf: + - $ref: '#/components/schemas/FileGetWithLocalizedNameDTO' + - $ref: '#/components/schemas/FolderGetWithLocalizedNameDTO' + post: + operationId: create-resource-at-any-folder-v1 + summary: Create Resources At Any Folder Level + tags: + - Resources controller + description: Create resources at any folder level + requestBody: + required: true + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/FileCreateDTO' + - $ref: '#/components/schemas/FolderCreateDTO' + responses: + '201': + description: CREATED + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/FileGetWithI18nDTO' + - $ref: '#/components/schemas/FolderGetWithI18nDTO' + /api/v1/companies/{companyId}/knowledgecenter/folders/{folderId}/resources/{resourceId}: + parameters: + - $ref: '#/components/parameters/companyId' + - $ref: '#/components/parameters/folderId' + - $ref: '#/components/parameters/resourceId' + - $ref: '#/components/parameters/Accept-Language' + - $ref: '#/components/parameters/X-Correlation-Id' + put: + operationId: update-resource-at-any-folder-v1 + summary: Update A Resource At Any Folder Level + tags: + - Resources controller + description: Update A Resource At Any Folder Level + requestBody: + required: true + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/FileUpdateDTO' + - $ref: '#/components/schemas/FolderUpdateDTO' + responses: + '200': + description: OK + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/FileGetWithI18nDTO' + - $ref: '#/components/schemas/FolderGetWithI18nDTO' + + /api/v1/companies/{companyId}/knowledgecenter/resources: + parameters: + - $ref: '#/components/parameters/companyId' + - $ref: '#/components/parameters/Accept-Language' + - $ref: '#/components/parameters/X-Correlation-Id' + get: + operationId: list-resources-at-the-root-folder-v1 + summary: List All Resources At The Root Folder + tags: + - Resources controller + description: List All Resources At The Root Folder + parameters: + - $ref: '#/components/parameters/querySearch' + - $ref: '#/components/parameters/minSize' + - $ref: '#/components/parameters/maxSize' + - $ref: '#/components/parameters/status' + - $ref: '#/components/parameters/directoryOnly' + - $ref: '#/components/parameters/order' + - $ref: '#/components/parameters/targetAudience' + - $ref: '#/components/parameters/publicationStartDate' + - $ref: '#/components/parameters/publicationEndDate' + - $ref: '#/components/parameters/startKey' + - $ref: '#/components/parameters/size' + responses: + '200': + description: OK + content: + application/json: + schema: + type: array + items: + anyOf: + - $ref: '#/components/schemas/FileGetWithLocalizedNameDTO' + - $ref: '#/components/schemas/FolderGetWithLocalizedNameDTO' + post: + operationId: create-resource-at-the-root-folder-v1 + summary: Create A Resource At The Root Folder + tags: + - Resources controller + description: Create A Resource At The Root Folder + requestBody: + required: true + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/FileCreateDTO' + - $ref: '#/components/schemas/FolderCreateDTO' + responses: + '201': + description: CREATED + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/FileGetWithI18nDTO' + - $ref: '#/components/schemas/FolderGetWithI18nDTO' + + /api/v1/companies/{companyId}/knowledgecenter/resources/{resourceId}: + parameters: + - $ref: '#/components/parameters/companyId' + - $ref: '#/components/parameters/resourceId' + - $ref: '#/components/parameters/Accept-Language' + - $ref: '#/components/parameters/X-Correlation-Id' + get: + operationId: get-resource-by-id-v1 + summary: Get Resource by ID + tags: + - Resources controller + description: Get Resource by ID + responses: + '200': + description: OK + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/FileGetWithI18nDTO' + - $ref: '#/components/schemas/FolderGetWithI18nDTO' + put: + operationId: update-resource-at-the-root-folder-v1 + summary: Update A Resource At The Root Folder + tags: + - Resources controller + description: Update A Resource At The Root Folder + requestBody: + required: true + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/FileUpdateDTO' + - $ref: '#/components/schemas/FolderUpdateDTO' + responses: + '200': + description: OK + content: + application/json: + schema: + oneOf: + - $ref: '#/components/schemas/FileGetWithI18nDTO' + - $ref: '#/components/schemas/FolderGetWithI18nDTO' + delete: + operationId: delete-resource-at-the-root-folder-v1 + summary: Delete A Resource At The Root Folder + tags: + - Resources controller + description: Delete A Resource At The Root Folder + responses: + '204': + description: No Content + default: + $ref: '#/components/responses/common_Error' + +components: + schemas: + FilePropertiesDTO: + type: object + properties: + size: + type: integer + format: int32 + url: + type: string + contentType: + type: string + FolderPropertiesDTO: + type: object + properties: + fileCount: + type: integer + format: int32 + childFolderCount: + type: integer + format: int32 + ResourceTimestampDataDTO: + type: object + properties: + lastUpdateTimestamp: + type: string + format: date-time + lastUpdateUserId: + type: string + + BaseResourceDTO: + type: object + properties: + parentFolderId: + type: string + status: + $ref: '#/components/schemas/ResourceStatus' + publicationStartTimestamp: + type: string + format: date-time + publicationEndTimestamp: + type: string + format: date-time + previewUrl: + type: string + allowedTargetAudiences: + type: array + items: + type: string + shiftFenced: + type: boolean + punchedFenced: + type: boolean + geoFenced: + type: boolean + pinned: + type: boolean + + BaseResourceUpdateDTO: + allOf: + - $ref: '#/components/schemas/BaseResourceDTO' + - type: object + properties: + i18n: + type: object + additionalProperties: + type: object + additionalProperties: + type: string + + ResourceGetDTO: + allOf: + - type: object + properties: + parentHierarchy: + type: array + items: + $ref: '#/components/schemas/ParentFolderGetWithLocalizedNameDTO' + - $ref: '#/components/schemas/BaseResourceDTO' + - type: object + properties: + type: + $ref: '#/components/schemas/ResourceType' + id: + type: string + - $ref: '#/components/schemas/ResourceTimestampDataDTO' + required: + - id + - status + - type + FileGetWithI18nDTO: + allOf: + - $ref: '#/components/schemas/ResourceGetDTO' + - $ref: '#/components/schemas/FilePropertiesDTO' + - type: object + properties: + i18n: + type: object + additionalProperties: + type: object + additionalProperties: + type: string + required: + - size + - url + - contentType + - i18n + FolderGetWithI18nDTO: + allOf: + - $ref: '#/components/schemas/ResourceGetDTO' + - $ref: '#/components/schemas/FolderPropertiesDTO' + - type: object + properties: + i18n: + type: object + additionalProperties: + type: object + additionalProperties: + type: string + required: + - i18n + FileGetWithLocalizedNameDTO: + allOf: + - $ref: '#/components/schemas/ResourceGetDTO' + - $ref: '#/components/schemas/FilePropertiesDTO' + - type: object + properties: + name: + type: string + required: + - size + - url + - contentType + - name + FolderGetWithLocalizedNameDTO: + allOf: + - $ref: '#/components/schemas/ResourceGetDTO' + - $ref: '#/components/schemas/FolderPropertiesDTO' + - type: object + properties: + name: + type: string + required: + - name + ParentFolderGetWithLocalizedNameDTO: + type: object + properties: + type: + $ref: '#/components/schemas/ResourceType' + id: + type: string + status: + $ref: '#/components/schemas/ResourceStatus' + publicationStartTimestamp: + type: string + format: date-time + publicationEndTimestamp: + type: string + format: date-time + previewUrl: + type: string + allowedTargetAudiences: + type: array + items: + type: string + isShiftFenced: + type: boolean + isPunchedFenced: + type: boolean + isGeoFenced: + type: boolean + isPinned: + type: boolean + name: + type: string + creationTimestamp: + type: string + format: date-time + creationUserId: + type: string + lastUpdateTimestamp: + type: string + format: date-time + lastUpdateUserId: + type: string + fileCount: + type: integer + format: int32 + childFolderCount: + type: integer + format: int32 + required: + - name + - id + - status + - type + - lastUpdateTimestamp + - lastUpdateUserId + ResourceCreateDTO: + allOf: + - $ref: '#/components/schemas/BaseResourceUpdateDTO' + - type: object + properties: + type: + $ref: '#/components/schemas/ResourceType' + required: + - status + - type + - i18n + - size + - url + - contentType + FileCreateDTO: + allOf: + - $ref: '#/components/schemas/ResourceCreateDTO' + - $ref: '#/components/schemas/FilePropertiesDTO' + FolderCreateDTO: + allOf: + - $ref: '#/components/schemas/ResourceCreateDTO' + + ResourceUpdateDTO: + allOf: + - $ref: '#/components/schemas/BaseResourceUpdateDTO' + FileUpdateDTO: + allOf: + - $ref: '#/components/schemas/ResourceUpdateDTO' + - $ref: '#/components/schemas/FilePropertiesDTO' + FolderUpdateDTO: + allOf: + - $ref: '#/components/schemas/ResourceUpdateDTO' + ResourceStatus: + type: array + items: + type: string + enum: + - ACTIVE + - INACTIVE + - SCHEDULED + ResourceType: + type: array + items: + type: string + enum: + - FILE + - FOLDER + + v1_common_error: + title: Error + type: object + additionalProperties: false + externalDocs: + description: Refer to the Error Handling wiki page for domains and reasons. + url: https://bitbucket.org/test/test-api-documentation/wiki/Error%20Handling + properties: + status: + type: integer + timestamp: + type: string + format: date-time + exception: + type: string + path: + type: string + message: + type: string + description: Localized and human readable message taken from the first error. + pattern: ^(?![A-Z_]*$).*$ + debugMessage: + type: string + description: Message for debug purposes. Not intended to be shown the users. + errors: + type: array + items: + $ref: '#/components/schemas/v1_common_error_details' + required: + - status + - timestamp + - path + - message + - localizedMessage + v1_common_error_details: + title: Error Details + type: object + properties: + domain: + type: string + enum: + - KNOWLEDGE_CENTER + reason: + type: string + pattern: ^[A-Z_]+$ + location: + type: string + locationType: + type: string + enum: + - HEADER + - PARAMETER + - FIELD + - PERMISSION + message: + type: string + description: Localized and human readable message. + pattern: ^(?![A-Z_]*$).*$ + required: + - domain + - reason + - message + responses: + common_Error: + description: Error + content: + application/json: + schema: + $ref: '#/components/schemas/v1_common_error' + parameters: + # Path Parameters + companyId: + name: companyId + in: path + required: true + schema: + type: string + folderId: + name: folderId + in: path + required: true + schema: + type: string + resourceId: + name: resourceId + in: path + required: true + schema: + type: string + querySearch: + name: querySearch + description: Text to search in title + in: query + required: false + schema: + type: string + minSize: + name: minSize + description: Minimum size of a resource + in: query + required: false + schema: + type: integer + format: int32 + maxSize: + name: maxSize + description: Maximum size of a resource + in: query + required: false + schema: + type: integer + format: int32 + status: + name: status + description: Status of the resource + in: query + required: false + schema: + $ref: '#/components/schemas/ResourceStatus' + directoryOnly: + name: directoryOnly + in: query + required: false + schema: + type: boolean + default: false + order: + name: order + description: List of order + in: query + required: false + schema: + type: array + items: + type: string + pattern: '^(FILE_TYPE|NAME|LAST_UPDATE_DATE)(,(ASC|DESC))?$' + targetAudience: + name: targetAudience + description: Target of the resource (the resource need to have all of the target audience passed in the list) + in: query + required: false + schema: + type: array + items: + type: string + publicationStartDate: + name: publicationStartDate + description: Publication start date + in: query + required: false + schema: + type: string + format: date + publicationEndDate: + name: publicationEndDate + description: Publication end date + in: query + required: false + schema: + type: string + format: date + startKey: + name: startKey + description: The page number + in: query + required: false + schema: + type: string + size: + name: size + in: query + required: false + schema: + type: integer + format: int32 + # Header Parameters + Accept-Language: + name: Accept-Language + in: header + description: As defined in RFC 3282 https://tools.ietf.org/html/rfc3282 + schema: + type: string + X-Correlation-Id: + name: X-Correlation-Id + in: header + description: Correlation ID from the auth call. + schema: + type: string + X-Last-Evaluated-Key: + name: X-Last-Evaluated-Key + in: header + description: Contains the page as string for the next call. + schema: + type: string diff --git a/packages/loaders/openapi/tests/toto.test.ts b/packages/loaders/openapi/tests/toto.test.ts new file mode 100644 index 0000000000000..6f2782e196733 --- /dev/null +++ b/packages/loaders/openapi/tests/toto.test.ts @@ -0,0 +1,19 @@ +import { printSchemaWithDirectives } from '@graphql-tools/utils'; +import loadGraphQLSchemaFromOpenAPI, { createBundle } from '../src'; + +describe('Toto', () => { + it('should generate the correct bundle', async () => { + const bundle = await createBundle('toto', { + oasFilePath: './fixtures/toto.yml', + cwd: __dirname, + }); + expect(bundle).toMatchSnapshot(); + }); + it('should generate the correct schema', async () => { + const schema = await loadGraphQLSchemaFromOpenAPI('toto', { + oasFilePath: './fixtures/toto.yml', + cwd: __dirname, + }); + expect(printSchemaWithDirectives(schema)).toMatchSnapshot(); + }); +});