Skip to content

Commit

Permalink
Merge branch 'main' into ns-workflows-1-specification
Browse files Browse the repository at this point in the history
  • Loading branch information
frankkilcommins authored Dec 4, 2023
2 parents 4c7030d + 69d0f95 commit d487499
Show file tree
Hide file tree
Showing 72 changed files with 253 additions and 297 deletions.
14 changes: 7 additions & 7 deletions packages/apidom-ls/src/config/openapi/example/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
CompletionFormat,
CompletionType,
} from '../../../apidom-language-types';
import { OpenAPI30, OpenAPI31, OpenAPI3 } from '../target-specs';

const completion: ApidomCompletionItem[] = [
{
Expand All @@ -16,6 +17,7 @@ const completion: ApidomCompletionItem[] = [
kind: 'markdown',
value: 'A reference to an Example.',
},
targetSpecs: OpenAPI3,
},
{
label: 'summary',
Expand All @@ -28,6 +30,7 @@ const completion: ApidomCompletionItem[] = [
kind: 'markdown',
value: 'Short description for the example.',
},
targetSpecs: OpenAPI3,
},
{
label: 'description',
Expand All @@ -41,6 +44,7 @@ const completion: ApidomCompletionItem[] = [
value:
'Long description for the example. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.',
},
targetSpecs: OpenAPI3,
},
{
label: 'value',
Expand All @@ -54,6 +58,7 @@ const completion: ApidomCompletionItem[] = [
value:
'Embedded literal example. The `value` field and `externalValue` field are mutually exclusive. To represent examples of media types that cannot naturally represented in JSON or YAML, use a string value to contain the example, escaping where necessary.',
},
targetSpecs: OpenAPI3,
},
{
label: 'externalValue',
Expand All @@ -67,12 +72,7 @@ const completion: ApidomCompletionItem[] = [
value:
'A URI that points to the literal example. This provides the capability to reference examples that cannot easily be included in JSON or YAML documents. The `value` field and `externalValue` field are mutually exclusive.',
},
targetSpecs: [
{ namespace: 'openapi', version: '3.0.0' },
{ namespace: 'openapi', version: '3.0.1' },
{ namespace: 'openapi', version: '3.0.2' },
{ namespace: 'openapi', version: '3.0.3' },
],
targetSpecs: OpenAPI30,
},
{
label: 'externalValue',
Expand All @@ -86,7 +86,7 @@ const completion: ApidomCompletionItem[] = [
value:
'A URI that points to the literal example. This provides the capability to reference examples that cannot easily be included in JSON or YAML documents. The `value` field and `externalValue` field are mutually exclusive. See the rules for resolving [Relative References](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#relativeReferencesURI).',
},
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
targetSpecs: OpenAPI31,
},
];

Expand Down
23 changes: 9 additions & 14 deletions packages/apidom-ls/src/config/openapi/example/documentation.ts
Original file line number Diff line number Diff line change
@@ -1,43 +1,38 @@
import { OpenAPI30, OpenAPI31, OpenAPI3 } from '../target-specs';

