You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

API Blueprint中资源组下方添加纯文本标题遇语义问题求助

Answer

Yep, this is a known implicit rule in API Blueprint that catches many users off guard—your observation about the discrepancy between working headers above groups and broken ones below is exactly right.

Why this happens

API Blueprint’s parser (like Drafter, which powers tools like Apiary) enforces strict semantic hierarchy after a # Group <Name> declaration. After defining a group, the parser expects only:

  • A nested sub-group (## Group <Subgroup Name>)
  • A resource definition (## <Resource Name> [URI])
  • A schema/definition block (# <Definition Name>)

Plain text headers (like ## Some Section Title) don’t fit into these allowed categories, hence the "unexpected header block" error you’re seeing. The official docs mention grouping behavior but omit this specific restriction because it’s tied to the parser’s strict grammar rules.

Solutions to work around this

You have a few options to structure your content properly without ditching your intended organization:

  1. Use group descriptions for context
    If the text was meant to explain the group’s purpose, just add it directly below the group header (no extra heading needed). The parser will treat this as the group’s descriptive text and render it correctly:

    # Group User Management
    This section covers all APIs for user account operations—including creation, updates, and deletion.
    
    ## User [/users/{id}]
    ### GET
    Retrieve a single user by ID.
    
  2. Nested sub-groups for sectioning
    If you need to split a group into sub-sections, use nested sub-groups instead of plain text headers. This fits the parser’s grammar and maintains your hierarchical structure:

    # Group User Management
    ## Group User Creation
    ### Create User [POST /users]
    Create a new user account.
    
    ## Group User Modification
    ### Update User [PUT /users/{id}]
    Update an existing user’s details.
    
  3. Relocate plain text headers (last resort)
    If you absolutely need to keep plain text headers as-is, you’ll have to move them above all resource groups, since the parser allows free-form content (including headers) before the first # Group declaration.

Wrap-up

Unfortunately, there’s no way to force plain text headers directly under a resource group while adhering to API Blueprint’s semantic rules—you’ll need to use one of the workarounds above to keep your document valid and properly rendered.

内容的提问来源于stack exchange,提问作者Nathaniel Lindsey

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 08:22:59