Skip to content

Commit d3f64ad

Browse files
committed
feat(comment): Use the defined comment
1 parent 17aa008 commit d3f64ad

File tree

16 files changed

+14
-43
lines changed

16 files changed

+14
-43
lines changed

src/Converter/v3/components/Header.ts

-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ export const generateInterface = (
8484
return factory.InterfaceDeclaration.create({
8585
export: true,
8686
name: converterContext.escapeDeclarationText(name),
87-
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#headerObject`,
8887
members: generatePropertySignatures(entryPoint, currentPoint, factory, headers, context, converterContext),
8988
});
9089
};

src/Converter/v3/components/Headers.ts

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export const generateNamespace = (
2222
store.addComponent("headers", {
2323
kind: "namespace",
2424
name: Name.Components.Headers,
25-
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#componentsObject`,
2625
});
2726
Object.entries(headers).forEach(([name, header]) => {
2827
if (Guard.isReference(header)) {

src/Converter/v3/components/MediaType.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const generatePropertySignature = (
1818
name: converterContext.escapePropertySignatureName(protocol),
1919
optional: false,
2020
type: ToTypeNode.convert(entryPoint, currentPoint, factory, schema, context, converterContext),
21+
comment: schema.description,
2122
});
2223
};
2324

@@ -50,6 +51,5 @@ export const generateInterface = (
5051
export: true,
5152
name,
5253
members: generatePropertySignatures(entryPoint, currentPoint, factory, content, context, converterContext),
53-
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#mediaTypeObject`,
5454
});
5555
};

