Repository navigation
Formatting of annotations and annotation attributes has room for improvements #366
Copy link
Copy link
Open
Description
The formatting of annotations and annotation attributes makes the code more difficult to read in my opinion.
Example below.
Relates #78
post-apply:
package com.example.api;
import io.swagger.v3.oas.annotations.ExternalDocumentation;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Contact;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.info.License;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.servers.Server;
import io.swagger.v3.oas.annotations.servers.ServerVariable;
import io.swagger.v3.oas.annotations.tags.Tag;
@OpenAPIDefinition(
info = @Info(title = "the title", version = "0.0", description = "My API",
license = @License(name = "Apache 2.0", url = "http://foo.bar"),
contact = @Contact(url = "http://gigantic-server.com", name = "Fred",
email = "Fred@gigagantic-server.com")),
tags = { @Tag(name = "Tag 1", description = "desc 1",
externalDocs = @ExternalDocumentation(description = "docs desc")),
@Tag(name = "Tag 2", description = "desc 2",
externalDocs = @ExternalDocumentation(description = "docs desc 2")),
@Tag(name = "Tag 3") },
externalDocs = @ExternalDocumentation(description = "definition docs desc"),
security = { @SecurityRequirement(name = "req 1", scopes = { "a", "b" }),
@SecurityRequirement(name = "req 2", scopes = { "b", "c" }) },
servers = { @Server(description = "server 1", url = "http://foo",
variables = {
@ServerVariable(name = "var1", description = "var 1", defaultValue = "1",
allowableValues = { "1", "2" }),
@ServerVariable(name = "var2", description = "var 2", defaultValue = "1",
allowableValues = { "1", "2" }) }) })
public class OpenAPI {
}
My opinion is that something like this is more readable as the indent is lineup and not like stair:
package com.example.api;
import io.swagger.v3.oas.annotations.ExternalDocumentation;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Contact;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.info.License;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.servers.Server;
import io.swagger.v3.oas.annotations.servers.ServerVariable;
import io.swagger.v3.oas.annotations.tags.Tag;
@OpenAPIDefinition(
info = @Info(
title = "the title",
version = "0.0",
description = "My API",
license = @License(name = "Apache 2.0", url = "http://foo.bar"),
contact = @Contact(url = "http://gigantic-server.com", name = "Fred", email = "Fred@gigagantic-server.com")
),
tags = {
@Tag(name = "Tag 1", description = "desc 1", externalDocs = @ExternalDocumentation(description = "docs desc")),
@Tag(name = "Tag 2", description = "desc 2", externalDocs = @ExternalDocumentation(description = "docs desc 2")),
@Tag(name = "Tag 3")
},
externalDocs = @ExternalDocumentation(description = "definition docs desc"),
security = {
@SecurityRequirement(name = "req 1", scopes = {"a", "b"}),
@SecurityRequirement(name = "req 2", scopes = {"b", "c"})
},
servers = {
@Server(
description = "server 1",
url = "http://foo",
variables = {
@ServerVariable(name = "var1", description = "var 1", defaultValue = "1", allowableValues = {"1", "2"}),
@ServerVariable(name = "var2", description = "var 2", defaultValue = "1", allowableValues = {"1", "2"})
})
}
)
public class OpenAPI {
}
Metadata
Metadata
Assignees
Labels
No labels
Activity
philwebb commentedon Feb 23, 2023
I agree that the bottom version is easier to read, but I'm not sure that we want to go back to non-wrapped lines. Perhaps there's some other Eclipse formatter options we can tweak?
jimisola commentedon Feb 25, 2023
What type of formatting are you thinking of if we go back to non-wrapped lines?