dotnet icon indicating copy to clipboard operation
dotnet copied to clipboard

Structurizr JsonWriter produces a file different from the one downloaded from the one downloaded from the https://structurizr.com/

Open alexey-aurea opened this issue 4 years ago • 9 comments

The json file downloaded from the web seems to have more information than the one which could be obtained using the API. Can this issue be fixed please and either or of those sources changed to match the other ?

alexey-aurea avatar Feb 17 '20 23:02 alexey-aurea

When you say "more information" ... what's missing?

simonbrowndotje avatar Feb 18 '20 01:02 simonbrowndotje

Feel free to run debug on https://structurizr.com/share/47754

if you compare 2 json files, the following sections a missing from the web json: Workspace is missing "lastModifiedUser", "lastModifiedAgent", "configuration"

And with the deep compare we got (Expected is the web json compared with api one) Expected pair[model][people][0] to be a dictionary with 8 item(s), but it misses key(s) {"properties", "perspectives"} Expected pair[model][people][1] to be a dictionary with 8 item(s), but it misses key(s) {"properties", "perspectives"} Expected pair[model][softwareSystems][0] to be a dictionary with 8 item(s), but it misses key(s) {"containers", "properties", "perspectives"} and has additional key(s) {"location"} Expected pair[model][softwareSystems][1] to be a dictionary with 8 item(s), but it misses key(s) {"containers", "relationships", "properties", "perspectives"} and has additional key(s) {"location"} Expected pair[model][softwareSystems][2] to be a dictionary with 8 item(s), but it misses key(s) {"properties", "perspectives"} and has additional key(s) {"location"} Expected pair[model][softwareSystems][3] to be a dictionary with 8 item(s), but it misses key(s) {"containers", "relationships", "properties", "perspectives"} and has additional key(s) {"location"} Expected pair[model][deploymentNodes][0] to be a dictionary with 12 item(s), but it misses key(s) {"relationships", "properties", "perspectives"} Expected pair[model][deploymentNodes][1] to be a dictionary with 12 item(s), but it misses key(s) {"relationships", "properties", "perspectives"} Expected pair[model][deploymentNodes][2] to be a dictionary with 12 item(s), but it misses key(s) {"relationships", "properties", "perspectives"} Expected pair[model][deploymentNodes][3] to be a dictionary with 12 item(s), but it misses key(s) {"relationships", "properties", "perspectives"} Expected pair[views][systemContextViews][0][elements][0] to be a dictionary with 4 item(s), but it misses key(s) {"properties"} Expected pair[views][systemContextViews][0][elements][1] to be a dictionary with 4 item(s), but it misses key(s) {"properties"} Expected pair[views][systemContextViews][0][elements][2] to be a dictionary with 4 item(s), but it misses key(s) {"properties"} Expected pair[views][systemContextViews][0][elements][3] to be a dictionary with 4 item(s), but it misses key(s) {"properties"} Expected pair[views][systemContextViews][0][elements][4] to be a dictionary with 4 item(s), but it misses key(s) {"properties"} Expected pair[views][systemContextViews][0][elements][5] to be a dictionary with 4 item(s), but it misses key(s) {"properties"} Expected pair[views][systemContextViews][0][relationships][0] to be a dictionary with 2 item(s), but it misses key(s) {"properties"} Expected pair[views][systemContextViews][0][relationships][1] to be a dictionary with 2 item(s), but it misses key(s) {"properties"} Expected pair[views][systemContextViews][0][relationships][2] to be a dictionary with 2 item(s), but it misses key(s) {"properties"} Expected pair[views][systemContextViews][0][relationships][3] to be a dictionary with 2 item(s), but it misses key(s) {"properties"} Expected pair[views][systemContextViews][0][relationships][4] to be a dictionary with 2 item(s), but it misses key(s) {"properties"} Expected pair[views][systemContextViews][0][relationships][5] to be a dictionary with 3 item(s), but it misses key(s) {"properties"} Expected pair[views][systemContextViews][0][relationships][6] to be a dictionary with 3 item(s), but it misses key(s) {"properties"} Expected pair[views][systemContextViews][0][relationships][7] to be a dictionary with 2 item(s), but it misses key(s) {"properties"} Expected pair[views][containerViews][0][elements][0] to be a dictionary with 4 item(s), but it misses key(s) {"properties"} Expected pair[views][containerViews][0][elements][1] to be a dictionary with 4 item(s), but it misses key(s) {"properties"} Expected pair[views][containerViews][0][elements][2] to be a dictionary with 4 item(s), but it misses key(s) {"properties"} Expected pair[views][containerViews][0][elements][3] to be a dictionary with 4 item(s), but it misses key(s) {"properties"} Expected pair[views][containerViews][0][elements][4] to be a dictionary with 4 item(s), but it misses key(s) {"properties"} Expected pair[views][containerViews][0][elements][5] to be a dictionary with 4 item(s), but it misses key(s) {"properties"} Expected pair[views][containerViews][0][elements][6] to be a dictionary with 4 item(s), but it misses key(s) {"properties"} Expected pair[views][containerViews][0][elements][7] to be a dictionary with 4 item(s), but it misses key(s) {"properties"} Expected pair[views][containerViews][0][elements][8] to be a dictionary with 4 item(s), but it misses key(s) {"properties"} Expected pair[views][containerViews][0][elements][9] to be a dictionary with 4 item(s), but it misses key(s) {"properties"} Expected pair[views][containerViews][0][relationships][0] to be a dictionary with 2 item(s), but it misses key(s) {"properties"} Expected pair[views][containerViews][0][relationships][1] to be a dictionary with 2 item(s), but it misses key(s) {"properties"} Expected pair[views][containerViews][0][relationships][2] to be a dictionary with 3 item(s), but it misses key(s) {"properties"} Expected pair[views][containerViews][0][relationships][3] to be a dictionary with 3 item(s), but it misses key(s) {"properties"} Expected pair[views][containerViews][0][relationships][4] to be a dictionary with 2 item(s), but it misses key(s) {"properties"} Expected pair[views][containerViews][0][relationships][5] to be a dictionary with 2 item(s), but it misses key(s) {"properties"} Expected pair[views][containerViews][0][relationships][6] to be a dictionary with 3 item(s), but it misses key(s) {"properties"} Expected pair[views][containerViews][0][relationships][7] to be a dictionary with 2 item(s), but it misses key(s) {"properties"} Expected pair[views][containerViews][0][relationships][8] to be a dictionary with 2 item(s), but it misses key(s) {"properties"} Expected pair[views][containerViews][0][relationships][9] to be a dictionary with 3 item(s), but it misses key(s) {"properties"} Expected pair[views][componentViews][0] to be a dictionary with 8 item(s), but it misses key(s) {"softwareSystemId"} Expected pair[views][componentViews][1] to be a dictionary with 8 item(s), but it misses key(s) {"softwareSystemId"} Expected pair[views][componentViews][2] to be a dictionary with 8 item(s), but it misses key(s) {"softwareSystemId"} Expected pair[views][componentViews][3] to be a dictionary with 8 item(s), but it misses key(s) {"softwareSystemId"} Expected pair[views][componentViews][4] to be a dictionary with 8 item(s), but it misses key(s) {"softwareSystemId"} Expected pair[views][componentViews][5] to be a dictionary with 8 item(s), but it misses key(s) {"softwareSystemId"} Expected pair[views][deploymentViews][0] to be a dictionary with 5 item(s), but has additional key(s) {"environment"} Expected pair[views][configuration] to be a dictionary with 5 item(s), but it misses key(s) {"viewSortOrder"} Expected pair[lastModifiedDate] to be <2020-02-18 10:24:36>, but found <2020-02-17 07:34:59>. Expected pair[revision] to be 320L, but found 319L.

