docusaurus-openapi-docs icon indicating copy to clipboard operation
docusaurus-openapi-docs copied to clipboard

Using $ref for primitive types erases the field type

Open AchrafAmil opened this issue 1 year ago • 2 comments

Documentation link

https://docs.nabla.com

Describe the problem

When declaring a field like the following:

email:
  $ref: "./shared/user_email.yaml"

While user_email.yaml is:

type: string
description: Some long description for what a user email is used for etc etc etc... The same "email" field is reused in multiple endpoints (to share the description).

The output is:

image

While I expect it to be (same as if the $ref was inlined):

image

Suggested fix

Instead of: always assuming a $ref is referencing a complex object and thus giving its type a "name" (picking the file name is ok) while the rest of the doc-gen will indent the nested fields and everything is well-documented. I suggest the doc-gen code to first checks if the referenced type is a primitive (string, boolean, or number) and if so lets its type name be the primitive type itself.

AchrafAmil avatar Feb 01 '24 13:02 AchrafAmil

I think this should be labeled as a bug. I'm having the same issue, any references to strings display the referenced name as the format instead of string as the format.

@AchrafAmil are you able to change the label of your issue from "documentation" to "bug"?

cdstull avatar Feb 22 '24 08:02 cdstull

I agree but I can't change labels

AchrafAmil avatar Feb 22 '24 11:02 AchrafAmil

upgraded to 2.1.3 and this is fixed: it shows file name (primitive type) (e.g. user_email (string)).

AchrafAmil avatar May 10 '24 12:05 AchrafAmil