const documentation = [
{
target: 'summary',
docs: 'Short description for the example.',
targetSpecs: OpenAPI3,
},
{
target: 'description',
docs: 'Long description for the example. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.',
targetSpecs: OpenAPI3,
},
{
target: 'value',
docs: 'Embedded literal example. The `value` field and `externalValue` field are mutually exclusive. To represent examples of media types that cannot naturally represented in JSON or YAML, use a string value to contain the example, escaping where necessary.',
targetSpecs: OpenAPI3,
},
{
target: 'externalValue',
docs: 'A URI that points to the literal example. This provides the capability to reference examples that cannot easily be included in JSON or YAML documents. The `value` field and `externalValue` field are mutually exclusive.',
targetSpecs: [
{ namespace: 'openapi', version: '3.0.0' },
{ namespace: 'openapi', version: '3.0.1' },
{ namespace: 'openapi', version: '3.0.2' },
{ namespace: 'openapi', version: '3.0.3' },
],
targetSpecs: OpenAPI30,
},
{
target: 'externalValue',
docs: 'A URI that points to the literal example. This provides the capability to reference examples that cannot easily be included in JSON or YAML documents. The `value` field and `externalValue` field are mutually exclusive. See the rules for resolving [Relative References](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#relativeReferencesURI).',
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
targetSpecs: OpenAPI31,
},
{
docs: "#### [Example Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#exampleObject)\n\n##### Fixed Fields\nField Name | Type | Description\n---|:---:|---\nsummary | `string` | Short description for the example.\ndescription | `string` | Long description for the example. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.\nvalue | Any | Embedded literal example. The `value` field and `externalValue` field are mutually exclusive. To represent examples of media types that cannot naturally represented in JSON or YAML, use a string value to contain the example, escaping where necessary.\nexternalValue | `string` | A URL that points to the literal example. This provides the capability to reference examples that cannot easily be included in JSON or YAML documents. The `value` field and `externalValue` field are mutually exclusive.\n\nThis object MAY be extended with [Specification Extensions](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#specificationExtensions).\n\nIn all cases, the example value is expected to be compatible with the type schema\nof its associated value. Tooling implementations MAY choose to\nvalidate compatibility automatically, and reject the example value(s) if incompatible.\n\n##### Example Object Examples\n\nIn a request body:\n\n\n\\\nYAML\n```yaml\nrequestBody:\n content:\n 'application/json':\n schema:\n $ref: '#/components/schemas/Address'\n examples:\n foo:\n summary: A foo example\n value: {\"foo\": \"bar\"}\n bar:\n summary: A bar example\n value: {\"bar\": \"baz\"}\n 'application/xml':\n examples:\n xmlExample:\n summary: This is an example in XML\n externalValue: 'http://example.org/examples/address-example.xml'\n 'text/plain':\n examples:\n textExample:\n summary: This is a text example\n externalValue: 'http://foo.bar/examples/address-example.txt'\n```\n\nIn a parameter:\n\n```yaml\nparameters:\n - name: 'zipCode'\n in: 'query'\n schema:\n type: 'string'\n format: 'zip-code'\n examples:\n zip-example:\n $ref: '#/components/examples/zip-example'\n```\n\nIn a response:\n\n```yaml\nresponses:\n '200':\n description: your car appointment has been booked\n content:\n application/json:\n schema:\n $ref: '#/components/schemas/SuccessResponse'\n examples:\n confirmation-success:\n $ref: '#/components/examples/confirmation-success'\n```",
targetSpecs: [
{ namespace: 'openapi', version: '3.0.0' },
{ namespace: 'openapi', version: '3.0.1' },
{ namespace: 'openapi', version: '3.0.2' },
{ namespace: 'openapi', version: '3.0.3' },
],
targetSpecs: OpenAPI30,
},
{
docs: "#### [Example Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#exampleObject)\n\n##### Fixed Fields\n\nField Name | Type | Description\n---|:---:|---\nsummary | `string` | Short description for the example.\ndescription | `string` | Long description for the example. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.\nvalue | Any | Embedded literal example. The `value` field and `externalValue` field are mutually exclusive. To represent examples of media types that cannot naturally represented in JSON or YAML, use a string value to contain the example, escaping where necessary.\nexternalValue | `string` | A URI that points to the literal example. This provides the capability to reference examples that cannot easily be included in JSON or YAML documents. The `value` field and `externalValue` field are mutually exclusive. See the rules for resolving [Relative References](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#relativeReferencesURI).\n\n\\\nThis object MAY be extended with [Specification Extensions](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specificationExtensions).\n\n\\\nIn all cases, the example value is expected to be compatible with the type schema of its associated value. Tooling implementations MAY choose to validate compatibility automatically, and reject the example value(s) if incompatible.\n##### Example Object Examples\n\nIn a request body:\n\n\\\nYAML\n```yaml\nrequestBody:\n content:\n 'application/json':\n schema:\n $ref: '#/components/schemas/Address'\n examples: \n foo:\n summary: A foo example\n value: {\"foo\": \"bar\"}\n bar:\n summary: A bar example\n value: {\"bar\": \"baz\"}\n 'application/xml':\n examples: \n xmlExample:\n summary: This is an example in XML\n externalValue: 'https://example.org/examples/address-example.xml'\n 'text/plain':\n examples:\n textExample: \n summary: This is a text example\n externalValue: 'https://foo.bar/examples/address-example.txt'\n```\n\n\\\nIn a parameter:\n\n\\\nYAML\n```yaml\nparameters:\n - name: 'zipCode'\n in: 'query'\n schema:\n type: 'string'\n format: 'zip-code'\n examples:\n zip-example: \n $ref: '#/components/examples/zip-example'\n```\n\n\\\nIn a response:\n\n\\\nYAML\n```yaml\nresponses:\n '200':\n description: your car appointment has been booked\n content: \n application/json:\n schema:\n $ref: '#/components/schemas/SuccessResponse'\n examples:\n confirmation-success:\n $ref: '#/components/examples/confirmation-success'\n```\n",
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
targetSpecs: OpenAPI31,
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI30 } from '../../target-specs';

// eslint-disable-next-line @typescript-eslint/naming-convention
const allowedFields3_0Lint: LinterMeta = {
Expand All @@ -12,12 +13,7 @@ const allowedFields3_0Lint: LinterMeta = {
linterFunction: 'allowedFields',
linterParams: [['summary', 'description', 'value', 'externalValue', '$ref'], 'x-'],
marker: 'key',
targetSpecs: [
{ namespace: 'openapi', version: '3.0.0' },
{ namespace: 'openapi', version: '3.0.1' },
{ namespace: 'openapi', version: '3.0.2' },
{ namespace: 'openapi', version: '3.0.3' },
],
targetSpecs: OpenAPI30,
};

export default allowedFields3_0Lint;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI31 } from '../../target-specs';

// eslint-disable-next-line @typescript-eslint/naming-convention
const allowedFields3_1Lint: LinterMeta = {
Expand All @@ -18,7 +19,7 @@ const allowedFields3_1Lint: LinterMeta = {
params: ['$ref'],
},
],
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
targetSpecs: OpenAPI31,
};

