Skip to content

feat(comment): Use the defined comment #19

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

Merged
merged 1 commit into from
Feb 18, 2021
Merged
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
1 change: 0 additions & 1 deletion src/Converter/v3/components/Header.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ export const generateInterface = (
return factory.InterfaceDeclaration.create({
export: true,
name: converterContext.escapeDeclarationText(name),
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#headerObject`,
members: generatePropertySignatures(entryPoint, currentPoint, factory, headers, context, converterContext),
});
};
1 change: 0 additions & 1 deletion src/Converter/v3/components/Headers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export const generateNamespace = (
store.addComponent("headers", {
kind: "namespace",
name: Name.Components.Headers,
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#componentsObject`,
});
Object.entries(headers).forEach(([name, header]) => {
if (Guard.isReference(header)) {
Expand Down
2 changes: 1 addition & 1 deletion src/Converter/v3/components/MediaType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const generatePropertySignature = (
name: converterContext.escapePropertySignatureName(protocol),
optional: false,
type: ToTypeNode.convert(entryPoint, currentPoint, factory, schema, context, converterContext),
comment: schema.description,
});
};

Expand Down Expand Up @@ -50,6 +51,5 @@ export const generateInterface = (
export: true,
name,
members: generatePropertySignatures(entryPoint, currentPoint, factory, content, context, converterContext),
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#mediaTypeObject`,
});
};
5 changes: 3 additions & 2 deletions src/Converter/v3/components/Parameter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const generatePropertySignature = (
return factory.PropertySignature.create({
name: converterContext.escapePropertySignatureName(localRef.name),
optional: false,
comment: localRef.description,
type: factory.TypeReferenceNode.create({
name: context.resolveReferencePath(currentPoint, reference.path).name,
}),
Expand All @@ -62,6 +63,7 @@ export const generatePropertySignature = (
return factory.PropertySignature.create({
name: converterContext.escapePropertySignatureName(reference.data.name),
optional: isPathProperty ? false : !reference.data.required,
comment: reference.data.description,
type: ToTypeNode.convert(
entryPoint,
reference.referencePoint,
Expand All @@ -77,6 +79,7 @@ export const generatePropertySignature = (
name: converterContext.escapePropertySignatureName(parameter.name),
optional: isPathProperty ? false : !parameter.required,
type: ToTypeNode.convert(entryPoint, currentPoint, factory, parameter.schema || { type: "null" }, context, converterContext),
comment: parameter.description,
});
};

Expand Down Expand Up @@ -107,7 +110,6 @@ export const generateInterface = (
return factory.InterfaceDeclaration.create({
export: true,
name,
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#headerObject`,
members: generatePropertySignatures(entryPoint, currentPoint, store, factory, parameters, context, converterContext),
});
};
Expand All @@ -128,7 +130,6 @@ export const generateAliasInterface = (
return factory.InterfaceDeclaration.create({
export: true,
name: converterContext.escapeDeclarationText(name),
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#headerObject`,
members: generatePropertySignatures(entryPoint, currentPoint, store, factory, parameters, context, converterContext),
});
};
2 changes: 0 additions & 2 deletions src/Converter/v3/components/Parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export const generateNamespace = (
store.addComponent("parameters", {
kind: "namespace",
name: Name.Components.Parameters,
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#parameterObject`,
});

Object.entries(parameters).forEach(([name, parameter]) => {
Expand Down Expand Up @@ -81,7 +80,6 @@ export const generateNamespaceWithList = (
store.addComponent("parameters", {
kind: "namespace",
name: Name.Components.Parameters,
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#parameterObject`,
});

parameters.forEach(parameter => {
Expand Down
1 change: 0 additions & 1 deletion src/Converter/v3/components/PathItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export const generateNamespace = (
store.addComponent("pathItems", {
kind: "namespace",
name: Name.Components.PathItems,
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#componentsObject`,
});

Object.entries(pathItems).forEach(([key, pathItem]) => {
Expand Down
1 change: 0 additions & 1 deletion src/Converter/v3/components/RequestBodies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export const generateNamespace = (
store.addComponent("requestBodies", {
kind: "namespace",
name: Name.Components.RequestBodies,
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#componentsObject`,
});

Object.entries(requestBodies).forEach(([name, requestBody]) => {
Expand Down
1 change: 0 additions & 1 deletion src/Converter/v3/components/RequestBody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export const generateInterface = (
export: true,
name,
members: contentSignatures,
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#requestBodyObject`,
});
};

Expand Down
2 changes: 0 additions & 2 deletions src/Converter/v3/components/Responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export const generateNamespace = (
store.addComponent("responses", {
kind: "namespace",
name: Name.Components.Responses,
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#responsesObject`,
});
Object.entries(responses).forEach(([name, response]) => {
if (Guard.isReference(response)) {
Expand Down Expand Up @@ -69,7 +68,6 @@ export const generateNamespaceWithStatusCode = (
store.addStatement(basePath, {
kind: "namespace",
name: Name.ComponentChild.Response,
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#responsesObject`,
});

Object.entries(responses).forEach(([statusCode, response]) => {
Expand Down
1 change: 1 addition & 0 deletions src/Converter/v3/components/Schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const generatePropertySignatures = (
return factory.PropertySignature.create({
name: convertContext.escapePropertySignatureName(propertyName),
optional: !required.includes(propertyName),
comment: schema.description,
type: factory.TypeNode.create({
type: "any",
}),
Expand Down
1 change: 0 additions & 1 deletion src/Converter/v3/components/Schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export const generateNamespace = (
store.addComponent("schemas", {
kind: "namespace",
name: Name.Components.Schemas,
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#schemaObject`,
});
Object.entries(schemas).forEach(([name, targetSchema]) => {
if (Guard.isReference(targetSchema)) {
Expand Down
1 change: 0 additions & 1 deletion src/Converter/v3/components/SecuritySchemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const generateNamespace = (
store.addComponent("securitySchemes", {
kind: "namespace",
name: Name.Components.SecuritySchemas,
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#securitySchemeObject`,
});
Object.entries(requestBodies).forEach(([name, requestBody]) => {
if (Guard.isReference(requestBody)) {
Expand Down
34 changes: 6 additions & 28 deletions test/__tests__/__snapshots__/snapshot-test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ exports[`Generate Code Snapshot Test api.test.domain 1`] = `
//


/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#schemaObject */
export namespace Schemas {
/** String Literal */
export type StringType = string;
Expand Down Expand Up @@ -128,7 +127,6 @@ export namespace Schemas {
children: Child[];
}
}
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#componentsObject */
export namespace Headers {
export type StringHeader = string;
export type A = number;
Expand All @@ -137,7 +135,6 @@ export namespace Headers {
}
export type ReferenceOfHeaderToSchema = Schemas.DirectRef.ForHeader;
}
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#responsesObject */
export namespace Responses {
/**
* Status Code 100
Expand All @@ -151,43 +148,38 @@ export namespace Responses {
export namespace SwitchingProtocol { }
/** Type Reference - string */
export namespace LocalReferenceStringDateTimeType {
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#mediaTypeObject */
export interface Content {
\\"application/json\\": Schemas.StringDateTimeType;
}
}
/** Local Reference - object */
export namespace LocalReferenceObjectType {
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#mediaTypeObject */
export interface Content {
\\"application/json\\": Schemas.ObjectHasPropertiesType;
}
}
/** Response -> Schema */
export namespace ReferenceOfResponseToSchema {
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#mediaTypeObject */
export interface Content {
\\"application/json\\": Schemas.DirectRef.ForResponse;
}
}
/** response A definition */
export namespace ResponseA {
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#headerObject */
export interface Header {
HeaderA: Headers.A;
HeaderB: string;
}
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#mediaTypeObject */
export interface Content {
\\"application/json\\": {
/** responseA description */
name?: \\"responseA\\";
};
}
}
export namespace Level1 {
/** response B definition */
export namespace ResponseB {
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#mediaTypeObject */
export interface Content {
\\"application/json\\": {
name?: \\"responseB\\";
Expand All @@ -197,7 +189,6 @@ export namespace Responses {
export namespace Level2 {
/** response C definition */
export namespace ResponseC {
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#mediaTypeObject */
export interface Content {
\\"application/json\\": {
name?: \\"responseC\\";
Expand All @@ -209,21 +200,19 @@ export namespace Responses {
export namespace ForPathItems {
/** response A definition */
export namespace FullRemoteReference {
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#headerObject */
export interface Header {
HeaderA: Headers.A;
HeaderB: string;
}
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#mediaTypeObject */
export interface Content {
\\"application/json\\": {
/** responseA description */
name?: \\"responseA\\";
};
}
}
}
}
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#parameterObject */
export namespace Parameters {
/** parameters.StringQueryParams */
export type StringQueryParams = string;
Expand All @@ -250,32 +239,27 @@ export namespace Parameters {
};
};
}
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#componentsObject */
export namespace RequestBodies {
/** Request body string type */
export namespace StringType {
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#requestBodyObject */
export interface Content {
\\"application/json\\": string;
}
}
/** Request body Local reference string type */
export namespace LocalReferenceStringType {
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#requestBodyObject */
export interface Content {
\\"application/json\\": Schemas.StringHasEnumType;
}
}
/** requestBodies -> schemas */
export namespace ReferenceOfRequestBodyToSchema {
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#requestBodyObject */
export interface Content {
\\"application/json\\": Schemas.DirectRef.ForRequestBody;
}
}
/** Remote Request body A */
export namespace RequestBodyA {
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#requestBodyObject */
export interface Content {
\\"application/json\\": {
body?: string;
Expand All @@ -285,7 +269,6 @@ export namespace RequestBodies {
export namespace Level1 {
/** Remote Request body B */
export namespace RequestBodyB {
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#requestBodyObject */
export interface Content {
\\"application/json\\": {
body?: string;
Expand All @@ -295,7 +278,6 @@ export namespace RequestBodies {
export namespace Level2 {
/** Remote Request body C */
export namespace RequestBodyC {
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#requestBodyObject */
export interface Content {
\\"application/json\\": {
body?: string;
Expand All @@ -305,35 +287,32 @@ export namespace RequestBodies {
}
}
}
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#headerObject */
export interface Parameter$getIncludeLocalReference {
/** parameters.StringQueryParams */
StringQuery: string;
}
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#mediaTypeObject */
export interface Response$getIncludeLocalReference$Status$200 {
\\"application/json\\": {
meta: string;
};
}
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#headerObject */
export interface Parameter$getIncludeRemoteReference {
/** remote reference parameter */
IncludeRemoteReference: number;
}
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#requestBodyObject */
export interface RequestBody$getIncludeRemoteReference {
\\"application/json\\": string;
}
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#headerObject */
export interface Parameter$getFullRemoteReference {
/** Full Remote Reference */
FullRemoteReferenceQuery: Schemas.FullRemoteReference.ForParameters;
}
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#mediaTypeObject */
export interface Response$getFullRemoteReference$Status$200 {
\\"application/json\\": {
/** responseA description */
name?: \\"responseA\\";
};
}
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#mediaTypeObject */
export interface Response$getReferenceItems$Status$200 {
\\"application/json\\": {
books?: Schemas.Item[];
Expand Down Expand Up @@ -422,7 +401,6 @@ exports[`Generate Code Snapshot Test infer.domain 1`] = `
//


/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#schemaObject */
export namespace Schemas {
export type InferArrayEmptyItems = {}[];
export type InferArrayType = string[];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: FullRemoteReferenceQuery
in: query
description: Full Remote REference
description: Full Remote Reference
required: true
schema:
$ref: "../../schemas/FullRemoteReference/ForParameters.yml"
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ content:
name:
type: string
enum: [responseA]
description: responseA description
1 change: 1 addition & 0 deletions test/api.test.domain/components/responses/ResponseA.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ content:
name:
type: string
enum: [responseA]
description: responseA description