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

Use serializers for simple informational views like "metadata" views #283

Open
AlanCoding opened this issue Apr 8, 2024 · 1 comment
Open
Labels
app:resource_registry enhancement New feature or request ready to work Item is ready to be worked on

Comments

@AlanCoding
Copy link
Member

Some background in #276

With the latest changes (speculative) I still have the schema outputting this:

        "/service-index/": {
            "get": {
                "operationId": "service_index_retrieve",
                "description": "Link other resource registry endpoints",
                "tags": [
                    "service-index"
                ],
                "security": [
                    {
                        "cookieAuth": []
                    },
                    {
                        "basicAuth": []
                    },
                    {
                        "jwtAuth": []
                    },
                    {
                        "EDAJWTAuthentication": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "No response body"
                    }
                }
            }
        },
        "/service-index/metadata/": {
            "get": {
                "operationId": "service_index_metadata_retrieve",
                "tags": [
                    "service-index"
                ],
                "security": [
                    {
                        "cookieAuth": []
                    },
                    {
                        "basicAuth": []
                    },
                    {
                        "jwtAuth": []
                    },
                    {
                        "EDAJWTAuthentication": []
                    }
                ],
                "responses": {
                    "200": {
                        "description": "No response body"
                    }
                }
            }
        },

This isn't correct / complete, and it can't be unless the view uses a serializer. In these cases, the serializer would just be filled with read-only fields. It would do the same thing it does not, but using the serializer would allow OPTIONS to show the expected keys, and would allow OpenAPI spec to provide information about the format of the response.

@AlanCoding
Copy link
Member Author

I'm not saying this is my best work, but you can see

https://github.com/ansible/django-ansible-base/blob/devel/ansible_base/rbac/api/views.py#L48

but RoleMetadataView does the basics of what is asked for here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app:resource_registry enhancement New feature or request ready to work Item is ready to be worked on
Projects
None yet
Development

No branches or pull requests

1 participant