Skip to content

Conversation

@ctII
Copy link

@ctII ctII commented Sep 6, 2024

This change runs jq to format the openapi.json to remove extra white spacing and generally format the original spec to consistent formatting

Then moves the InternalServerError to the components/responses section that is referenced in the already written api endpoints, instead of schemas/responses

Then fixes the reference to SuggestionComment

This resolves all errors that https://editor.swagger.io/ shows when using the openapi.json

swagger editor errors:

Semantic error at paths./cwe/version.get.responses.500.$ref
$refs must reference a valid location in the document

Semantic error at paths./cwe/{id(s)}.get.responses.500.$ref
$refs must reference a valid location in the document

Semantic error at paths./cwe/weakness/{id(s)}.get.responses.500.$ref
$refs must reference a valid location in the document

Semantic error at paths./cwe/category/{id(s)}.get.responses.500.$ref
$refs must reference a valid location in the document

Semantic error at paths./cwe/view/{id(s)}.get.responses.500.$ref
$refs must reference a valid location in the document

Semantic error at paths./cwe/{id}/parents.get.responses.500.$ref
$refs must reference a valid location in the document

Semantic error at paths./cwe/{id}/descendants.get.responses.500.$ref
$refs must reference a valid location in the document

Semantic error at paths./cwe/{id}/children.get.responses.500.$ref
$refs must reference a valid location in the document

Semantic error at paths./cwe/{id}/ancestors.get.responses.500.$ref
$refs must reference a valid location in the document

Structural error at components.schemas.MappingNotes.properties.Suggestions
should NOT have additional properties
additionalProperty: #ref

Semantic error at components.schemas.MappingNotes.properties.Suggestions
Schemas with 'type: array', require a sibling 'items: ' field

Structural error at components.schemas.responses
should NOT have additional properties
additionalProperty: InternalServerError

actual difference excluding the general formatting changes

cat openapi-original.json | jq > openapi-original-formatted.json
diff openapi-original-formatted.json {json file of this change}

out of diff

1273c1273,1275
<             "#ref": "#/components/schema/SuggestionComment"
---
>             "items": {
>               "$ref": "#/components/schemas/SuggestionComment"
>             }
1595,1599c1597,1601
<       },
<       "responses": {
<         "InternalServerError": {
<           "description": "An Internal Server Error occurred"
<         }
---
>       }
>     },
>     "responses": {
>       "InternalServerError": {
>         "description": "An Internal Server Error occurred"

@rpiazza
Copy link
Collaborator

rpiazza commented Sep 6, 2024

@ctII - Thanks - is made those changes myself, so I'm closing this MR. You should be able to pull and get exactly what you proposed.

@rpiazza rpiazza closed this Sep 6, 2024
@ctII
Copy link
Author

ctII commented Sep 6, 2024

@ctII - Thanks - is made those changes myself, so I'm closing this MR. You should be able to pull and get exactly what you proposed.

This is not completely correct, since this PR also included formatting the JSON using jq to fix formatting inconsistencies in the spec file

For example line 173, while correct JSON, is not consistent formatting. This doesn't break any parsers, but makes it more difficult to read manually. Not to mention the formatted JSON spec file is actually smaller than the unformatted version

"$ref": "#/components/schemas/Category" }

@rpiazza
Copy link
Collaborator

rpiazza commented Sep 6, 2024

I'll look into it

@rpiazza rpiazza reopened this Sep 6, 2024
@ctII ctII closed this Sep 6, 2024
@ctII ctII deleted the patch-1 branch September 6, 2024 20:43
@ctII
Copy link
Author

ctII commented Sep 6, 2024

PR #3 has been opened that is solely the formatting aspect of this PR

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.

2 participants