fix(docs): API reference bugs (#2119)
* fixed shipping method tax line schema name * added dry run option to build openapi script * fixed summary of endpoints * fixed title of endpoint
This commit is contained in:
@@ -31,4 +31,4 @@ jobs:
|
|||||||
|
|
||||||
- name: Build OAS
|
- name: Build OAS
|
||||||
run: |
|
run: |
|
||||||
yarn openapi:generate
|
yarn openapi:generate --dry-run
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ import { validator } from "../../../../utils/validator"
|
|||||||
/**
|
/**
|
||||||
* @oas [post] /discounts/{discount_id}/conditions
|
* @oas [post] /discounts/{discount_id}/conditions
|
||||||
* operationId: "PostDiscountsDiscountConditions"
|
* operationId: "PostDiscountsDiscountConditions"
|
||||||
* summary: "Creates a DiscountCondition. Only one of `products`, `product_types`, `product_collections`, `product_tags`, and `customer_groups` should be provided."
|
* summary: "Create a DiscountCondition"
|
||||||
|
* description: "Creates a DiscountCondition. Only one of `products`, `product_types`, `product_collections`, `product_tags`, and `customer_groups` should be provided."
|
||||||
* x-authenticated: true
|
* x-authenticated: true
|
||||||
* parameters:
|
* parameters:
|
||||||
* - (path) discount_id=* {string} The ID of the Product.
|
* - (path) discount_id=* {string} The ID of the Product.
|
||||||
* - (query) expand {string} (Comma separated) Which fields should be expanded in each product of the result.
|
* - (query) expand {string} (Comma separated) Which fields should be expanded in each product of the result.
|
||||||
* - (query) fields {string} (Comma separated) Which fields should be included in each product of the result.
|
* - (query) fields {string} (Comma separated) Which fields should be included in each product of the result.
|
||||||
* description: "Creates a DiscountCondition"
|
|
||||||
* requestBody:
|
* requestBody:
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ import { validator } from "../../../../utils/validator"
|
|||||||
/**
|
/**
|
||||||
* @oas [post] /discounts/{discount_id}/conditions/{condition_id}
|
* @oas [post] /discounts/{discount_id}/conditions/{condition_id}
|
||||||
* operationId: "PostDiscountsDiscountConditionsCondition"
|
* operationId: "PostDiscountsDiscountConditionsCondition"
|
||||||
* summary: "Updates a DiscountCondition. Only one of `products`, `product_types`, `product_collections`, `product_tags`, and `customer_groups` should be provided."
|
* summary: "Update a DiscountCondition"
|
||||||
|
* description: "Updates a DiscountCondition. Only one of `products`, `product_types`, `product_collections`, `product_tags`, and `customer_groups` should be provided."
|
||||||
* x-authenticated: true
|
* x-authenticated: true
|
||||||
* parameters:
|
* parameters:
|
||||||
* - (path) discount_id=* {string} The ID of the Product.
|
* - (path) discount_id=* {string} The ID of the Product.
|
||||||
* - (path) condition_id=* {string} The ID of the DiscountCondition.
|
* - (path) condition_id=* {string} The ID of the DiscountCondition.
|
||||||
* - (query) expand {string} (Comma separated) Which fields should be expanded in each item of the result.
|
* - (query) expand {string} (Comma separated) Which fields should be expanded in each item of the result.
|
||||||
* - (query) fields {string} (Comma separated) Which fields should be included in each item of the result.
|
* - (query) fields {string} (Comma separated) Which fields should be included in each item of the result.
|
||||||
* description: "Updates a DiscountCondition"
|
|
||||||
* requestBody:
|
* requestBody:
|
||||||
* content:
|
* content:
|
||||||
* application/json:
|
* application/json:
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import { EntityManager } from "typeorm"
|
|||||||
/**
|
/**
|
||||||
* @oas [post] /gift-cards/{id}
|
* @oas [post] /gift-cards/{id}
|
||||||
* operationId: "PostGiftCardsGiftCard"
|
* operationId: "PostGiftCardsGiftCard"
|
||||||
* summary: "Create a Gift Card"
|
* summary: "Update a Gift Card"
|
||||||
* description: "Creates a Gift Card that can redeemed by its unique code. The Gift Card is only valid within 1 region."
|
* description: "Update a Gift Card that can redeemed by its unique code. The Gift Card is only valid within 1 region."
|
||||||
* x-authenticated: true
|
* x-authenticated: true
|
||||||
* parameters:
|
* parameters:
|
||||||
* - (path) id=* {string} The ID of the Gift Card.
|
* - (path) id=* {string} The ID of the Gift Card.
|
||||||
|
|||||||
@@ -30,10 +30,10 @@ export class ShippingMethodTaxLine extends TaxLine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @schema sales_channel_tax_line
|
* @schema shipping_method_tax_line
|
||||||
* title: "Sales Channel"
|
* title: "Shipping Method Tax Line"
|
||||||
* description: "A Sales Channel"
|
* description: "Shipping Method Tax Line"
|
||||||
* x-resourceId: sales_channel_tax_line
|
* x-resourceId: shipping_method_tax_line
|
||||||
* required:
|
* required:
|
||||||
* - shipping_method_id
|
* - shipping_method_id
|
||||||
* - rate
|
* - rate
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ export class ShippingMethod {
|
|||||||
* type: array
|
* type: array
|
||||||
* description: Available if the relation `tax_lines` is expanded.
|
* description: Available if the relation `tax_lines` is expanded.
|
||||||
* items:
|
* items:
|
||||||
* $ref: "#/components/schemas/tax_line"
|
* $ref: "#/components/schemas/shipping_method_tax_line"
|
||||||
* price:
|
* price:
|
||||||
* description: "The amount to charge for the Shipping Method. The currency of the price is defined by the Region that the Order that the Shipping Method belongs to is a part of."
|
* description: "The amount to charge for the Shipping Method. The currency of the price is defined by the Region that the Order that the Shipping Method belongs to is a part of."
|
||||||
* type: integer
|
* type: integer
|
||||||
|
|||||||
@@ -3,7 +3,10 @@
|
|||||||
const fs = require("fs")
|
const fs = require("fs")
|
||||||
const OAS = require("oas-normalize")
|
const OAS = require("oas-normalize")
|
||||||
const swaggerInline = require("swagger-inline")
|
const swaggerInline = require("swagger-inline")
|
||||||
const { exec } = require("child_process")
|
const { exec } = require("child_process");
|
||||||
|
const { exit } = require("process");
|
||||||
|
|
||||||
|
const isDryRun = process.argv.indexOf('--dry-run') !== -1;
|
||||||
|
|
||||||
// Storefront API
|
// Storefront API
|
||||||
swaggerInline(
|
swaggerInline(
|
||||||
@@ -16,7 +19,9 @@ swaggerInline(
|
|||||||
oas
|
oas
|
||||||
.validate(true)
|
.validate(true)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
if (!isDryRun) {
|
||||||
fs.writeFileSync("./docs/api/store-spec3.json", gen)
|
fs.writeFileSync("./docs/api/store-spec3.json", gen)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log("Error in store")
|
console.log("Error in store")
|
||||||
@@ -32,6 +37,7 @@ swaggerInline(
|
|||||||
format: "yaml",
|
format: "yaml",
|
||||||
}
|
}
|
||||||
).then((gen) => {
|
).then((gen) => {
|
||||||
|
if (!isDryRun) {
|
||||||
fs.writeFileSync("./docs/api/store-spec3.yaml", gen)
|
fs.writeFileSync("./docs/api/store-spec3.yaml", gen)
|
||||||
exec("rm -rf docs/api/store/ && yarn run -- redocly split docs/api/store-spec3.yaml --outDir=docs/api/store/", (error, stdout, stderr) => {
|
exec("rm -rf docs/api/store/ && yarn run -- redocly split docs/api/store-spec3.yaml --outDir=docs/api/store/", (error, stdout, stderr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
@@ -39,6 +45,9 @@ swaggerInline(
|
|||||||
}
|
}
|
||||||
console.log(`${stderr || stdout}`);
|
console.log(`${stderr || stdout}`);
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
console.log('No errors occurred while generating Store API Reference');
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// Admin API
|
// Admin API
|
||||||
@@ -52,7 +61,9 @@ swaggerInline(
|
|||||||
oas
|
oas
|
||||||
.validate(true)
|
.validate(true)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
if (!isDryRun) {
|
||||||
fs.writeFileSync("./docs/api/admin-spec3.json", gen)
|
fs.writeFileSync("./docs/api/admin-spec3.json", gen)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.log("Error in admin")
|
console.log("Error in admin")
|
||||||
@@ -68,6 +79,7 @@ swaggerInline(
|
|||||||
format: "yaml",
|
format: "yaml",
|
||||||
}
|
}
|
||||||
).then((gen) => {
|
).then((gen) => {
|
||||||
|
if (!isDryRun) {
|
||||||
fs.writeFileSync("./docs/api/admin-spec3.yaml", gen)
|
fs.writeFileSync("./docs/api/admin-spec3.yaml", gen)
|
||||||
exec("rm -rf docs/api/admin/ && yarn run -- redocly split docs/api/admin-spec3.yaml --outDir=docs/api/admin/", (error, stdout, stderr) => {
|
exec("rm -rf docs/api/admin/ && yarn run -- redocly split docs/api/admin-spec3.yaml --outDir=docs/api/admin/", (error, stdout, stderr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
@@ -76,4 +88,7 @@ swaggerInline(
|
|||||||
console.log(`${stderr || stdout}`);
|
console.log(`${stderr || stdout}`);
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
console.log('No errors occurred while generating Admin API Reference');
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user