Skip to content

Fix serialize object #910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 1, 2022
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
3 changes: 2 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ export function prepareComment(v: CommentObject): string | void {
if (v[field] === "" && !allowEmptyString) {
continue;
}
commentsArray.push(`@${field} ${v[field]} `);
const serialized = typeof v[field] === "object" ? JSON.stringify(v[field], null, 2) : v[field];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice fix

commentsArray.push(`@${field} ${serialized} `);
}

// * JSDOC 'Constant' without value
Expand Down
16 changes: 11 additions & 5 deletions test/bin/expected/specs/manifold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ export interface definitions {
sso_url?: string;
/** @enum {string} */
version?: "v1";
/** @default [object Object] */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

/** @default {} */
features?: {
access_code?: boolean;
sso?: boolean;
Expand Down Expand Up @@ -762,7 +762,13 @@ export interface definitions {
/**
* @description Price describes how the feature cost should be calculated.
*
* @example [object Object]
* @example {
* "feature_multiplies_base_cost": "(* plan#base_cost feature-a#multiply_factor)",
* "feature_multiplies_feature_cost": "(* feature-b#cost feature-a#multiply_factor)",
* "feature_multiplies_numeric_value": "(* feature-c#number feature-a#multiply_factor)",
* "feature_multiplies_total_cost": "(* plan#total_cost feature-a#multiply_factor)",
* "feature_nested_formulas": "(+ (- (* feature-a#cost feature-b#multiply_factor) 500) plan#partial_cost)"
* }
*/
formula?: definitions["PriceFormula"];
/** @description Description explains how a feature is calculated to the user. */
Expand Down Expand Up @@ -834,7 +840,7 @@ export interface definitions {
ProductTags: definitions["Label"][];
/** @enum {string} */
ProductState: "available" | "hidden" | "grandfathered" | "new" | "upcoming";
/** @default [object Object] */
/** @default {} */
ProductListing: {
/**
* @description When true, everyone can see the product when requested. When false it will
Expand All @@ -859,7 +865,7 @@ export interface definitions {
* we find ourselves in a position where we think they should, we should
* consider refactoring our listing definition.
*
* @default [object Object]
* @default {}
*/
marketing?: {
/**
Expand Down Expand Up @@ -898,7 +904,7 @@ export interface definitions {
* @enum {string}
*/
ProductProvisioning: "provider-only" | "pre-order" | "public";
/** @default [object Object] */
/** @default {} */
ProductIntegrationFeatures: {
/**
* @description Indicates whether or not this product supports resource transitions to
Expand Down
16 changes: 11 additions & 5 deletions test/v2/expected/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ export interface definitions {
sso_url?: string;
/** @enum {string} */
version?: "v1";
/** @default [object Object] */
/** @default {} */
features?: {
access_code?: boolean;
sso?: boolean;
Expand Down Expand Up @@ -762,7 +762,13 @@ export interface definitions {
/**
* @description Price describes how the feature cost should be calculated.
*
* @example [object Object]
* @example {
* "feature_multiplies_base_cost": "(* plan#base_cost feature-a#multiply_factor)",
* "feature_multiplies_feature_cost": "(* feature-b#cost feature-a#multiply_factor)",
* "feature_multiplies_numeric_value": "(* feature-c#number feature-a#multiply_factor)",
* "feature_multiplies_total_cost": "(* plan#total_cost feature-a#multiply_factor)",
* "feature_nested_formulas": "(+ (- (* feature-a#cost feature-b#multiply_factor) 500) plan#partial_cost)"
* }
*/
formula?: definitions["PriceFormula"];
/** @description Description explains how a feature is calculated to the user. */
Expand Down Expand Up @@ -834,7 +840,7 @@ export interface definitions {
ProductTags: definitions["Label"][];
/** @enum {string} */
ProductState: "available" | "hidden" | "grandfathered" | "new" | "upcoming";
/** @default [object Object] */
/** @default {} */
ProductListing: {
/**
* @description When true, everyone can see the product when requested. When false it will
Expand All @@ -859,7 +865,7 @@ export interface definitions {
* we find ourselves in a position where we think they should, we should
* consider refactoring our listing definition.
*
* @default [object Object]
* @default {}
*/
marketing?: {
/**
Expand Down Expand Up @@ -898,7 +904,7 @@ export interface definitions {
* @enum {string}
*/
ProductProvisioning: "provider-only" | "pre-order" | "public";
/** @default [object Object] */
/** @default {} */
ProductIntegrationFeatures: {
/**
* @description Indicates whether or not this product supports resource transitions to
Expand Down
16 changes: 11 additions & 5 deletions test/v2/expected/manifold.immutable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ export interface definitions {
readonly sso_url?: string
/** @enum {string} */
readonly version?: 'v1'
/** @default [object Object] */
/** @default {} */
readonly features?: {
readonly access_code?: boolean
readonly sso?: boolean
Expand Down Expand Up @@ -762,7 +762,13 @@ export interface definitions {
/**
* @description Price describes how the feature cost should be calculated.
*
* @example [object Object]
* @example {
* "feature_multiplies_base_cost": "(* plan#base_cost feature-a#multiply_factor)",
* "feature_multiplies_feature_cost": "(* feature-b#cost feature-a#multiply_factor)",
* "feature_multiplies_numeric_value": "(* feature-c#number feature-a#multiply_factor)",
* "feature_multiplies_total_cost": "(* plan#total_cost feature-a#multiply_factor)",
* "feature_nested_formulas": "(+ (- (* feature-a#cost feature-b#multiply_factor) 500) plan#partial_cost)"
* }
*/
readonly formula?: definitions['PriceFormula']
/** @description Description explains how a feature is calculated to the user. */
Expand Down Expand Up @@ -834,7 +840,7 @@ export interface definitions {
readonly ProductTags: readonly definitions['Label'][]
/** @enum {string} */
readonly ProductState: 'available' | 'hidden' | 'grandfathered' | 'new' | 'upcoming'
/** @default [object Object] */
/** @default {} */
readonly ProductListing: {
/**
* @description When true, everyone can see the product when requested. When false it will
Expand All @@ -859,7 +865,7 @@ export interface definitions {
* we find ourselves in a position where we think they should, we should
* consider refactoring our listing definition.
*
* @default [object Object]
* @default {}
*/
readonly marketing?: {
/**
Expand Down Expand Up @@ -898,7 +904,7 @@ export interface definitions {
* @enum {string}
*/
readonly ProductProvisioning: 'provider-only' | 'pre-order' | 'public'
/** @default [object Object] */
/** @default {} */
readonly ProductIntegrationFeatures: {
/**
* @description Indicates whether or not this product supports resource transitions to
Expand Down
16 changes: 11 additions & 5 deletions test/v2/expected/manifold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,7 @@ export interface definitions {
sso_url?: string
/** @enum {string} */
version?: 'v1'
/** @default [object Object] */
/** @default {} */
features?: {
access_code?: boolean
sso?: boolean
Expand Down Expand Up @@ -762,7 +762,13 @@ export interface definitions {
/**
* @description Price describes how the feature cost should be calculated.
*
* @example [object Object]
* @example {
* "feature_multiplies_base_cost": "(* plan#base_cost feature-a#multiply_factor)",
* "feature_multiplies_feature_cost": "(* feature-b#cost feature-a#multiply_factor)",
* "feature_multiplies_numeric_value": "(* feature-c#number feature-a#multiply_factor)",
* "feature_multiplies_total_cost": "(* plan#total_cost feature-a#multiply_factor)",
* "feature_nested_formulas": "(+ (- (* feature-a#cost feature-b#multiply_factor) 500) plan#partial_cost)"
* }
*/
formula?: definitions['PriceFormula']
/** @description Description explains how a feature is calculated to the user. */
Expand Down Expand Up @@ -834,7 +840,7 @@ export interface definitions {
ProductTags: definitions['Label'][]
/** @enum {string} */
ProductState: 'available' | 'hidden' | 'grandfathered' | 'new' | 'upcoming'
/** @default [object Object] */
/** @default {} */
ProductListing: {
/**
* @description When true, everyone can see the product when requested. When false it will
Expand All @@ -859,7 +865,7 @@ export interface definitions {
* we find ourselves in a position where we think they should, we should
* consider refactoring our listing definition.
*
* @default [object Object]
* @default {}
*/
marketing?: {
/**
Expand Down Expand Up @@ -898,7 +904,7 @@ export interface definitions {
* @enum {string}
*/
ProductProvisioning: 'provider-only' | 'pre-order' | 'public'
/** @default [object Object] */
/** @default {} */
ProductIntegrationFeatures: {
/**
* @description Indicates whether or not this product supports resource transitions to
Expand Down
Loading