alexey-aurea avatar Feb 18 '20 04:02 alexey-aurea

The following seems to suggest that you're comparing the JSON documents for two different workspaces, which is why you're seeing so many deep comparison differences:

Expected pair[id] to be 48532L, but found 47754L.

That aside, there will be some minor differences in the JSON created by the Structurizr .NET library vs that returned via the web API. The reasons for this include:

  • The web API is written using Java, and uses the Structurizr for Java client library for JSON serialisation. Since there are no guarantees on element ordering in JSON, both libraries might do ordering slightly differently.
  • The Structurizr cloud service will modify some of the workspace metadata (e.g. last modified date/agent/user), so you'll see that being different too.

If you compare the JSON document created by the Structurizr .NET library with the version returned by the web API, for the same workspace, the JSON documents should mostly be semantically the same.

simonbrowndotje avatar Feb 18 '20 11:02 simonbrowndotje

Yes, sorry, you are correct. I have updated the report. Our main concern is 'locations' and 'environment' are missing from API json. Any way to fix that ?

alexey-aurea avatar Feb 18 '20 23:02 alexey-aurea

Let me know which objects these properties belong to, and I'll take a look.

simonbrowndotje avatar Feb 19 '20 01:02 simonbrowndotje

environment>> workspace.views.deploymentViews.item location >> model.softwareSystems.item

alexey-aurea avatar Feb 19 '20 01:02 alexey-aurea

Both properties will now be outputted when the default/empty values are set.

simonbrowndotje avatar Feb 19 '20 02:02 simonbrowndotje

Thanks!

alexey-aurea avatar Feb 19 '20 03:02 alexey-aurea

Could you please also add an integration test to make sure such deviations won't happen in the future ?

alexey-aurea avatar Feb 19 '20 04:02 alexey-aurea