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

Hover: Show root property title and description when using anyOf untitled un-described types #952

Open
az0uz opened this issue Feb 29, 2024 · 3 comments

Comments

@az0uz
Copy link

az0uz commented Feb 29, 2024

Is your enhancement related to a problem? Please describe.

When using the language server feature and hovering over a property to get the documentation, I don't get the description of a property if using anyOf:

{
  "properties": {
    "optionalZipFile": {
      "anyOf": [{ "type": "string", "pattern": "\\.zip$" }, { "type": "null" }],
      "description": "Optional ZIP File Path.",
      "title": "Zip file",
      "default": null
    }
  },
  "required": ["optionalZipFile"],
  "title": "My Config File",
  "type": "object"
}
Screenshot 2024-02-29 at 15 46 33

The language server seems to infer the title for both possible types from the property title and show both possibilities.

Describe the solution you would like

Have the same behavior as if we use "type": ["string", "null"] instead of "anyOf"

Screenshot 2024-02-29 at 15 56 34

Describe alternatives you have considered

Alternative is to generate nullable values using "type": ["string", "null"] but it won't work for more complex type like the one with a pattern field.

Additional context

This happens frequently when using pydantic generated schemas and Optional values. pydantic is using anyOf when generating the schema for python optional (nullable) values
https://github.com/pydantic/pydantic/blob/bbf0724722b44113bf8c8e3bd0cf41403a5913e9/pydantic/json_schema.py#L1030

@jirutka
Copy link

jirutka commented Jun 20, 2024

I have the same problem, but since I often don’t specify title in schemas (only markdownDescription), VS Codium shows me just || on hover. However, when I trigger auto-completion on the (YAML) key, it correctly renders the markdownDescription for the key.

Example schema: https://jirutka.github.io/nginx-json-schema/nginx-full.json; can be tested e.g. on proxy_set_header.

@SILJAEUROPA
Copy link

Experiencing the same issue.

@AndreasStautner
Copy link

Also experiencing this issue in combination with pydantic.

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

4 participants