export default allowedFields3_1Lint;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI3 } from '../../target-specs';

const descriptionTypeLint: LinterMeta = {
code: ApilintCodes.OPENAPI3_0_EXAMPLE_FIELD_DESCRIPTION_TYPE,
Expand All @@ -13,6 +14,7 @@ const descriptionTypeLint: LinterMeta = {
marker: 'value',
target: 'description',
data: {},
targetSpecs: OpenAPI3,
};

export default descriptionTypeLint;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI3 } from '../../target-specs';

const externalValueFormatURILint: LinterMeta = {
code: ApilintCodes.OPENAPI3_0_EXAMPLE_FIELD_EXTERNAL_VALUE_FORMAT_URI,
Expand All @@ -12,6 +13,7 @@ const externalValueFormatURILint: LinterMeta = {
marker: 'value',
target: 'externalValue',
data: {},
targetSpecs: OpenAPI3,
};

export default externalValueFormatURILint;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI3 } from '../../target-specs';

const summaryTypeLint: LinterMeta = {
code: ApilintCodes.OPENAPI3_0_EXAMPLE_FIELD_SUMMARY_TYPE,
Expand All @@ -13,6 +14,7 @@ const summaryTypeLint: LinterMeta = {
marker: 'value',
target: 'summary',
data: {},
targetSpecs: OpenAPI3,
};

export default summaryTypeLint;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI3 } from '../../target-specs';

const valueMutuallyExclusiveLint: LinterMeta = {
code: ApilintCodes.OPENAPI3_0_EXAMPLE_FIELD_VALUE_MUTUALLY_EXCLUSIVE,
Expand All @@ -18,6 +19,7 @@ const valueMutuallyExclusiveLint: LinterMeta = {
params: [['externalValue']],
},
],
targetSpecs: OpenAPI3,
};

export default valueMutuallyExclusiveLint;
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
CompletionFormat,
CompletionType,
} from '../../../apidom-language-types';
import { OpenAPI3 } from '../target-specs';

const completion: ApidomCompletionItem[] = [
{
Expand All @@ -17,6 +18,7 @@ const completion: ApidomCompletionItem[] = [
value:
'A description of the target documentation. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.',
},
targetSpecs: OpenAPI3,
},
{
label: 'url',
Expand All @@ -30,6 +32,7 @@ const completion: ApidomCompletionItem[] = [
value:
'**REQUIRED**. The URL for the target documentation. This MUST be in the form of a URL.',
},
targetSpecs: OpenAPI3,
},
];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import { OpenAPI30, OpenAPI31, OpenAPI3 } from '../target-specs';

