-
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: port message, operation, correlation-id and security-requirements models #542
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,11 @@ | ||
import type { BaseModel } from "./base"; | ||
import type { DescriptionMixinInterface, ExtensionsMixinInterface } from "./mixins"; | ||
import type { SchemaInterface } from "./schema"; | ||
|
||
export interface ChannelParameterInterface extends BaseModel {} | ||
export interface ChannelParameterInterface extends BaseModel, DescriptionMixinInterface, ExtensionsMixinInterface { | ||
id(): string; | ||
hasSchema(): boolean; | ||
schema(): SchemaInterface | undefined; | ||
hasLocation(): boolean; | ||
location(): string | undefined; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as before, If this should stay, should be added to https://github.com/asyncapi/parser-api/blob/master/docs/v1.md#channelparameter There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The channel parameter has a location so it has to stay 😄 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you mind then creating a PR on Parser-API repo? |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
import type { BaseModel } from "./base"; | ||
import type { ChannelParametersInterface } from "./channel-parameters"; | ||
import type { BindingsMixinInterface, DescriptionMixinInterface, ExtensionsMixinInterface } from "./mixins"; | ||
import type { OperationsInterface } from "./operations"; | ||
import type { ServersInterface } from "./servers"; | ||
|
||
export interface ChannelInterface extends BaseModel {} | ||
export interface ChannelInterface extends BaseModel, BindingsMixinInterface, DescriptionMixinInterface, ExtensionsMixinInterface { | ||
id(): string; | ||
address(): string; | ||
servers(): ServersInterface; | ||
operations(): OperationsInterface; | ||
parameters(): ChannelParametersInterface; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
import type { BaseModel } from "./base"; | ||
import type { DescriptionMixinInterface, ExtensionsMixinInterface } from "./mixins"; | ||
|
||
export interface CorrelationIdInterface extends BaseModel {} | ||
export interface CorrelationIdInterface extends BaseModel, DescriptionMixinInterface, ExtensionsMixinInterface { | ||
hasLocation(): boolean; | ||
location(): string | undefined; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
import type { BaseModel } from "./base"; | ||
import type { ExtensionsMixinInterface } from './mixins'; | ||
|
||
export interface MessageExample extends BaseModel {} | ||
export interface MessageExampleInterface extends BaseModel, ExtensionsMixinInterface { | ||
hasName(): boolean; | ||
name(): string; | ||
hasSummary(): boolean; | ||
summary(): string; | ||
hasHeaders(): boolean; | ||
headers(): Record<string, any> | undefined; | ||
hasPayload(): boolean; | ||
payload(): Record<string, any> | undefined; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import type { Collection } from "./collection"; | ||
import type { MessageExampleInterface } from "./message-example"; | ||
|
||
export interface MessageExamplesInterface extends Collection<MessageExampleInterface> {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,24 @@ | ||
import type { BaseModel } from "./base"; | ||
import type { CorrelationIdInterface } from "./correlation-id"; | ||
import type { MessageExamplesInterface } from "./message-examples"; | ||
import type { BindingsMixinInterface, DescriptionMixinInterface, ExtensionsMixinInterface, ExternalDocumentationMixinInterface, TagsMixinInterface } from './mixins'; | ||
import type { SchemaInterface } from "./schema"; | ||
|
||
export interface MessageTraitInterface extends BaseModel {} | ||
export interface MessageTraitInterface extends BaseModel, BindingsMixinInterface, DescriptionMixinInterface, ExtensionsMixinInterface, ExternalDocumentationMixinInterface, TagsMixinInterface { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There are some missing methods from the Parser-API that I think should be implemented here (otherwise, discarded from the Parser-API).
See https://github.com/asyncapi/parser-api/blob/master/docs/v1.md#message There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I didn't add it on purpose for a simple reason. Defining There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It makes sense indeed. How would you implement that? I think this should be then done in this PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I can add There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, makes sense. I like the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Issue :) #544 |
||
id(): string; | ||
hasMessageId(): boolean; | ||
messageId(): string | undefined; | ||
hasCorrelationId(): boolean; | ||
correlationId(): CorrelationIdInterface | undefined; | ||
hasContentType(): boolean; | ||
contentType(): string | undefined; | ||
hasHeaders(): boolean | ||
headers(): SchemaInterface | undefined; | ||
hasName(): boolean; | ||
name(): string | undefined; | ||
hasTitle(): boolean; | ||
title(): string | undefined; | ||
hasSummary(): boolean; | ||
summary(): string | undefined; | ||
examples(): MessageExamplesInterface; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import type { Collection } from "./collection"; | ||
import type { MessageTraitInterface } from "./message-trait"; | ||
|
||
export interface MessagesTraitsInterface extends Collection<MessageTraitInterface> {} | ||
export interface MessageTraitsInterface extends Collection<MessageTraitInterface> {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,10 @@ | ||
import type { BaseModel } from "./base"; | ||
import type { MessageTraitsInterface } from "./message-traits"; | ||
import type { MessageTraitInterface } from "./message-trait"; | ||
import type { SchemaInterface } from "./schema"; | ||
|
||
export interface MessageInterface extends BaseModel, MessageTraitInterface {} | ||
export interface MessageInterface extends BaseModel, MessageTraitInterface { | ||
hasPayload(): boolean; | ||
payload(): SchemaInterface | undefined; | ||
traits(): MessageTraitsInterface; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import { OAuthFlowInterface } from './oauth-flow'; | ||
import { BaseModel } from './base'; | ||
import {ExtensionsMixinInterface} from './mixins'; | ||
import type { BaseModel } from './base'; | ||
import type { OAuthFlowInterface } from './oauth-flow'; | ||
import type { ExtensionsMixinInterface } from './mixins'; | ||
|
||
export interface OAuthFlowsInterface extends BaseModel, ExtensionsMixinInterface { | ||
hasAuthorizationCode(): boolean; | ||
authorizationCode(): OAuthFlowInterface | undefined; | ||
hasClientCredentials(): boolean | ||
clientCredentials(): OAuthFlowInterface | undefined; | ||
hasImplicit(): boolean; | ||
implicit(): OAuthFlowInterface | undefined; | ||
hasPassword(): boolean; | ||
password(): OAuthFlowInterface | undefined; | ||
} | ||
hasAuthorizationCode(): boolean; | ||
authorizationCode(): OAuthFlowInterface | undefined; | ||
hasClientCredentials(): boolean | ||
clientCredentials(): OAuthFlowInterface | undefined; | ||
hasImplicit(): boolean; | ||
implicit(): OAuthFlowInterface | undefined; | ||
hasPassword(): boolean; | ||
password(): OAuthFlowInterface | undefined; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,14 @@ | ||
import type { BaseModel } from "./base"; | ||
import type { BindingsMixinInterface, DescriptionMixinInterface, ExtensionsMixinInterface, ExternalDocumentationMixinInterface, TagsMixinInterface } from './mixins'; | ||
import type { OperationAction } from "./operation"; | ||
import type { SecuritySchemeInterface } from "./security-scheme"; | ||
|
||
export interface OperationTraitInterface extends BaseModel {} | ||
export interface OperationTraitInterface extends BaseModel, BindingsMixinInterface, DescriptionMixinInterface, ExtensionsMixinInterface, ExternalDocumentationMixinInterface, TagsMixinInterface { | ||
id(): string; | ||
action(): OperationAction; | ||
hasOperationId(): boolean; | ||
operationId(): string | undefined; | ||
hasSummary(): boolean; | ||
summary(): string | undefined; | ||
security(): Array<Record<string, { schema: SecuritySchemeInterface; scopes: string[]; }>>; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import type { Collection } from "./collection"; | ||
import type { OperationTraitInterface } from "./operation-trait"; | ||
|
||
export interface OperationsTraitsInterface extends Collection<OperationTraitInterface> {} | ||
export interface OperationTraitsInterface extends Collection<OperationTraitInterface> {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
import type { BaseModel } from "./base"; | ||
import type { MessagesInterface } from "./messages"; | ||
import type { OperationTraitsInterface } from "./operation-traits"; | ||
import type { OperationTraitInterface } from "./operation-trait"; | ||
|
||
export interface OperationInterface extends BaseModel, OperationTraitInterface {} | ||
export type OperationAction = 'send' | 'receive' | 'publish' | 'subscribe'; | ||
|
||
export interface OperationInterface extends BaseModel, OperationTraitInterface { | ||
messages(): MessagesInterface; | ||
traits(): OperationTraitsInterface; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import type { BaseModel } from "./base"; | ||
import type { ExtensionsMixinInterface } from "./mixins"; | ||
|
||
export interface SchemaInterface extends BaseModel {} | ||
export interface SchemaInterface extends BaseModel, ExtensionsMixinInterface {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,17 @@ | ||
import { BaseModel } from './base'; | ||
import { DescriptionMixinInterface, ExtensionsMixinInterface } from './mixins'; | ||
import { OAuthFlowsInterface } from './oauth-flows'; | ||
import type { BaseModel } from './base'; | ||
import type { OAuthFlowsInterface } from './oauth-flows'; | ||
import type { DescriptionMixinInterface, ExtensionsMixinInterface } from './mixins'; | ||
|
||
export type SecuritySchemaType = 'userPassword' | 'apiKey' | 'X509' | 'symmetricEncryption' | 'asymmetricEncryption' | 'httpApiKey' | 'http' | 'oauth2' | 'openIdConnect' | 'plain' | 'scramSha256' | 'scramSha512' | 'gssapi'; | ||
|
||
|
||
export interface SecuritySchemeInterface extends BaseModel, DescriptionMixinInterface, ExtensionsMixinInterface { | ||
id(): string | ||
hasBearerFormat(): boolean; | ||
bearerFormat(): string | undefined; | ||
openIdConnectUrl(): string; | ||
scheme(): string | undefined; | ||
flows(): OAuthFlowsInterface | undefined; | ||
scopes(): string[]; | ||
type(): SecuritySchemaType; | ||
in(): string | undefined; | ||
} | ||
id(): string | ||
hasBearerFormat(): boolean; | ||
bearerFormat(): string | undefined; | ||
openIdConnectUrl(): string; | ||
scheme(): string | undefined; | ||
flows(): OAuthFlowsInterface | undefined; | ||
scopes(): string[]; | ||
type(): SecuritySchemaType; | ||
in(): string | undefined; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import {Collection} from './collection'; | ||
import { SecuritySchemeInterface } from './security-scheme'; | ||
import type { Collection} from './collection'; | ||
import type { SecuritySchemeInterface } from './security-scheme'; | ||
|
||
export interface SecuritySchemesInterface extends Collection<SecuritySchemeInterface> {} | ||
export interface SecuritySchemesInterface extends Collection<SecuritySchemeInterface> {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
import type { BaseModel } from "./base"; | ||
import type { BindingsMixinInterface, DescriptionMixinInterface, ExtensionsMixinInterface } from './mixins'; | ||
import type { ServerVariablesInterface } from "./server-variables"; | ||
import type { SecuritySchemeInterface } from "./security-scheme"; | ||
|
||
export interface ServerInterface extends BaseModel, DescriptionMixinInterface, BindingsMixinInterface, ExtensionsMixinInterface { | ||
id(): string | ||
url(): string; | ||
protocol(): string | undefined; | ||
protocol(): string; | ||
protocolVersion(): string; | ||
hasProtocolVersion(): boolean; | ||
variables(): ServerVariablesInterface | ||
} | ||
variables(): ServerVariablesInterface; | ||
security(): Array<Record<string, { schema: SecuritySchemeInterface; scopes: string[]; }>>; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { BaseModel } from "../base"; | ||
|
||
import { Mixin } from '../utils'; | ||
import { DescriptionMixin } from './mixins/description'; | ||
import { ExtensionsMixin } from './mixins/extensions'; | ||
|
||
import type { CorrelationIdInterface } from "../correlation-id"; | ||
|
||
export class CorrelationId extends Mixin(BaseModel, DescriptionMixin, ExtensionsMixin) implements CorrelationIdInterface { | ||
hasLocation(): boolean { | ||
return !!this._json.location; | ||
} | ||
|
||
location(): string | undefined { | ||
return this._json.location; | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this should stay, should be added to https://github.com/asyncapi/parser-api/blob/master/docs/v1.md#channelparameter