Просмотр исходного кода

Merge pull request #1472 from weseek/reactify-admin/rewrite-swagger

Reactify admin/rewrite swagger
Yuki Takei 6 лет назад
Родитель
Сommit
b53950a242

+ 1 - 1
src/client/js/app.jsx

@@ -158,7 +158,7 @@ Object.keys(componentMappings).forEach((key) => {
 const adminCustomizeContainer = new AdminCustomizeContainer(appContainer);
 const adminUsersContainer = new AdminUsersContainer(appContainer);
 const adminExternalAccountsContainer = new AdminExternalAccountsContainer(appContainer);
-const adminMarkDownContainer = new MarkDownSettingContainer(appContainer);
+const adminMarkDownContainer = new AdminMarkDownContainer(appContainer);
 const adminContainers = {
   'admin-customize': adminCustomizeContainer,
   'admin-user-page': adminUsersContainer,

+ 65 - 94
src/server/routes/apiv3/customize-setting.js

@@ -21,50 +21,48 @@ const ErrorV3 = require('../../models/vo/error-apiv3');
  *
  *  components:
  *    schemas:
- *      CustomizeParams:
+ *      CustomizeLayoutTheme:
  *        type: object
- *          CustomizeLayoutTheme:
- *            type: object
- *              layoutType:
- *                type: string
- *              themeType:
- *                type: string
- *          CustomizeBehavior:
- *            type: object
- *              behaviorType
- *                type: string
- *          CustomizeFunction:
- *            type: object
- *              isEnabledTimeline:
- *                type: boolean
- *              isSavedStatesOfTabChanges:
- *                type: boolean
- *              isEnabledAttachTitleHeader:
- *                type: boolean
- *              recentCreatedLimit:
- *                type: number
- *          CustomizeHighlight:
- *            type: object
- *              styleName:
- *                type: string
- *              styleBorder:
- *                type: boolean
- *          CustomizeTitle:
- *            type: object
- *              customizeTitle:
- *                type: string
- *          CustomizeHeader:
- *            type: object
- *              customizeHeader:
- *                type: string
- *          CustomizeCss:
- *            type: object
- *              customizeCss:
- *                type: string
- *          CustomizeScript:
- *            type: object
- *              customizeScript:
- *                type: string
+ *          layoutType:
+ *            type: string
+ *          themeType:
+ *            type: string
+ *      CustomizeBehavior:
+ *        type: object
+ *          behaviorType
+ *            type: string
+ *      CustomizeFunction:
+ *        type: object
+ *          isEnabledTimeline:
+ *            type: boolean
+ *          isSavedStatesOfTabChanges:
+ *            type: boolean
+ *          isEnabledAttachTitleHeader:
+ *            type: boolean
+ *          recentCreatedLimit:
+ *            type: number
+ *      CustomizeHighlight:
+ *        type: object
+ *          styleName:
+ *            type: string
+ *          styleBorder:
+ *            type: boolean
+ *      CustomizeTitle:
+ *        type: object
+ *          customizeTitle:
+ *            type: string
+ *      CustomizeHeader:
+ *        type: object
+ *          customizeHeader:
+ *            type: string
+ *      CustomizeCss:
+ *        type: object
+ *          customizeCss:
+ *            type: string
+ *      CustomizeScript:
+ *        type: object
+ *          customizeScript:
+ *            type: string
  */
 module.exports = (crowi) => {
   const loginRequiredStrictly = require('../../middleware/login-required')(crowi);
@@ -124,9 +122,14 @@ module.exports = (crowi) => {
    *            content:
    *              application/json:
    *                schema:
-   *                  properties:
-   *                    customizedParams:
-   *                      $ref: '#/components/schemas/CustomizeParams'
+   *                  $ref: '#/components/schemas/CustomizeLayoutTheme'
+   *                  $ref: '#/components/schemas/CustomizeBehavior'
+   *                  $ref: '#/components/schemas/CustomizeFunction'
+   *                  $ref: '#/components/schemas/CustomizeHighlight'
+   *                  $ref: '#/components/schemas/CustomizeTitle'
+   *                  $ref: '#/components/schemas/CustomizeHeader'
+   *                  $ref: '#/components/schemas/CustomizeCss'
+   *                  $ref: '#/components/schemas/CustomizeScript'
    */
   router.get('/', loginRequiredStrictly, adminRequired, async(req, res) => {
 
@@ -161,18 +164,14 @@ module.exports = (crowi) => {
    *          content:
    *            application/json:
    *              schama:
-   *                type: object
-   *                properties:
-   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeLayoutTheme'
+   *                $ref: '#/components/schemas/CustomizeLayoutTheme'
    *      responses:
    *        200:
    *          description: Succeeded to update layout and theme
    *          content:
    *            application/json:
    *              schema:
-   *                type: object
-   *                properties:
-   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeLayoutTheme'
+   *                $ref: '#/components/schemas/CustomizeLayoutTheme'
    */
   router.put('/layoutTheme', loginRequiredStrictly, adminRequired, csrf, validator.layoutTheme, ApiV3FormValidator, async(req, res) => {
     const requestParams = {
@@ -207,18 +206,14 @@ module.exports = (crowi) => {
    *          content:
    *            application/json:
    *              schama:
-   *                type: object
-   *                properties:
-   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeBehavior'
+   *                $ref: '#/components/schemas/CustomizeBehavior'
    *      responses:
    *        200:
    *          description: Succeeded to update behavior
    *          content:
    *            application/json:
    *              schema:
-   *                type: object
-   *                properties:
-   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeBehavior'
+   *                $ref: '#/components/schemas/CustomizeBehavior'
    */
   router.put('/behavior', loginRequiredStrictly, adminRequired, csrf, validator.behavior, ApiV3FormValidator, async(req, res) => {
     const requestParams = {
@@ -251,18 +246,14 @@ module.exports = (crowi) => {
    *          content:
    *            application/json:
    *              schama:
-   *                type: object
-   *                properties:
-   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeFunction'
+   *                $ref: '#/components/schemas/CustomizeFunction'
    *      responses:
    *        200:
    *          description: Succeeded to update function
    *          content:
    *            application/json:
    *              schema:
-   *                type: object
-   *                properties:
-   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeFunction'
+   *                $ref: '#/components/schemas/CustomizeFunction'
    */
   router.put('/function', loginRequiredStrictly, adminRequired, csrf, validator.function, ApiV3FormValidator, async(req, res) => {
     const requestParams = {
@@ -301,18 +292,14 @@ module.exports = (crowi) => {
    *          content:
    *            application/json:
    *              schama:
-   *                type: object
-   *                properties:
-   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeHighlight'
+   *                $ref: '#/components/schemas/CustomizeHighlight'
    *      responses:
    *        200:
    *          description: Succeeded to update highlight
    *          content:
    *            application/json:
    *              schema:
-   *                type: object
-   *                properties:
-   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeHighlight'
+   *                $ref: '#/components/schemas/CustomizeHighlight'
    */
   router.put('/highlight', loginRequiredStrictly, adminRequired, csrf, validator.highlight, ApiV3FormValidator, async(req, res) => {
     const requestParams = {
@@ -347,18 +334,14 @@ module.exports = (crowi) => {
    *          content:
    *            application/json:
    *              schema:
-   *                type: object
-   *                properties:
-   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeTitle'
+   *                $ref: '#/components/schemas/CustomizeTitle'
    *      responses:
    *        200:
    *          description: Succeeded to update customizeTitle
    *          content:
    *            application/json:
    *              schema:
-   *                type: object
-   *                properties:
-   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeTitle'
+   *                $ref: '#/components/schemas/CustomizeTitle'
    */
   router.put('/customize-title', loginRequiredStrictly, adminRequired, csrf, validator.customizeTitle, ApiV3FormValidator, async(req, res) => {
     const requestParams = {
@@ -392,18 +375,14 @@ module.exports = (crowi) => {
    *          content:
    *            application/json:
    *              schama:
-   *                type: object
-   *                properties:
-   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeHeader'
+   *                $ref: '#/components/schemas/CustomizeHeader'
    *      responses:
    *        200:
    *          description: Succeeded to update customize header
    *          content:
    *            application/json:
    *              schema:
-   *                type: object
-   *                properties:
-   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeHeader'
+   *                $ref: '#/components/schemas/CustomizeHeader'
    */
   router.put('/customize-header', loginRequiredStrictly, adminRequired, csrf, validator.customizeHeader, ApiV3FormValidator, async(req, res) => {
     const requestParams = {
@@ -435,18 +414,14 @@ module.exports = (crowi) => {
    *          content:
    *            application/json:
    *              schama:
-   *                type: object
-   *                properties:
-   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeCss'
+   *                $ref: '#/components/schemas/CustomizeCss'
    *      responses:
    *        200:
    *          description: Succeeded to update customize css
    *          content:
    *            application/json:
    *              schema:
-   *                type: object
-   *                properties:
-   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeCss'
+   *                $ref: '#/components/schemas/CustomizeCss'
    */
   router.put('/customize-css', loginRequiredStrictly, adminRequired, csrf, validator.customizeCss, ApiV3FormValidator, async(req, res) => {
     const requestParams = {
@@ -479,18 +454,14 @@ module.exports = (crowi) => {
    *          content:
    *            application/json:
    *              schama:
-   *                type: object
-   *                properties:
-   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeScript'
+   *                $ref: '#/components/schemas/CustomizeScript'
    *      responses:
    *        200:
    *          description: Succeeded to update customize script
    *          content:
    *            application/json:
    *              schema:
-   *                type: object
-   *                properties:
-   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeScript'
+   *                $ref: '#/components/schemas/CustomizeScript'
    */
   router.put('/customize-script', loginRequiredStrictly, adminRequired, csrf, validator.customizeScript, ApiV3FormValidator, async(req, res) => {
     const requestParams = {

+ 3 - 3
src/server/routes/apiv3/markdown-setting.js

@@ -38,8 +38,6 @@ const validator = {
  *
  *  components:
  *    schemas:
- *      CustomizeParams:
- *        type: object
  *      LineBreakParams:
  *        type: object
  *        properties:
@@ -103,7 +101,9 @@ module.exports = (crowi) => {
    *                schema:
    *                  properties:
    *                    markdonwParams:
-   *                      $ref: '#/components/schemas/CustomizeParams'
+   *                      $ref: '#/components/schemas/LineBreakParams'
+   *                      $ref: '#/components/schemas/PresentationParams'
+   *                      $ref: '#/components/schemas/XssParams'
    */
   router.get('/', loginRequiredStrictly, adminRequired, async(req, res) => {
     const markdownParams = {