src/Converter/v3/components/Parameter.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export const generatePropertySignature = (
5353
return factory.PropertySignature.create({
5454
name: converterContext.escapePropertySignatureName(localRef.name),
5555
optional: false,
56+
comment: localRef.description,
5657
type: factory.TypeReferenceNode.create({
5758
name: context.resolveReferencePath(currentPoint, reference.path).name,
5859
}),
@@ -62,6 +63,7 @@ export const generatePropertySignature = (
6263
return factory.PropertySignature.create({
6364
name: converterContext.escapePropertySignatureName(reference.data.name),
6465
optional: isPathProperty ? false : !reference.data.required,
66+
comment: reference.data.description,
6567
type: ToTypeNode.convert(
6668
entryPoint,
6769
reference.referencePoint,
@@ -77,6 +79,7 @@ export const generatePropertySignature = (
7779
name: converterContext.escapePropertySignatureName(parameter.name),
7880
optional: isPathProperty ? false : !parameter.required,
7981
type: ToTypeNode.convert(entryPoint, currentPoint, factory, parameter.schema || { type: "null" }, context, converterContext),
82+
comment: parameter.description,
8083
});
8184
};
8285

@@ -107,7 +110,6 @@ export const generateInterface = (
107110
return factory.InterfaceDeclaration.create({
108111
export: true,
109112
name,
110-
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#headerObject`,
111113
members: generatePropertySignatures(entryPoint, currentPoint, store, factory, parameters, context, converterContext),
112114
});
113115
};
@@ -128,7 +130,6 @@ export const generateAliasInterface = (
128130
return factory.InterfaceDeclaration.create({
129131
export: true,
130132
name: converterContext.escapeDeclarationText(name),
131-
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#headerObject`,
132133
members: generatePropertySignatures(entryPoint, currentPoint, store, factory, parameters, context, converterContext),
133134
});
134135
};

src/Converter/v3/components/Parameters.ts

-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export const generateNamespace = (
2323
store.addComponent("parameters", {
2424
kind: "namespace",
2525
name: Name.Components.Parameters,
26-
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#parameterObject`,
2726
});
2827

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

8785
parameters.forEach(parameter => {

src/Converter/v3/components/PathItems.ts

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ export const generateNamespace = (
2424
store.addComponent("pathItems", {
2525
kind: "namespace",
2626
name: Name.Components.PathItems,
27-
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#componentsObject`,
2827
});
2928

3029
Object.entries(pathItems).forEach(([key, pathItem]) => {

src/Converter/v3/components/RequestBodies.ts

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export const generateNamespace = (
2323
store.addComponent("requestBodies", {
2424
kind: "namespace",
2525
name: Name.Components.RequestBodies,
26-
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#componentsObject`,
2726
});
2827

2928
Object.entries(requestBodies).forEach(([name, requestBody]) => {

src/Converter/v3/components/RequestBody.ts

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export const generateInterface = (
2828
export: true,
2929
name,
3030
members: contentSignatures,
31-
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#requestBodyObject`,
3231
});
3332
};
3433

src/Converter/v3/components/Responses.ts

-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export const generateNamespace = (
2727
store.addComponent("responses", {
2828
kind: "namespace",
2929
name: Name.Components.Responses,
30-
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#responsesObject`,
3130
});
3231
Object.entries(responses).forEach(([name, response]) => {
3332
if (Guard.isReference(response)) {
@@ -69,7 +68,6 @@ export const generateNamespaceWithStatusCode = (
6968
store.addStatement(basePath, {
7069
kind: "namespace",
7170
name: Name.ComponentChild.Response,
72-
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#responsesObject`,
7371
});
7472

7573
Object.entries(responses).forEach(([statusCode, response]) => {

src/Converter/v3/components/Schema.ts

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export const generatePropertySignatures = (
2626
return factory.PropertySignature.create({
2727
name: convertContext.escapePropertySignatureName(propertyName),
2828
optional: !required.includes(propertyName),
29+
comment: schema.description,
2930
type: factory.TypeNode.create({
3031
type: "any",
3132
}),

src/Converter/v3/components/Schemas.ts

-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ export const generateNamespace = (
3939
store.addComponent("schemas", {
4040
kind: "namespace",
4141
name: Name.Components.Schemas,
42-
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#schemaObject`,
4342
});
4443
Object.entries(schemas).forEach(([name, targetSchema]) => {
4544
if (Guard.isReference(targetSchema)) {

src/Converter/v3/components/SecuritySchemas.ts

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export const generateNamespace = (
1717
store.addComponent("securitySchemes", {
1818
kind: "namespace",
1919
name: Name.Components.SecuritySchemas,
20-
comment: `@see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#securitySchemeObject`,
2120
});
2221
Object.entries(requestBodies).forEach(([name, requestBody]) => {
2322
if (Guard.isReference(requestBody)) {

test/__tests__/__snapshots__/snapshot-test.ts.snap

+6-28
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ exports[`Generate Code Snapshot Test api.test.domain 1`] = `
1010
//
1111
1212
13-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#schemaObject */
1413
export namespace Schemas {
1514
/** String Literal */
1615
export type StringType = string;
@@ -128,7 +127,6 @@ export namespace Schemas {
128127
children: Child[];
129128
}
130129
}
131-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#componentsObject */
132130
export namespace Headers {
133131
export type StringHeader = string;
134132
export type A = number;
@@ -137,7 +135,6 @@ export namespace Headers {
137135
}
138136
export type ReferenceOfHeaderToSchema = Schemas.DirectRef.ForHeader;
139137
}
140-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#responsesObject */
141138
export namespace Responses {
142139
/**
143140
* Status Code 100
@@ -151,43 +148,38 @@ export namespace Responses {
151148
export namespace SwitchingProtocol { }
152149
/** Type Reference - string */
153150
export namespace LocalReferenceStringDateTimeType {
154-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#mediaTypeObject */
155151
export interface Content {
156152
\\"application/json\\": Schemas.StringDateTimeType;
157153
}
158154
}
159155
/** Local Reference - object */
160156
export namespace LocalReferenceObjectType {
161-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#mediaTypeObject */
162157
export interface Content {
163158
\\"application/json\\": Schemas.ObjectHasPropertiesType;
164159
}
165160
}
166161
/** Response -> Schema */
167162
export namespace ReferenceOfResponseToSchema {
168-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#mediaTypeObject */
169163
export interface Content {
170164
\\"application/json\\": Schemas.DirectRef.ForResponse;
171165
}
172166
}
173167
/** response A definition */
174168
export namespace ResponseA {
175-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#headerObject */
176169
export interface Header {
177170
HeaderA: Headers.A;
178171
HeaderB: string;
179172
}
180-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#mediaTypeObject */
181173
export interface Content {
182174
\\"application/json\\": {
175+
/** responseA description */
183176
name?: \\"responseA\\";
184177
};
185178
}
186179
}
187180
export namespace Level1 {
188181
/** response B definition */
189182
export namespace ResponseB {
190-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#mediaTypeObject */
191183
export interface Content {
192184
\\"application/json\\": {
193185
name?: \\"responseB\\";
@@ -197,7 +189,6 @@ export namespace Responses {
197189
export namespace Level2 {
198190
/** response C definition */
199191
export namespace ResponseC {
200-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#mediaTypeObject */
201192
export interface Content {
202193
\\"application/json\\": {
203194
name?: \\"responseC\\";
@@ -209,21 +200,19 @@ export namespace Responses {
209200
export namespace ForPathItems {
210201
/** response A definition */
211202
export namespace FullRemoteReference {
212-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#headerObject */
213203
export interface Header {
214204
HeaderA: Headers.A;
215205
HeaderB: string;
216206
}
217-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#mediaTypeObject */
218207
export interface Content {
219208
\\"application/json\\": {
209+
/** responseA description */
220210
name?: \\"responseA\\";
221211
};
222212
}
223213
}
224214
}
225215
}
226-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#parameterObject */
227216
export namespace Parameters {
228217
/** parameters.StringQueryParams */
229218
export type StringQueryParams = string;
@@ -250,32 +239,27 @@ export namespace Parameters {
250239
};
251240
};
252241
}
253-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#componentsObject */
254242
export namespace RequestBodies {
255243
/** Request body string type */
256244
export namespace StringType {
257-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#requestBodyObject */
258245
export interface Content {
259246
\\"application/json\\": string;
260247
}
261248
}
262249
/** Request body Local reference string type */
263250
export namespace LocalReferenceStringType {
264-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#requestBodyObject */
265251
export interface Content {
266252
\\"application/json\\": Schemas.StringHasEnumType;
267253
}
268254
}
269255
/** requestBodies -> schemas */
270256
export namespace ReferenceOfRequestBodyToSchema {
271-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#requestBodyObject */
272257
export interface Content {
273258
\\"application/json\\": Schemas.DirectRef.ForRequestBody;
274259
}
275260
}
276261
/** Remote Request body A */
277262
export namespace RequestBodyA {
278-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#requestBodyObject */
279263
export interface Content {
280264
\\"application/json\\": {
281265
body?: string;
@@ -285,7 +269,6 @@ export namespace RequestBodies {
285269
export namespace Level1 {
286270
/** Remote Request body B */
287271
export namespace RequestBodyB {
288-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#requestBodyObject */
289272
export interface Content {
290273
\\"application/json\\": {
291274
body?: string;
@@ -295,7 +278,6 @@ export namespace RequestBodies {
295278
export namespace Level2 {
296279
/** Remote Request body C */
297280
export namespace RequestBodyC {
298-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#requestBodyObject */
299281
export interface Content {
300282
\\"application/json\\": {
301283
body?: string;
@@ -305,35 +287,32 @@ export namespace RequestBodies {
305287
}
306288
}
307289
}
308-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#headerObject */
309290
export interface Parameter$getIncludeLocalReference {
291+
/** parameters.StringQueryParams */
310292
StringQuery: string;
311293
}
312-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#mediaTypeObject */
313294
export interface Response$getIncludeLocalReference$Status$200 {
314295
\\"application/json\\": {
315296
meta: string;
316297
};
317298
}
318-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#headerObject */
319299
export interface Parameter$getIncludeRemoteReference {
300+
/** remote reference parameter */
320301
IncludeRemoteReference: number;
321302
}
322-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#requestBodyObject */
323303
export interface RequestBody$getIncludeRemoteReference {
324304
\\"application/json\\": string;
325305
}
326-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#headerObject */
327306
export interface Parameter$getFullRemoteReference {
307+
/** Full Remote Reference */
328308
FullRemoteReferenceQuery: Schemas.FullRemoteReference.ForParameters;
329309
}
330-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#mediaTypeObject */
331310
export interface Response$getFullRemoteReference$Status$200 {
332311
\\"application/json\\": {
312+
/** responseA description */
333313
name?: \\"responseA\\";
334314
};
335315
}
336-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#mediaTypeObject */
337316
export interface Response$getReferenceItems$Status$200 {
338317
\\"application/json\\": {
339318
books?: Schemas.Item[];
@@ -422,7 +401,6 @@ exports[`Generate Code Snapshot Test infer.domain 1`] = `
422401
//
423402
424403
425-
/** @see https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#schemaObject */
426404
export namespace Schemas {
427405
export type InferArrayEmptyItems = {}[];
428406
export type InferArrayType = string[];
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: FullRemoteReferenceQuery
22
in: query
3-
description: Full Remote REference
3+
description: Full Remote Reference
44
required: true
55
schema:
66
$ref: "../../schemas/FullRemoteReference/ForParameters.yml"

test/api.test.domain/components/responses/ForPathItems/FullRemoteReference.yml

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ content:
1414
name:
1515
type: string
1616
enum: [responseA]
17+
description: responseA description

test/api.test.domain/components/responses/ResponseA.yml

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@ content:
1414
name:
1515
type: string
1616
enum: [responseA]
17+
description: responseA description

0 commit comments

Comments
 (0)