asyncapi/html-template

If / then / else blocks generate incomplete document

trsh opened this issue · 8 comments

trsh commented

Describe the bug

If / then / else blocks generate incomplete document

How to Reproduce

Use something like this:

"publish": {
                "summary": "Socket backend API",
                "message": {
                    "name": "Create a lobby/room",
                    "x-CreateRoomPayload-key": "CreateRoomPayload",
                    "payload": {
                        "$schema": "http://json-schema.org/draft-07/schema#",
                        "type": "object",
                        "$id": "CreateRoomPayload",
                        "additionalProperties": false,
                        "required": [
                            "type",
                            "maxPlayers"
                        ],
                        "properties": {
                            "type": {
                                "$id": "RoomType",
                                "enum": [
                                    "private",
                                    "public"
                                ],
                                "type": "string",
                                "description": "Room type"
                            },
                            "secret": {
                                "type": "string",
                                "description": "Password for the room (ignored if public)",
                                "example": "lksadlksladlkksadkl"
                            },
                            "maxPlayers": {
                                "type": "integer",
                                "minimum": 2,
                                "description": "Maximum players who can join",
                                "example": 6
                            }
                        },
                        "if": {
                            "properties": {
                                "type": {
                                    "const": "private"
                                }
                            }
                        },
                        "then": {
                            "required": [
                                "secret"
                            ]
                        }
                    }
                }
            }

Results:

hhhhhhhhhhhhhhhh9

Expected behavior

Something that clearly states, that if type is 'private', secret is required.

trsh commented

Another problem, when using IF (right side example)
rrrrrrrrrrrrrrrr5

This issue has been automatically marked as stale because it has not had recent activity 😴

It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience ❤️

trsh commented

This report is still valid. If nobody cares about issues for this repo, then why leave a github garbage cleaner on?

If nobody cares about issues for this repo, then why leave a github garbage cleaner on?

To remind about issues that have escaped attention ;)

As far as your problem is concerned this should not be a problem in showing required, however, I wonder if there are other JSON Schema keywords that have similar semantic value as required.

As for the example on the right, there is nothing we can do about it, because we are using a simple and lightweight library to generate these exemplars and it only generates the simplest examples, without complex looking at the schemas in if/the/else etc.

trsh commented

As for the example on the right, there is nothing we can do about it, because we are using a simple and lightweight library to generate these exemplars and it only generates the simplest examples, without complex looking at the schemas in if/the/else etc.

Welp maybe there are better options?

There are other libraries, but they add a lot of kilobytes to the final bundle (and use nodeJS core libraries), and this is what we want to avoid, which is why we chose https://github.com/Redocly/openapi-sampler. I'm just wondering why your example only generates type as it should also generate other fields (but without including if/then/else):

image

This issue has been automatically marked as stale because it has not had recent activity 😴

It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience ❤️

This issue has been automatically marked as stale because it has not had recent activity 😴

It will be closed in 120 days if no further activity occurs. To unstale this issue, add a comment with a detailed explanation.

There can be many reasons why some specific issue has no activity. The most probable cause is lack of time, not lack of interest. AsyncAPI Initiative is a Linux Foundation project not owned by a single for-profit company. It is a community-driven initiative ruled under open governance model.

Let us figure out together how to push this issue forward. Connect with us through one of many communication channels we established here.

Thank you for your patience ❤️