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;
|
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.ArraySchema;
|
||||||
import io.swagger.v3.oas.models.media.Schema;
|
import io.swagger.v3.oas.models.media.Schema;
|
||||||
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
import io.swagger.v3.parser.util.SchemaTypeUtil;
|
||||||
import org.openapitools.codegen.*;
|
import org.openapitools.codegen.*;
|
||||||
import org.openapitools.codegen.meta.features.DocumentationFeature;
|
import org.openapitools.codegen.meta.features.DocumentationFeature;
|
||||||
|
import org.openapitools.codegen.templating.mustache.IndentedLambda;
|
||||||
import org.openapitools.codegen.utils.ModelUtils;
|
import org.openapitools.codegen.utils.ModelUtils;
|
||||||
|
|
||||||
import java.io.File;
|
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
|
@Override
|
||||||
public String getTypeDeclaration(Schema p) {
|
public String getTypeDeclaration(Schema p) {
|
||||||
if (ModelUtils.isFileSchema(p)) {
|
if (ModelUtils.isFileSchema(p)) {
|
||||||
|
@ -28,8 +28,8 @@ export interface {{#prefixParameterInterfaces}}{{classname}}{{/prefixParameterIn
|
|||||||
{{#withInterfaces}}
|
{{#withInterfaces}}
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
/**
|
/**
|
||||||
* {{classname}} - interface{{#description}}
|
* {{classname}} - interface
|
||||||
* {{&description}}{{/description}}
|
* {{#lambda.indented_1}}{{{unescapedDescription}}}{{/lambda.indented_1}}
|
||||||
* @export
|
* @export
|
||||||
* @interface {{classname}}Interface
|
* @interface {{classname}}Interface
|
||||||
*/
|
*/
|
||||||
@ -71,7 +71,7 @@ export interface {{classname}}Interface {
|
|||||||
{{/withInterfaces}}
|
{{/withInterfaces}}
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
/**
|
/**
|
||||||
* {{#description}}{{{description}}}{{/description}}{{^description}}no description{{/description}}
|
* {{#lambda.indented_star_1}}{{{unescapedDescription}}}{{/lambda.indented_star_1}}
|
||||||
*/
|
*/
|
||||||
{{#withInterfaces}}
|
{{#withInterfaces}}
|
||||||
export class {{classname}} extends runtime.BaseAPI implements {{classname}}Interface {
|
export class {{classname}} extends runtime.BaseAPI implements {{classname}}Interface {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* {{{description}}}
|
* {{#lambda.indented_star_1}}{{{unescapedDescription}}}{{/lambda.indented_star_1}}
|
||||||
* @export
|
* @export
|
||||||
* @enum {string}
|
* @enum {string}
|
||||||
*/
|
*/
|
||||||
|
@ -19,7 +19,7 @@ import {
|
|||||||
|
|
||||||
{{/discriminator}}
|
{{/discriminator}}
|
||||||
/**
|
/**
|
||||||
* {{{description}}}
|
* {{#lambda.indented_star_1}}{{{unescapedDescription}}}{{/lambda.indented_star_1}}
|
||||||
* @export
|
* @export
|
||||||
* @interface {{classname}}
|
* @interface {{classname}}
|
||||||
*/
|
*/
|
||||||
@ -29,7 +29,7 @@ export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{
|
|||||||
{{/additionalPropertiesType}}
|
{{/additionalPropertiesType}}
|
||||||
{{#vars}}
|
{{#vars}}
|
||||||
/**
|
/**
|
||||||
* {{{description}}}
|
* {{#lambda.indented_star_4}}{{{unescapedDescription}}}{{/lambda.indented_star_4}}
|
||||||
* @type {{=<% %>=}}{<%&datatype%>}<%={{ }}=%>
|
* @type {{=<% %>=}}{<%&datatype%>}<%={{ }}=%>
|
||||||
* @memberof {{classname}}
|
* @memberof {{classname}}
|
||||||
*/
|
*/
|
||||||
|
@ -11,8 +11,8 @@ import {
|
|||||||
|
|
||||||
{{/hasImports}}
|
{{/hasImports}}
|
||||||
/**
|
/**
|
||||||
* @type {{classname}}{{#description}}
|
* @type {{classname}}
|
||||||
* {{{description}}}{{/description}}
|
* {{#lambda.indented_star_1}}{{{unescapedDescription}}}{{/lambda.indented_star_1}}
|
||||||
* @export
|
* @export
|
||||||
*/
|
*/
|
||||||
export type {{classname}} = {{#discriminator}}{{#mappedModels}}{ {{discriminator.propertyName}}: '{{mappingName}}' } & {{modelName}}{{^-last}} | {{/-last}}{{/mappedModels}}{{/discriminator}}{{^discriminator}}{{#oneOf}}{{{.}}}{{^-last}} | {{/-last}}{{/oneOf}}{{/discriminator}};
|
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 {
|
export class PetApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ export interface PlaceOrderRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* no description
|
*
|
||||||
*/
|
*/
|
||||||
export class StoreApi extends runtime.BaseAPI {
|
export class StoreApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ export interface UpdateUserRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* no description
|
*
|
||||||
*/
|
*/
|
||||||
export class UserApi extends runtime.BaseAPI {
|
export class UserApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ export interface UploadFileRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* no description
|
*
|
||||||
*/
|
*/
|
||||||
export class PetApi extends runtime.BaseAPI {
|
export class PetApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ export interface PlaceOrderRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* no description
|
*
|
||||||
*/
|
*/
|
||||||
export class StoreApi extends runtime.BaseAPI {
|
export class StoreApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ export interface UpdateUserRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* no description
|
*
|
||||||
*/
|
*/
|
||||||
export class UserApi extends runtime.BaseAPI {
|
export class UserApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ export interface UploadFileRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* no description
|
*
|
||||||
*/
|
*/
|
||||||
export class PetApi extends runtime.BaseAPI {
|
export class PetApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ export interface PlaceOrderRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* no description
|
*
|
||||||
*/
|
*/
|
||||||
export class StoreApi extends runtime.BaseAPI {
|
export class StoreApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ export interface UpdateUserRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* no description
|
*
|
||||||
*/
|
*/
|
||||||
export class UserApi extends runtime.BaseAPI {
|
export class UserApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ export interface PetApiUploadFileRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* no description
|
*
|
||||||
*/
|
*/
|
||||||
export class PetApi extends runtime.BaseAPI {
|
export class PetApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ export interface StoreApiPlaceOrderRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* no description
|
*
|
||||||
*/
|
*/
|
||||||
export class StoreApi extends runtime.BaseAPI {
|
export class StoreApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ export interface UserApiUpdateUserRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* no description
|
*
|
||||||
*/
|
*/
|
||||||
export class UserApi extends runtime.BaseAPI {
|
export class UserApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ export interface UploadFileRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* no description
|
*
|
||||||
*/
|
*/
|
||||||
export class PetApi extends runtime.BaseAPI {
|
export class PetApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ export interface PlaceOrderRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* no description
|
*
|
||||||
*/
|
*/
|
||||||
export class StoreApi extends runtime.BaseAPI {
|
export class StoreApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ export interface UpdateUserRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* no description
|
*
|
||||||
*/
|
*/
|
||||||
export class UserApi extends runtime.BaseAPI {
|
export class UserApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
@ -62,6 +62,7 @@ export interface UploadFileRequest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* PetApi - interface
|
* PetApi - interface
|
||||||
|
*
|
||||||
* @export
|
* @export
|
||||||
* @interface PetApiInterface
|
* @interface PetApiInterface
|
||||||
*/
|
*/
|
||||||
@ -197,7 +198,7 @@ export interface PetApiInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* no description
|
*
|
||||||
*/
|
*/
|
||||||
export class PetApi extends runtime.BaseAPI implements PetApiInterface {
|
export class PetApi extends runtime.BaseAPI implements PetApiInterface {
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ export interface PlaceOrderRequest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* StoreApi - interface
|
* StoreApi - interface
|
||||||
|
*
|
||||||
* @export
|
* @export
|
||||||
* @interface StoreApiInterface
|
* @interface StoreApiInterface
|
||||||
*/
|
*/
|
||||||
@ -103,7 +104,7 @@ export interface StoreApiInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* no description
|
*
|
||||||
*/
|
*/
|
||||||
export class StoreApi extends runtime.BaseAPI implements StoreApiInterface {
|
export class StoreApi extends runtime.BaseAPI implements StoreApiInterface {
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ export interface UpdateUserRequest {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* UserApi - interface
|
* UserApi - interface
|
||||||
|
*
|
||||||
* @export
|
* @export
|
||||||
* @interface UserApiInterface
|
* @interface UserApiInterface
|
||||||
*/
|
*/
|
||||||
@ -183,7 +184,7 @@ export interface UserApiInterface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* no description
|
*
|
||||||
*/
|
*/
|
||||||
export class UserApi extends runtime.BaseAPI implements UserApiInterface {
|
export class UserApi extends runtime.BaseAPI implements UserApiInterface {
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ export interface UploadFileRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* no description
|
*
|
||||||
*/
|
*/
|
||||||
export class PetApi extends runtime.BaseAPI {
|
export class PetApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ export interface PlaceOrderRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* no description
|
*
|
||||||
*/
|
*/
|
||||||
export class StoreApi extends runtime.BaseAPI {
|
export class StoreApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ export interface UpdateUserRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* no description
|
*
|
||||||
*/
|
*/
|
||||||
export class UserApi extends runtime.BaseAPI {
|
export class UserApi extends runtime.BaseAPI {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user