Skip to content
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

@Schema applied to two getters of type JsonNode returns one definition only #4697

Open
marco-brandizi opened this issue Jun 12, 2024 · 0 comments

Comments

@marco-brandizi
Copy link

I'm trying to document the following class, which is returned by a Spring-based API:

public class CytoscapeJsWrapper
{
...  

  @Schema ( description = 
    """
    As per Cytoscape.js, this contains a 'data' element, containing node properties 
    (eg, id, type, label, and a few others). See /graphDetails for more information.      
    """
  )
  public JsonNode getNodes ()
  {
    return nodes;
  }

  @Schema ( description = 
    """
    Same as /elements/nodes, with the addition of the 'source' and 'target' properties.
    """
  )
  public JsonNode getEdges ()
  {
    return edges;
  }
  
}

The generated OpenAPI I can see at http://localhost:8080/v3/api-docs/v1:

...
"CytoscapeJsWrapper": {
  "type": "object",
  "properties": {
    "nodes": {
      "$ref": "#/components/schemas/JsonNode"
    },
    "edges": {
      "$ref": "#/components/schemas/JsonNode"
    }
  },
  "description": "The graph obtained from merging all the resulting semantic motif paths..."
}
...

And only one JsonNode definition in the components section:

...
"JsonNode": {
        "type": "object",
        "description": "Same as /elements/nodes, with the addition of the 'source' and 'target' properties.\n"
      }
...

While it should apply both the @Schema annotations and describe the two different fields properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant