Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion packages/openapi-model/src/3.0.3/model/BasicNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface TreeParent {
readonly root: OpenAPIModel;
}

export class BasicNode<TParent extends TreeParent>
export abstract class BasicNode<TParent extends TreeParent>
implements TreeNode<TParent>, Disposable, SpecificationExtensionsModel
{
readonly root: OpenAPIModel;
Expand All @@ -25,6 +25,8 @@ export class BasicNode<TParent extends TreeParent>
this.extensions = new Map<string, JSONValue>();
}

abstract children(): IterableIterator<TreeNode<unknown>>;

// eslint-disable-next-line class-methods-use-this
dispose(): void {}

Expand Down
6 changes: 5 additions & 1 deletion packages/openapi-model/src/3.0.3/model/Callback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { BidiMap } from '../../BidiMap';
import { BasicNode } from './BasicNode';
import { PathItem } from './PathItem';

import type { CallbackModel, CallbackModelParent, PathItemModel } from './types';
import type { CallbackModel, CallbackModelParent, PathItemModel, TreeNode } from './types';
import type { ParametrisedURLString } from '@fresha/api-tools-core';

/**
Expand All @@ -19,6 +19,10 @@ export class Callback extends BasicNode<CallbackModelParent> implements Callback
this.paths = new BidiMap<ParametrisedURLString, PathItemModel>();
}

children(): IterableIterator<TreeNode<unknown>> {
return this.paths.values();
}

getItemUrl(pathItem: PathItemModel): string | undefined {
return this.paths.getKey(pathItem);
}
Expand Down
31 changes: 31 additions & 0 deletions packages/openapi-model/src/3.0.3/model/Components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import type {
CreateSchemaOptions,
SchemaModel,
SecuritySchemaModel,
TreeNode,
} from './types';
import type { CommonMarkString } from '@fresha/api-tools-core';

Expand Down Expand Up @@ -59,6 +60,36 @@ export class Components extends BasicNode<ComponentsModelParent> implements Comp
this.callbacks = new Map<string, CallbackModel>();
}

*children(): IterableIterator<TreeNode<unknown>> {
for (const schema of this.schemas.values()) {
yield schema;
}
for (const response of this.responses.values()) {
yield response;
}
for (const parameter of this.parameters.values()) {
yield parameter;
}
for (const example of this.examples.values()) {
yield example;
}
for (const requestBody of this.requestBodies.values()) {
yield requestBody;
}
for (const header of this.headers.values()) {
yield header;
}
for (const securitySchema of this.securitySchemes.values()) {
yield securitySchema;
}
for (const link of this.links.values()) {
yield link;
}
for (const callback of this.callbacks.values()) {
yield callback;
}
}

isEmpty(): boolean {
return (
!this.schemas.size &&
Expand Down
6 changes: 5 additions & 1 deletion packages/openapi-model/src/3.0.3/model/Contact.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BasicNode } from './BasicNode';

import type { ContactModel, ContactModelParent } from './types';
import type { ContactModel, ContactModelParent, TreeNode } from './types';
import type { Nullable, URLString, EmailString } from '@fresha/api-tools-core';

/**
Expand All @@ -17,4 +17,8 @@ export class Contact extends BasicNode<ContactModelParent> implements ContactMod
this.url = null;
this.email = null;
}

// eslint-disable-next-line class-methods-use-this
*children(): IterableIterator<TreeNode<unknown>> {
}
}
6 changes: 5 additions & 1 deletion packages/openapi-model/src/3.0.3/model/Discriminator.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BasicNode } from './BasicNode';

import type { DiscriminatorModel, DiscriminatorModelParent } from './types';
import type { DiscriminatorModel, DiscriminatorModelParent, TreeNode } from './types';

/**
* @see http://spec.openapis.org/oas/v3.0.3#discriminator-object
Expand All @@ -17,4 +17,8 @@ export class Discriminator
this.propertyName = propertyName;
this.mapping = new Map<string, string>();
}

// eslint-disable-next-line class-methods-use-this
*children(): IterableIterator<TreeNode<unknown>> {
}
}
5 changes: 5 additions & 0 deletions packages/openapi-model/src/3.0.3/model/Encoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
EncodingModelParent,
EncodingSerializationStyle,
HeaderModel,
TreeNode,
} from './types';
import type { Nullable } from '@fresha/api-tools-core';

Expand All @@ -30,6 +31,10 @@ export class Encoding extends BasicNode<EncodingModelParent> implements Encoding
this.allowReserved = false;
}

children(): IterableIterator<TreeNode<unknown>> {
return this.headers.values();
}

getHeader(name: string): HeaderModel | undefined {
return this.headers.get(name);
}
Expand Down
7 changes: 6 additions & 1 deletion packages/openapi-model/src/3.0.3/model/Example.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BasicNode } from './BasicNode';

import type { ExampleModel, ExampleModelParent } from './types';
import type { ExampleModel, ExampleModelParent, TreeNode } from './types';
import type { Nullable, URLString, JSONValue } from '@fresha/api-tools-core';

/**
Expand All @@ -19,4 +19,9 @@ export class Example extends BasicNode<ExampleModelParent> implements ExampleMod
this.value = null;
this.externalValue = null;
}


// eslint-disable-next-line class-methods-use-this
*children(): IterableIterator<TreeNode<unknown>> {
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BasicNode } from './BasicNode';

import type { ExternalDocumentationModel, ExternalDocumentationModelParent } from './types';
import type { ExternalDocumentationModel, ExternalDocumentationModelParent, TreeNode } from './types';
import type { CommonMarkString, Nullable, URLString } from '@fresha/api-tools-core';

/**
Expand All @@ -18,4 +18,8 @@ export class ExternalDocumentation
this.url = url;
this.description = null;
}

// eslint-disable-next-line class-methods-use-this
*children(): IterableIterator<TreeNode<unknown>> {
}
}
13 changes: 13 additions & 0 deletions packages/openapi-model/src/3.0.3/model/Header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type {
HeaderParameterSerializationStyle,
MediaTypeModel,
SchemaModel,
TreeNode,
} from './types';
import type { Nullable, JSONValue, MIMETypeString, CommonMarkString } from '@fresha/api-tools-core';

Expand Down Expand Up @@ -41,6 +42,18 @@ export class Header extends BasicNode<HeaderModelParent> implements HeaderModel
this.content = new Map<MIMETypeString, MediaTypeModel>();
}

*children(): IterableIterator<TreeNode<unknown>> {
if (this.schema) {
yield this.schema;
}
for (const example of this.examples.values()) {
yield example;
}
for (const mediaType of this.content.values()) {
yield mediaType;
}
}

getExample(name: string): ExampleModel | undefined {
return this.examples.get(name);
}
Expand Down
7 changes: 6 additions & 1 deletion packages/openapi-model/src/3.0.3/model/Info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BasicNode } from './BasicNode';
import { Contact } from './Contact';
import { License } from './License';

import type { InfoModel, InfoModelParent } from './types';
import type { InfoModel, InfoModelParent, TreeNode } from './types';
import type { CommonMarkString, Nullable, URLString, VersionString } from '@fresha/api-tools-core';

/**
Expand All @@ -25,4 +25,9 @@ export class Info extends BasicNode<InfoModelParent> implements InfoModel {
this.license = new License(this, 'UNLICENSED');
this.version = version;
}

*children(): IterableIterator<TreeNode<unknown>> {
yield this.contact;
yield this.license;
}
}
5 changes: 4 additions & 1 deletion packages/openapi-model/src/3.0.3/model/License.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BasicNode } from './BasicNode';

import type { LicenseModel, LicenseModelParent } from './types';
import type { LicenseModel, LicenseModelParent, TreeNode } from './types';
import type { Nullable } from '@fresha/api-tools-core';

/**
Expand All @@ -15,4 +15,7 @@ export class License extends BasicNode<LicenseModelParent> implements LicenseMod
this.name = name;
this.url = null;
}

*children(): IterableIterator<TreeNode<unknown>> {
}
}
5 changes: 4 additions & 1 deletion packages/openapi-model/src/3.0.3/model/Link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import assert from 'assert';
import { BasicNode } from './BasicNode';

import type { Server } from './Server';
import type { LinkModel, LinkModelParent } from './types';
import type { LinkModel, LinkModelParent, TreeNode } from './types';
import type { Nullable, JSONValue } from '@fresha/api-tools-core';

/**
Expand All @@ -27,6 +27,9 @@ export class Link extends BasicNode<LinkModelParent> implements LinkModel {
this.server = null;
}

*children(): IterableIterator<TreeNode<unknown>> {
}

getParameter(key: string): JSONValue | undefined {
return this.parameters.get(key);
}
Expand Down
13 changes: 13 additions & 0 deletions packages/openapi-model/src/3.0.3/model/MediaType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import type {
MediaTypeModelParent,
CreateOrSetSchemaOptions,
SchemaModel,
TreeNode,
} from './types';
import type { Nullable, JSONValue } from '@fresha/api-tools-core';

Expand All @@ -32,6 +33,18 @@ export class MediaType extends BasicNode<MediaTypeModelParent> implements MediaT
this.encoding = new Map<string, EncodingModel>();
}

*children(): IterableIterator<TreeNode<unknown>> {
if (this.schema) {
yield this.schema;
}
for (const example of this.examples.values()) {
yield example;
}
for (const encoding of this.encoding.values()) {
yield encoding;
}
}

setSchema(options: CreateOrSetSchemaOptions): SchemaModel {
const result = SchemaFactory.createOrGet(this, options);
this.schema = result;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { OAuthFlowBase } from './OAuthFlowBase';

import type { OAuthAuthorizationCodeFlowModel, OAuthFlowModelParent } from '../types';
import type { OAuthAuthorizationCodeFlowModel, OAuthFlowModelParent, TreeNode } from '../types';
import type { URLString } from '@fresha/api-tools-core';

/**
Expand All @@ -19,4 +19,9 @@ export class OAuthAuthorisationCodeFlow
this.authorizationUrl = authorizationUrl;
this.tokenUrl = tokenUrl;
}

// eslint-disable-next-line class-methods-use-this
*children(): IterableIterator<TreeNode<unknown>> {

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { OAuthFlowBase } from './OAuthFlowBase';

import type { OAuthClientCredentialsFlowModel, OAuthFlowModelParent } from '../types';
import type { OAuthClientCredentialsFlowModel, OAuthFlowModelParent, TreeNode } from '../types';
import type { URLString } from '@fresha/api-tools-core';

/**
Expand All @@ -17,4 +17,9 @@ export class OAuthClientCredentialsFlow
super(parent, 'clientCredentials');
this.tokenUrl = tokenUrl;
}

// eslint-disable-next-line class-methods-use-this
*children(): IterableIterator<TreeNode<unknown>> {

}
}
16 changes: 16 additions & 0 deletions packages/openapi-model/src/3.0.3/model/OAuthFlow/OAuthFlows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
OAuthFlowsModelParent,
OAuthImplicitFlowModel,
OAuthPasswordFlowModel,
TreeNode,
} from '../types';
import type { Nullable } from '@fresha/api-tools-core';

Expand All @@ -26,4 +27,19 @@ export class OAuthFlows extends BasicNode<OAuthFlowsModelParent> implements OAut
this.clientCredentials = null;
this.authorizationCode = null;
}

*children(): IterableIterator<TreeNode<unknown>> {
if (this.implicit) {
yield this.implicit;
}
if (this.password) {
yield this.password;
}
if (this.clientCredentials) {
yield this.clientCredentials;
}
if (this.authorizationCode) {
yield this.authorizationCode;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { OAuthFlowBase } from './OAuthFlowBase';

import type { OAuthFlowModelParent, OAuthImplicitFlowModel } from '../types';
import type { OAuthFlowModelParent, OAuthImplicitFlowModel, TreeNode } from '../types';
import type { URLString } from '@fresha/api-tools-core';

/**
Expand All @@ -14,4 +14,9 @@ export class OAuthImplicitFlow extends OAuthFlowBase implements OAuthImplicitFlo
super(parent, 'implicit');
this.authorizationUrl = authorizationUrl;
}

// eslint-disable-next-line class-methods-use-this
*children(): IterableIterator<TreeNode<unknown>> {

}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { OAuthFlowBase } from './OAuthFlowBase';

import type { OAuthFlowModelParent, OAuthPasswordFlowModel } from '../types';
import type { OAuthFlowModelParent, OAuthPasswordFlowModel, TreeNode } from '../types';
import type { URLString } from '@fresha/api-tools-core';

/**
Expand All @@ -14,4 +14,9 @@ export class OAuthPasswordFlow extends OAuthFlowBase implements OAuthPasswordFlo
super(parent, 'password');
this.tokenUrl = tokenUrl;
}

// eslint-disable-next-line class-methods-use-this
*children(): IterableIterator<TreeNode<unknown>> {

}
}
Loading