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

[CIN-2018]: specify data types with non annotated properties #863

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kamilbochno
Copy link
Collaborator

@kamilbochno kamilbochno commented Feb 26, 2025

Screenshot 2025-02-26 143811

After updating schema from Ingestion API side, all tests including OpenApi schema test are now passing

"ALLOW_ACCESS": {"value": ["GROUP_EVERYONE"]},
"DENY_ACCESS": {"value": []}
"ALLOW_ACCESS": {"type": "string", "value": ["GROUP_EVERYONE"]},
"DENY_ACCESS": {"type": "string", "value": []}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to remove these empty arrays (as discussed).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to an empty string in the array and now it is the same as the OpenApi schema after update of data types and the tests pass


private void writeType(JsonGenerator jgen, String name, Object value) throws IOException
{
if ("cm:content".equals(name))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should work via the value instead. cm:content will always be a file reference if it's present.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to value-based check

@kamilbochno kamilbochno force-pushed the CIN-2018-specify-data-types-with-non-annotated-properties-when-sending-changes-to-ingest-api-new branch from 5953146 to 0da78a5 Compare February 26, 2025 12:22
@kamilbochno kamilbochno force-pushed the CIN-2018-specify-data-types-with-non-annotated-properties-when-sending-changes-to-ingest-api-new branch from 0bad124 to 38ee291 Compare February 26, 2025 13:58
@PWS-TE
Copy link
Collaborator

PWS-TE commented Mar 4, 2025

Looks 🆗

{
type = "float";
}
else
Copy link
Member

@tpage-alfresco tpage-alfresco Mar 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should also cope with collections. You could refactor this to extract a function:

    private String selectTypeByValue(Object value)
    {
        if (value instanceof Boolean)
            ...
        else if (value instanceof Collection collection)
        {
            if (collection.isEmpty())
            {
                // This should not happen because empty collections should already be filtered out.
                throw new ...;
            }
            return selectTypeByValue(collection.stream().findAny());
        }
        // Default to string.
        return "string";
    }

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

Successfully merging this pull request may close these issues.

3 participants