const documentation = [
{
target: 'description',
docs: 'A description of the target documentation. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.',
targetSpecs: OpenAPI3,
},
{
target: 'url',
docs: '**REQUIRED**. The URL for the target documentation. This MUST be in the form of a URL.',
targetSpecs: OpenAPI3,
},
{
docs: '#### [External Documentation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#externalDocumentationObject)\n\nAllows referencing an external resource for extended documentation.\n\n##### Fixed Fields\n\nField Name | Type | Description\n---|:---:|---\ndescription | `string` | A short description of the target documentation. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.\nurl | `string` | **REQUIRED**. The URL for the target documentation. Value MUST be in the format of a URL.\n\nThis object MAY be extended with [Specification Extensions](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#specificationExtensions).\n\n##### External Documentation Object Example\n\n\n\\\nJSON\n```json\n{\n "description": "Find more info here",\n "url": "https://example.com"\n}\n```\n\n\n\\\nYAML\n```yaml\ndescription: Find more info here\nurl: https://example.com\n```',
targetSpecs: [
{ namespace: 'openapi', version: '3.0.0' },
{ namespace: 'openapi', version: '3.0.1' },
{ namespace: 'openapi', version: '3.0.2' },
{ namespace: 'openapi', version: '3.0.3' },
],
targetSpecs: OpenAPI30,
},
{
docs: '#### [External Documentation Object](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#external-documentation-object)\n\nAllows referencing an external resource for extended documentation.\n\n##### Fixed Fields\n\nField Name | Type | Description\n---|:---:|---\ndescription | `string` | A description of the target documentation. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.\nurl | `string` | **REQUIRED**. The URL for the target documentation. This MUST be in the form of a URL.\n\n\\\nThis object MAY be extended with [Specification Extensions](https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specificationExtensions).\n\n##### External Documentation Object Example\n\n\n\\\nJSON\n```json\n{\n "description": "Find more info here",\n "url": "https://example.com"\n}\n```\n\n\n\\\nYAML\n```yaml\ndescription: Find more info here\nurl: https://example.com\n```',
targetSpecs: [{ namespace: 'openapi', version: '3.1.0' }],
targetSpecs: OpenAPI31,
},
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI3 } from '../../target-specs';

const allowedFieldsLint: LinterMeta = {
code: ApilintCodes.NOT_ALLOWED_FIELDS,
Expand All @@ -11,6 +12,7 @@ const allowedFieldsLint: LinterMeta = {
linterFunction: 'allowedFields',
linterParams: [['description', 'url'], 'x-'],
marker: 'key',
targetSpecs: OpenAPI3,
};

export default allowedFieldsLint;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI3 } from '../../target-specs';

const descriptionTypeLint: LinterMeta = {
code: ApilintCodes.OPENAPI3_0_EXTERNAL_DOCUMENTATION_FIELD_DESCRIPTION_TYPE,
Expand All @@ -13,6 +14,7 @@ const descriptionTypeLint: LinterMeta = {
marker: 'value',
target: 'description',
data: {},
targetSpecs: OpenAPI3,
};

export default descriptionTypeLint;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI3 } from '../../target-specs';

const urlFormatURILint: LinterMeta = {
code: ApilintCodes.OPENAPI3_0_EXTERNAL_DOCUMENTATION_FIELD_URL_FORMAT_URI,
Expand All @@ -12,6 +13,7 @@ const urlFormatURILint: LinterMeta = {
marker: 'value',
target: 'url',
data: {},
targetSpecs: OpenAPI3,
};

export default urlFormatURILint;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { DiagnosticSeverity } from 'vscode-languageserver-types';

import ApilintCodes from '../../../codes';
import { LinterMeta } from '../../../../apidom-language-types';
import { OpenAPI3 } from '../../target-specs';

const urlRequiredLint: LinterMeta = {
code: ApilintCodes.OPENAPI3_0_EXTERNAL_DOCUMENTATION_FIELD_URL_REQUIRED,
Expand All @@ -21,6 +22,7 @@ const urlRequiredLint: LinterMeta = {
},
],
},
targetSpecs: OpenAPI3,
};

export default urlRequiredLint;
Loading

0 comments on commit d487499

Please sign in to comment.