forked from loafle/openapi-generator-original
[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:
parent
f12fb86a1a
commit
500fb472b0
@ -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)) {
|
||||
|
@ -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 {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* {{{description}}}
|
||||
* {{#lambda.indented_star_1}}{{{unescapedDescription}}}{{/lambda.indented_star_1}}
|
||||
* @export
|
||||
* @enum {string}
|
||||
*/
|
||||
|
@ -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}}
|
||||
*/
|
||||
|
@ -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}};
|
||||
|
@ -61,7 +61,7 @@ export interface UploadFileRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* no description
|
||||
*
|
||||
*/
|
||||
export class PetApi extends runtime.BaseAPI {
|
||||
|
||||
|
@ -33,7 +33,7 @@ export interface PlaceOrderRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* no description
|
||||
*
|
||||
*/
|
||||
export class StoreApi extends runtime.BaseAPI {
|
||||
|
||||
|
@ -51,7 +51,7 @@ export interface UpdateUserRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* no description
|
||||
*
|
||||
*/
|
||||
export class UserApi extends runtime.BaseAPI {
|
||||
|
||||
|
@ -61,7 +61,7 @@ export interface UploadFileRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* no description
|
||||
*
|
||||
*/
|
||||
export class PetApi extends runtime.BaseAPI {
|
||||
|
||||
|
@ -33,7 +33,7 @@ export interface PlaceOrderRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* no description
|
||||
*
|
||||
*/
|
||||
export class StoreApi extends runtime.BaseAPI {
|
||||
|
||||
|
@ -51,7 +51,7 @@ export interface UpdateUserRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* no description
|
||||
*
|
||||
*/
|
||||
export class UserApi extends runtime.BaseAPI {
|
||||
|
||||
|
@ -61,7 +61,7 @@ export interface UploadFileRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* no description
|
||||
*
|
||||
*/
|
||||
export class PetApi extends runtime.BaseAPI {
|
||||
|
||||
|
@ -33,7 +33,7 @@ export interface PlaceOrderRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* no description
|
||||
*
|
||||
*/
|
||||
export class StoreApi extends runtime.BaseAPI {
|
||||
|
||||
|
@ -51,7 +51,7 @@ export interface UpdateUserRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* no description
|
||||
*
|
||||
*/
|
||||
export class UserApi extends runtime.BaseAPI {
|
||||
|
||||
|
@ -61,7 +61,7 @@ export interface PetApiUploadFileRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* no description
|
||||
*
|
||||
*/
|
||||
export class PetApi extends runtime.BaseAPI {
|
||||
|
||||
|
@ -33,7 +33,7 @@ export interface StoreApiPlaceOrderRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* no description
|
||||
*
|
||||
*/
|
||||
export class StoreApi extends runtime.BaseAPI {
|
||||
|
||||
|
@ -51,7 +51,7 @@ export interface UserApiUpdateUserRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* no description
|
||||
*
|
||||
*/
|
||||
export class UserApi extends runtime.BaseAPI {
|
||||
|
||||
|
@ -61,7 +61,7 @@ export interface UploadFileRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* no description
|
||||
*
|
||||
*/
|
||||
export class PetApi extends runtime.BaseAPI {
|
||||
|
||||
|
@ -33,7 +33,7 @@ export interface PlaceOrderRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* no description
|
||||
*
|
||||
*/
|
||||
export class StoreApi extends runtime.BaseAPI {
|
||||
|
||||
|
@ -51,7 +51,7 @@ export interface UpdateUserRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* no description
|
||||
*
|
||||
*/
|
||||
export class UserApi extends runtime.BaseAPI {
|
||||
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -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 {
|
||||
|
||||
|
@ -61,7 +61,7 @@ export interface UploadFileRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* no description
|
||||
*
|
||||
*/
|
||||
export class PetApi extends runtime.BaseAPI {
|
||||
|
||||
|
@ -33,7 +33,7 @@ export interface PlaceOrderRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* no description
|
||||
*
|
||||
*/
|
||||
export class StoreApi extends runtime.BaseAPI {
|
||||
|
||||
|
@ -51,7 +51,7 @@ export interface UpdateUserRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* no description
|
||||
*
|
||||
*/
|
||||
export class UserApi extends runtime.BaseAPI {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user