Skip to content
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
[typescript-fetch] Allow multiline documentation
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.
  • Loading branch information
haraldF committed Apr 28, 2020
commit 2fceeab30cdeb25d277ff6022d48f88592fa45dd
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -134,6 +137,14 @@ public void processOpts() {
}
}

@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)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* {{{description}}}
* {{#lambda.indented_star_1}}{{{unescapedDescription}}}{{/lambda.indented_star_1}}
* @export
* @enum {string}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {

{{/discriminator}}
/**
* {{{description}}}
* {{#lambda.indented_star_1}}{{{unescapedDescription}}}{{/lambda.indented_star_1}}
* @export
* @interface {{classname}}
*/
Expand All @@ -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}}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export interface UploadFileRequest {
}

/**
* no description
*
*/
export class PetApi extends runtime.BaseAPI {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface PlaceOrderRequest {
}

/**
* no description
*
*/
export class StoreApi extends runtime.BaseAPI {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export interface UpdateUserRequest {
}

/**
* no description
*
*/
export class UserApi extends runtime.BaseAPI {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export interface UploadFileRequest {
}

/**
* no description
*
*/
export class PetApi extends runtime.BaseAPI {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface PlaceOrderRequest {
}

/**
* no description
*
*/
export class StoreApi extends runtime.BaseAPI {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export interface UpdateUserRequest {
}

/**
* no description
*
*/
export class UserApi extends runtime.BaseAPI {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export interface UploadFileRequest {
}

/**
* no description
*
*/
export class PetApi extends runtime.BaseAPI {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface PlaceOrderRequest {
}

/**
* no description
*
*/
export class StoreApi extends runtime.BaseAPI {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export interface UpdateUserRequest {
}

/**
* no description
*
*/
export class UserApi extends runtime.BaseAPI {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export interface PetApiUploadFileRequest {
}

/**
* no description
*
*/
export class PetApi extends runtime.BaseAPI {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface StoreApiPlaceOrderRequest {
}

/**
* no description
*
*/
export class StoreApi extends runtime.BaseAPI {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export interface UserApiUpdateUserRequest {
}

/**
* no description
*
*/
export class UserApi extends runtime.BaseAPI {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export interface UploadFileRequest {
}

/**
* no description
*
*/
export class PetApi extends runtime.BaseAPI {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface PlaceOrderRequest {
}

/**
* no description
*
*/
export class StoreApi extends runtime.BaseAPI {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export interface UpdateUserRequest {
}

/**
* no description
*
*/
export class UserApi extends runtime.BaseAPI {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export interface UploadFileRequest {

/**
* PetApi - interface
*
* @export
* @interface PetApiInterface
*/
Expand Down Expand Up @@ -197,7 +198,7 @@ export interface PetApiInterface {
}

/**
* no description
*
*/
export class PetApi extends runtime.BaseAPI implements PetApiInterface {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export interface PlaceOrderRequest {

/**
* StoreApi - interface
*
* @export
* @interface StoreApiInterface
*/
Expand Down Expand Up @@ -103,7 +104,7 @@ export interface StoreApiInterface {
}

/**
* no description
*
*/
export class StoreApi extends runtime.BaseAPI implements StoreApiInterface {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface UpdateUserRequest {

/**
* UserApi - interface
*
* @export
* @interface UserApiInterface
*/
Expand Down Expand Up @@ -183,7 +184,7 @@ export interface UserApiInterface {
}

/**
* no description
*
*/
export class UserApi extends runtime.BaseAPI implements UserApiInterface {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export interface UploadFileRequest {
}

/**
* no description
*
*/
export class PetApi extends runtime.BaseAPI {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface PlaceOrderRequest {
}

/**
* no description
*
*/
export class StoreApi extends runtime.BaseAPI {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export interface UpdateUserRequest {
}

/**
* no description
*
*/
export class UserApi extends runtime.BaseAPI {

Expand Down