diff --git a/lib/tasks/swagger.rake b/lib/tasks/swagger.rake index 2e5650d42..299e75908 100644 --- a/lib/tasks/swagger.rake +++ b/lib/tasks/swagger.rake @@ -23,8 +23,8 @@ module SwaggerTaskActions logging: true ) - # Add x-mcp property to the final build - final_build['x-mcp'] = { 'enabled' => true } + # Add x-mcp property right after openapi version + final_build = _insert_x_mcp_after_openapi(final_build) File.write(swagger_json_relative_path, JSON.pretty_generate(final_build)) @@ -90,8 +90,8 @@ module SwaggerTaskActions tag_spec['paths'] = _filter_paths_for_tag_group(tag_spec['paths'], tags_in_current_group) tag_spec['tags'] = _filter_tags_for_tag_group(tag_spec['tags'], tags_in_current_group) - # Add x-mcp property to the tag spec - tag_spec['x-mcp'] = { 'enabled' => true } + # Add x-mcp property right after openapi version + tag_spec = _insert_x_mcp_after_openapi(tag_spec) output_filename = _determine_output_filename(group_name) File.write(output_dir.join(output_filename), JSON.pretty_generate(tag_spec)) @@ -142,6 +142,24 @@ module SwaggerTaskActions puts "Warning: Source file #{source_file_path} not found. Skipping symlink for #{File.basename(target_file_path)}." end end + + def _insert_x_mcp_after_openapi(spec) + ordered_spec = {} + + # First add openapi version + ordered_spec['openapi'] = spec['openapi'] if spec.key?('openapi') + + # Then add x-mcp property + ordered_spec['x-mcp'] = { 'enabled' => true } + + # Then add all other properties in their original order + spec.each do |key, value| + next if key == 'openapi' # Skip since we already added it + ordered_spec[key] = value + end + + ordered_spec + end end end diff --git a/swagger/swagger.json b/swagger/swagger.json index 78411fb71..f12786f54 100644 --- a/swagger/swagger.json +++ b/swagger/swagger.json @@ -1,5 +1,8 @@ { "openapi": "3.0.4", + "x-mcp": { + "enabled": true + }, "info": { "title": "Chatwoot", "description": "This is the API documentation for Chatwoot server.", @@ -11851,8 +11854,5 @@ "CSAT Survey Page" ] } - ], - "x-mcp": { - "enabled": true - } + ] } \ No newline at end of file diff --git a/swagger/tag_groups/application_swagger.json b/swagger/tag_groups/application_swagger.json index b48105753..c4f16b686 100644 --- a/swagger/tag_groups/application_swagger.json +++ b/swagger/tag_groups/application_swagger.json @@ -1,5 +1,8 @@ { "openapi": "3.0.4", + "x-mcp": { + "enabled": true + }, "info": { "title": "Chatwoot", "description": "This is the API documentation for Chatwoot server.", @@ -10180,8 +10183,5 @@ "CSAT Survey Page" ] } - ], - "x-mcp": { - "enabled": true - } + ] } \ No newline at end of file diff --git a/swagger/tag_groups/client_swagger.json b/swagger/tag_groups/client_swagger.json index ee76dbaa7..f580f547e 100644 --- a/swagger/tag_groups/client_swagger.json +++ b/swagger/tag_groups/client_swagger.json @@ -1,5 +1,8 @@ { "openapi": "3.0.4", + "x-mcp": { + "enabled": true + }, "info": { "title": "Chatwoot", "description": "This is the API documentation for Chatwoot server.", @@ -4959,8 +4962,5 @@ "CSAT Survey Page" ] } - ], - "x-mcp": { - "enabled": true - } + ] } \ No newline at end of file diff --git a/swagger/tag_groups/other_swagger.json b/swagger/tag_groups/other_swagger.json index 057a327a2..b805a7d4b 100644 --- a/swagger/tag_groups/other_swagger.json +++ b/swagger/tag_groups/other_swagger.json @@ -1,5 +1,8 @@ { "openapi": "3.0.4", + "x-mcp": { + "enabled": true + }, "info": { "title": "Chatwoot", "description": "This is the API documentation for Chatwoot server.", @@ -4366,8 +4369,5 @@ "CSAT Survey Page" ] } - ], - "x-mcp": { - "enabled": true - } + ] } \ No newline at end of file diff --git a/swagger/tag_groups/platform_swagger.json b/swagger/tag_groups/platform_swagger.json index e87440cc4..99cb4f1c9 100644 --- a/swagger/tag_groups/platform_swagger.json +++ b/swagger/tag_groups/platform_swagger.json @@ -1,5 +1,8 @@ { "openapi": "3.0.4", + "x-mcp": { + "enabled": true + }, "info": { "title": "Chatwoot", "description": "This is the API documentation for Chatwoot server.", @@ -5139,8 +5142,5 @@ "CSAT Survey Page" ] } - ], - "x-mcp": { - "enabled": true - } + ] } \ No newline at end of file