[typescript-fetch] Allow multiline documentation (#6088)

Add a lambda that formats the documentation correctly even if it
contains newlines. The generated docs with typedoc looks a lot better
and also renders Markdown correctly.

Also remove the "no description" fallback for APIs because we don't have
it anywhere else, other generators don't generate a default fallback and
I'd rather have no documentation than a "no description" string.
This commit is contained in:
Harald Fernengel 2020-04-28 16:20:26 +02:00 committed by GitHub
parent f12fb86a1a
commit 500fb472b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 43 additions and 29 deletions

View File

@ -17,11 +17,14 @@
package org.openapitools.codegen.languages;
import com.google.common.collect.ImmutableMap;
import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.media.ArraySchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.openapitools.codegen.*;
import org.openapitools.codegen.meta.features.DocumentationFeature;
import org.openapitools.codegen.templating.mustache.IndentedLambda;
import org.openapitools.codegen.utils.ModelUtils;
import java.io.File;
@ -134,6 +137,14 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
}
}
@Override
protected ImmutableMap.Builder<String, Mustache.Lambda> addMustacheLambdas() {
ImmutableMap.Builder<String, Mustache.Lambda> lambdas = super.addMustacheLambdas();
lambdas.put("indented_star_1", new IndentedLambda(1, " ", "* "));
lambdas.put("indented_star_4", new IndentedLambda(5, " ", "* "));
return lambdas;
}
@Override
public String getTypeDeclaration(Schema p) {
if (ModelUtils.isFileSchema(p)) {

View File

@ -28,8 +28,8 @@ export interface {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterIn
{{#withInterfaces}}
{{#operations}}
/**
* {{classname}} - interface{{#description}}
* {{&description}}{{/description}}
* {{classname}} - interface
* {{#lambda.indented_1}}{{{unescapedDescription}}}{{/lambda.indented_1}}
* @export
* @interface {{classname}}Interface
*/
@ -71,7 +71,7 @@ export interface {{classname}}Interface {
{{/withInterfaces}}
{{#operations}}
/**
* {{#description}}{{{description}}}{{/description}}{{^description}}no description{{/description}}
* {{#lambda.indented_star_1}}{{{unescapedDescription}}}{{/lambda.indented_star_1}}
*/
{{#withInterfaces}}
export class {{classname}} extends runtime.BaseAPI implements {{classname}}Interface {

View File

@ -1,5 +1,5 @@
/**
* {{{description}}}
* {{#lambda.indented_star_1}}{{{unescapedDescription}}}{{/lambda.indented_star_1}}
* @export
* @enum {string}
*/

View File

@ -19,7 +19,7 @@ import {
{{/discriminator}}
/**
* {{{description}}}
* {{#lambda.indented_star_1}}{{{unescapedDescription}}}{{/lambda.indented_star_1}}
* @export
* @interface {{classname}}
*/
@ -29,7 +29,7 @@ export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{
{{/additionalPropertiesType}}
{{#vars}}
/**
* {{{description}}}
* {{#lambda.indented_star_4}}{{{unescapedDescription}}}{{/lambda.indented_star_4}}
* @type {{=<% %>=}}{<%&datatype%>}<%={{ }}=%>
* @memberof {{classname}}
*/

View File

@ -11,8 +11,8 @@ import {
{{/hasImports}}
/**
* @type {{classname}}{{#description}}
* {{{description}}}{{/description}}
* @type {{classname}}
* {{#lambda.indented_star_1}}{{{unescapedDescription}}}{{/lambda.indented_star_1}}
* @export
*/
export type {{classname}} = {{#discriminator}}{{#mappedModels}}{ {{discriminator.propertyName}}: '{{mappingName}}' } & {{modelName}}{{^-last}} | {{/-last}}{{/mappedModels}}{{/discriminator}}{{^discriminator}}{{#oneOf}}{{{.}}}{{^-last}} | {{/-last}}{{/oneOf}}{{/discriminator}};

View File

@ -61,7 +61,7 @@ export interface UploadFileRequest {
}
/**
* no description
*
*/
export class PetApi extends runtime.BaseAPI {

View File

@ -33,7 +33,7 @@ export interface PlaceOrderRequest {
}
/**
* no description
*
*/
export class StoreApi extends runtime.BaseAPI {

View File

@ -51,7 +51,7 @@ export interface UpdateUserRequest {
}
/**
* no description
*
*/
export class UserApi extends runtime.BaseAPI {

View File

@ -61,7 +61,7 @@ export interface UploadFileRequest {
}
/**
* no description
*
*/
export class PetApi extends runtime.BaseAPI {

View File

@ -33,7 +33,7 @@ export interface PlaceOrderRequest {
}
/**
* no description
*
*/
export class StoreApi extends runtime.BaseAPI {

View File

@ -51,7 +51,7 @@ export interface UpdateUserRequest {
}
/**
* no description
*
*/
export class UserApi extends runtime.BaseAPI {

View File

@ -61,7 +61,7 @@ export interface UploadFileRequest {
}
/**
* no description
*
*/
export class PetApi extends runtime.BaseAPI {

View File

@ -33,7 +33,7 @@ export interface PlaceOrderRequest {
}
/**
* no description
*
*/
export class StoreApi extends runtime.BaseAPI {

View File

@ -51,7 +51,7 @@ export interface UpdateUserRequest {
}
/**
* no description
*
*/
export class UserApi extends runtime.BaseAPI {

View File

@ -61,7 +61,7 @@ export interface PetApiUploadFileRequest {
}
/**
* no description
*
*/
export class PetApi extends runtime.BaseAPI {

View File

@ -33,7 +33,7 @@ export interface StoreApiPlaceOrderRequest {
}
/**
* no description
*
*/
export class StoreApi extends runtime.BaseAPI {

View File

@ -51,7 +51,7 @@ export interface UserApiUpdateUserRequest {
}
/**
* no description
*
*/
export class UserApi extends runtime.BaseAPI {

View File

@ -61,7 +61,7 @@ export interface UploadFileRequest {
}
/**
* no description
*
*/
export class PetApi extends runtime.BaseAPI {

View File

@ -33,7 +33,7 @@ export interface PlaceOrderRequest {
}
/**
* no description
*
*/
export class StoreApi extends runtime.BaseAPI {

View File

@ -51,7 +51,7 @@ export interface UpdateUserRequest {
}
/**
* no description
*
*/
export class UserApi extends runtime.BaseAPI {

View File

@ -62,6 +62,7 @@ export interface UploadFileRequest {
/**
* PetApi - interface
*
* @export
* @interface PetApiInterface
*/
@ -197,7 +198,7 @@ export interface PetApiInterface {
}
/**
* no description
*
*/
export class PetApi extends runtime.BaseAPI implements PetApiInterface {

View File

@ -34,6 +34,7 @@ export interface PlaceOrderRequest {
/**
* StoreApi - interface
*
* @export
* @interface StoreApiInterface
*/
@ -103,7 +104,7 @@ export interface StoreApiInterface {
}
/**
* no description
*
*/
export class StoreApi extends runtime.BaseAPI implements StoreApiInterface {

View File

@ -52,6 +52,7 @@ export interface UpdateUserRequest {
/**
* UserApi - interface
*
* @export
* @interface UserApiInterface
*/
@ -183,7 +184,7 @@ export interface UserApiInterface {
}
/**
* no description
*
*/
export class UserApi extends runtime.BaseAPI implements UserApiInterface {

View File

@ -61,7 +61,7 @@ export interface UploadFileRequest {
}
/**
* no description
*
*/
export class PetApi extends runtime.BaseAPI {

View File

@ -33,7 +33,7 @@ export interface PlaceOrderRequest {
}
/**
* no description
*
*/
export class StoreApi extends runtime.BaseAPI {

View File

@ -51,7 +51,7 @@ export interface UpdateUserRequest {
}
/**
* no description
*
*/
export class UserApi extends runtime.BaseAPI {