This is an automated email from the ASF dual-hosted git repository.
jamesbognar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/juneau.git
The following commit(s) were added to refs/heads/master by this push:
new eba11e8a54 SonarQube bug fixes
eba11e8a54 is described below
commit eba11e8a54d391a8463e0a778aadd23d05736216
Author: James Bognar <[email protected]>
AuthorDate: Thu Feb 5 12:18:18 2026 -0500
SonarQube bug fixes
---
@AI_CONTINUE.md | 95 ++++++++
SONARQUBE_CLEANUP_PLAN.md | 253 +++++++++++++++++++++
.../apache/juneau/annotation/SchemaAnnotation.java | 155 ++++++++-----
.../juneau/annotation/SubItemsAnnotation.java | 56 +++--
.../org/apache/juneau/httppart/HttpPartSchema.java | 234 ++++++++++---------
.../jsonschema/JsonSchemaGeneratorSession.java | 43 ++--
6 files changed, 638 insertions(+), 198 deletions(-)
diff --git a/@AI_CONTINUE.md b/@AI_CONTINUE.md
new file mode 100644
index 0000000000..cdbb0d3f2f
--- /dev/null
+++ b/@AI_CONTINUE.md
@@ -0,0 +1,95 @@
+# SonarQube Duplicated String Literals Cleanup - Continuation Guide
+
+## Current Status
+
+We are working on addressing SonarQube issues related to duplicated string
literals (`java:S1192` rule). A comprehensive cleanup plan has been created and
saved in `SONARQUBE_CLEANUP_PLAN.md`.
+
+## What We've Done
+
+1. **Analyzed SonarQube Issues**: Reviewed a list of duplicated string literal
issues from SonarQube
+2. **Identified False Positives**: Found that many issues are already fixed -
constants exist and are being used in:
+ - `SchemaInfo.java` (both OpenAPI v3 and Swagger v2 versions)
+ - `HeaderInfo.java`, `Items.java`, `ParameterInfo.java` (Swagger v2)
+ - `Response.java` (OpenAPI v3), `ResponseInfo.java` (Swagger v2)
+ - `Server.java`, `SecurityRequirement.java`, `MediaType.java` (OpenAPI v3)
+3. **Identified Legitimate Issues**: Found that `HttpPartSchema.java` has
constants defined but they're not being used everywhere
+4. **Created Cleanup Plan**: Documented all findings in
`SONARQUBE_CLEANUP_PLAN.md` with categorized issues and suggestions
+
+## Key Findings
+
+### False Positives (Already Fixed)
+Most property name issues in the `juneau-bean` module are false positives.
Constants like `PROP_additionalProperties`, `PROP_allOf`, `PROP_anyOf`, etc.
already exist and are being used in `get()` and `keySet()` methods. SonarQube
line numbers may be outdated.
+
+### Legitimate Issues Found
+
+**Priority 1: HttpPartSchema.java**
+- **File**:
`/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java`
+- **Status**: Constants exist (lines 92-107) but are NOT being used everywhere
+- **Issues**:
+ - Missing `PROP_uniqueItems` constant (line ~108 needs to be added)
+ - String literals still used in `addIf()` calls (lines ~3758-3843)
+ - String literals still used in validation code (lines ~4202-4221)
+- **Fix Needed**:
+ 1. Add `PROP_uniqueItems = "uniqueItems"` constant
+ 2. Replace all string literals with existing `PROP_*` constants
+
+**Other Categories** (documented in plan):
+- UI files (CSS class names)
+- HTML parser/serializer (HTML tag names)
+- Error messages
+- Example/test data
+- Script files (Python)
+- Reflection property names
+- HTTP methods
+- Console commands
+- JSON schema types
+- Character encoding
+
+## Next Steps
+
+### Immediate Action (High Priority)
+1. **Fix HttpPartSchema.java**:
+ - Add missing `PROP_uniqueItems` constant after line 107
+ - Replace string literal `"uniqueItems"` on line 2696 with
`PROP_uniqueItems`
+ - Replace all string literals in `addIf()` calls (lines ~3758-3843) with
constants
+ - Replace string literals in validation code (lines ~4202-4221) with
constants
+
+### Follow-up Actions
+2. **Remove False Positives from SonarQube**: Mark issues in SchemaInfo.java,
HeaderInfo.java, etc. as resolved/false positives
+3. **Fix Other Categories**: Work through remaining categories in
`SONARQUBE_CLEANUP_PLAN.md` based on priority
+
+## Files to Reference
+
+- **Plan Document**: `SONARQUBE_CLEANUP_PLAN.md` - Contains full details of
all issues and suggestions
+- **Main File to Fix**:
`/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java`
+- **Reference Files** (for pattern examples):
+ -
`/juneau-bean/juneau-bean-openapi-v3/src/main/java/org/apache/juneau/bean/openapi3/SchemaInfo.java`
+ -
`/juneau-bean/juneau-bean-swagger-v2/src/main/java/org/apache/juneau/bean/swagger/SchemaInfo.java`
+
+## Constants Pattern
+
+The codebase uses a consistent pattern for property name constants:
+```java
+private static final String PROP_propertyName = "propertyName";
+```
+
+Examples:
+- `PROP_additionalProperties = "additionalProperties"`
+- `PROP_collectionFormat = "collectionFormat"`
+- `PROP_exclusiveMaximum = "exclusiveMaximum"`
+- etc.
+
+## Notes
+
+- SonarQube line numbers may be outdated after previous refactoring
+- Many issues in `juneau-bean` module are false positives (constants already
exist and are used)
+- `HttpPartSchema.java` is the main file needing fixes - constants exist but
aren't used everywhere
+- The `"value"` literal appears frequently in some files - may be acceptable
to suppress in certain contexts
+
+## How to Continue
+
+1. Read `SONARQUBE_CLEANUP_PLAN.md` for full context
+2. Start with fixing `HttpPartSchema.java` (highest priority)
+3. Test changes to ensure no regressions
+4. Mark false positives as resolved in SonarQube
+5. Continue with remaining categories as needed
diff --git a/SONARQUBE_CLEANUP_PLAN.md b/SONARQUBE_CLEANUP_PLAN.md
new file mode 100644
index 0000000000..4433ec9acb
--- /dev/null
+++ b/SONARQUBE_CLEANUP_PLAN.md
@@ -0,0 +1,253 @@
+# SonarQube Issues Cleanup Plan
+
+## Summary
+After fixing property name literals with constants, we need to:
+1. Remove false positives (issues already fixed)
+2. Categorize remaining legitimate issues
+3. Provide suggestions for fixes
+
+## False Positives to Remove
+
+These issues are **already fixed** - constants exist and are being used.
SonarQube line numbers may be outdated:
+
+### SchemaInfo.java (both OpenAPI v3 and Swagger v2)
+- ✅ `additionalProperties` - Already has `PROP_additionalProperties` constant
+- ✅ `allOf` - Already has `PROP_allOf` constant
+- ✅ `anyOf` - Already has `PROP_anyOf` constant (OpenAPI v3 only)
+- ✅ `default` - Already has `PROP_default` constant
+- ✅ `deprecated` - Already has `PROP_deprecated` constant
+- ✅ `description` - Already has `PROP_description` constant
+- ✅ `discriminator` - Already has `PROP_discriminator` constant
+- ✅ `example` - Already has `PROP_example` constant
+- ✅ `exclusiveMaximum` - Already has `PROP_exclusiveMaximum` constant
+- ✅ `exclusiveMinimum` - Already has `PROP_exclusiveMinimum` constant
+- ✅ `externalDocs` - Already has `PROP_externalDocs` constant
+- ✅ `format` - Already has `PROP_format` constant
+- ✅ `items` - Already has `PROP_items` constant
+- ✅ `maximum` - Already has `PROP_maximum` constant
+- ✅ `maxItems` - Already has `PROP_maxItems` constant
+- ✅ `maxLength` - Already has `PROP_maxLength` constant
+- ✅ `maxProperties` - Already has `PROP_maxProperties` constant
+- ✅ `minimum` - Already has `PROP_minimum` constant
+- ✅ `minItems` - Already has `PROP_minItems` constant
+- ✅ `minLength` - Already has `PROP_minLength` constant
+- ✅ `minProperties` - Already has `PROP_minProperties` constant
+- ✅ `multipleOf` - Already has `PROP_multipleOf` constant
+- ✅ `nullable` - Already has `PROP_nullable` constant (OpenAPI v3 only)
+- ✅ `oneOf` - Already has `PROP_oneOf` constant (OpenAPI v3 only)
+- ✅ `pattern` - Already has `PROP_pattern` constant
+- ✅ `properties` - Already has `PROP_properties` constant
+- ✅ `readOnly` - Already has `PROP_readOnly` constant
+- ✅ `required` - Already has `PROP_required` constant
+- ✅ `requiredProperties` - Already has `PROP_requiredProperties` constant
(Swagger v2 only)
+- ✅ `uniqueItems` - Already has `PROP_uniqueItems` constant
+- ✅ `writeOnly` - Already has `PROP_writeOnly` constant (OpenAPI v3 only)
+
+### HeaderInfo.java, Items.java, ParameterInfo.java (Swagger v2)
+- ✅ All property names already have constants (collectionFormat, default,
description, example, exclusiveMaximum, exclusiveMinimum, format, items,
maximum, maxItems, maxLength, minimum, minItems, minLength, multipleOf,
pattern, uniqueItems)
+
+### Response.java (OpenAPI v3)
+- ✅ `content` - Already has `PROP_content` constant
+- ✅ `description` - Already has `PROP_description` constant
+- ✅ `headers` - Already has `PROP_headers` constant
+- ✅ `links` - Already has `PROP_links` constant
+
+### ResponseInfo.java (Swagger v2)
+- ✅ `description` - Already has `PROP_description` constant
+- ✅ `examples` - Already has `PROP_examples` constant
+- ✅ `headers` - Already has `PROP_headers` constant
+- ✅ `schema` - Already has `PROP_schema` constant
+
+### Server.java (OpenAPI v3)
+- ✅ `variables` - Already has `PROP_variables` constant
+
+### SecurityRequirement.java (OpenAPI v3)
+- ✅ `requirements` - Already has `PROP_requirements` constant
+
+### MediaType.java (OpenAPI v3)
+- ✅ `encoding` - Already has `PROP_encoding` constant
+- ✅ `examples` - Already has `PROP_examples` constant
+- ✅ `schema` - Already has `PROP_schema` constant
+
+## Legitimate Issues to Fix
+
+### Category 1: HttpPartSchema.java - Property Names (LEGITIMATE ISSUES)
+**File**:
`/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java`
+
+**Status**: Constants exist (lines 92-107) but are NOT being used everywhere.
String literals still present in:
+- Line 2696: `"uniqueItems"` - **MISSING CONSTANT** `PROP_uniqueItems` needs
to be added
+- Lines 3758-3843: Multiple `addIf()` calls using string literals instead of
constants
+- Lines 4202-4221: More string literals in validation code
+
+**Issues to fix**:
+- Add missing `PROP_uniqueItems` constant
+- Replace all string literals in `addIf()` calls (lines ~3758-3843) with
constants
+- Replace string literals in validation code (lines ~4202-4221) with constants
+
+**Suggestion**:
+1. Add `PROP_uniqueItems = "uniqueItems"` constant (line ~108)
+2. Replace all `"properties"`, `"additionalProperties"`, `"exclusiveMaximum"`,
`"exclusiveMinimum"`, `"uniqueItems"`, `"collectionFormat"`, `"pattern"`,
`"items"`, `"maximum"`, `"minimum"`, `"multipleOf"`, `"maxItems"`,
`"maxLength"`, `"maxProperties"`, `"minItems"`, `"minLength"`,
`"minProperties"` string literals with their corresponding `PROP_*` constants
+
+### Category 2: UI Files - CSS Class Names / HTML Attributes
+**Files**:
+-
`/juneau-bean-openapi-v3/src/main/java/org/apache/juneau/bean/openapi3/ui/OpenApiUI.java`
+-
`/juneau-bean-swagger-v2/src/main/java/org/apache/juneau/bean/swagger/ui/SwaggerUI.java`
+
+These appear to be CSS class names or HTML attribute values used in UI
generation:
+
+- `"Description"` (3-6 times) - Capitalized version, likely for display
+- `"description"` (4-6 times) - Lowercase version
+- `"model"` (5-7 times)
+- `"parameter-key"` (3 times)
+- `"response-key"` (3 times)
+
+**Suggestion**: Create constants like `CSS_CLASS_Description`,
`CSS_CLASS_description`, `CSS_CLASS_model`, `CSS_CLASS_parameterKey`,
`CSS_CLASS_responseKey`. These are UI-specific constants, so a different naming
convention might be appropriate (e.g., `UI_CLASS_*` or `HTML_CLASS_*`).
+
+### Category 3: HTML Parser/Serializer - HTML Element Names
+**Files**:
+-
`/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlParserSession.java`
+-
`/juneau-marshall/src/main/java/org/apache/juneau/html/BasicHtmlDocTemplate.java`
+-
`/juneau-marshall/src/main/java/org/apache/juneau/html/HtmlSerializerSession.java`
+
+These are HTML element names:
+
+- `"array"` (5 times)
+- `"aside"` (8 times)
+- `"object"` (4 times)
+- `"section"` (6 times)
+- `"style"` (4 times)
+- `"table"` (6 times)
+
+**Suggestion**: Create constants like `HTML_TAG_array`, `HTML_TAG_aside`,
`HTML_TAG_object`, `HTML_TAG_section`, `HTML_TAG_style`, `HTML_TAG_table`. Or
use a shared constant class for HTML tag names.
+
+### Category 4: Error Messages
+**Files**:
+- `/juneau-marshall/src/main/java/org/apache/juneau/parser/ParserReader.java`
+-
`/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/assertion/FluentResponseBodyAssertion.java`
+-
`/juneau-rest-server/src/main/java/org/apache/juneau/rest/assertions/FluentRequestContentAssertion.java`
+-
`/juneau-rest-server/src/main/java/org/apache/juneau/rest/servlet/RestServlet.java`
+- `/juneau-marshall/src/main/java/org/apache/juneau/BeanPropertyMeta.java`
+
+- `"Buffer underflow."` (3 times)
+- `"Exception occurred during call."` (3-4 times)
+- `"Getter or public field not defined on property ''{0}''"` (3 times)
+- `"Servlet init error on class ''{0}''"` (3 times)
+
+**Suggestion**: These are error messages that could be moved to a messages
resource file or constants class. However, if they're only used 3-4 times,
consider:
+- For error messages: Create `ERROR_MSG_*` constants
+- For messages with placeholders: Consider using a message format utility or
resource bundle
+
+### Category 5: Example/Test Data
+**Files**:
+-
`/juneau-examples-core/src/main/java/org/apache/juneau/examples/bean/BeanExample.java`
+-
`/juneau-examples-core/src/main/java/org/apache/juneau/examples/bean/atom/AtomFeed.java`
+-
`/juneau-examples-rest/src/main/java/org/apache/juneau/examples/rest/dto/AtomFeedResource.java`
+
+- `"http://foo.org/"` (3 times each file)
+
+**Suggestion**: Create example constants like `EXAMPLE_URL_FOO_ORG =
"http://foo.org/"`. These are test/example data, so low priority unless they're
duplicated across many files.
+
+### Category 6: Script Files
+**File**: `/juneau/scripts/release.py`
+
+- `'https://dist.apache.org/repos/dist/dev/juneau'` (3 times)
+- `'pom.xml'` (5 times)
+- `'~/tmp/dist-release-juneau'` (15 times)
+- `r'RC(\d+)'` (8 times)
+
+**Suggestion**: Python scripts - create constants at the top of the file.
These are configuration values that should definitely be constants.
+
+### Category 7: Reflection/Internal Property Names
+**Files**:
+-
`/juneau-commons/src/main/java/org/apache/juneau/commons/reflect/ReflectionMap.java`
+-
`/juneau-commons/src/main/java/org/apache/juneau/commons/inject/BeanCreator2.java`
+-
`/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java`
+
+- `"fullClassName"` (3 times)
+- `"simpleClassName"` (3 times)
+- `"value"` (3-20 times) - Very common, used in many contexts
+- `"values"` (3-7 times)
+- `"names"` (4 times)
+- `"Using fallback supplier"` (4 times)
+
+**Suggestion**:
+- For property names: Create `PROP_fullClassName`, `PROP_simpleClassName`, etc.
+- For `"value"`: This is extremely common and used in many different contexts.
Consider if it's worth creating a constant, or if it's better to suppress the
warning for this specific case.
+- For messages: Create `MSG_*` constants
+
+### Category 8: HTTP Methods / REST
+**File**:
`/juneau-rest-client/src/main/java/org/apache/juneau/rest/client/RestClient.java`
+
+- `"PATCH"` (3 times)
+
+**Suggestion**: Use existing HTTP method constants if available, or create
`HTTP_METHOD_PATCH` constant.
+
+### Category 9: Configuration/Console Commands
+**File**:
`/juneau-microservice-core/src/main/java/org/apache/juneau/microservice/console/ConfigCommand.java`
+
+- `"InvalidArguments"` (3 times)
+- `"TooManyArguments"` (3 times)
+
+**Suggestion**: Create constants like `CMD_ERROR_InvalidArguments`,
`CMD_ERROR_TooManyArguments`.
+
+### Category 10: JSON Schema / Type Names
+**Files**:
+-
`/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/JsonSchemaGeneratorSession.java`
+-
`/juneau-marshall/src/main/java/org/apache/juneau/annotation/SchemaAnnotation.java`
+
+- `"items"` (4-7 times) - Already has constant in some files, check if used
here
+- `"string"` (4 times)
+
+**Suggestion**: Create constants like `JSONSCHEMA_TYPE_string`,
`JSONSCHEMA_TYPE_items`, or use existing constants if available.
+
+### Category 11: Character Encoding
+**File**:
`/juneau-commons/src/main/java/org/apache/juneau/commons/utils/StringUtils.java`
+
+- `"UTF-8"` (3 times)
+
+**Suggestion**: Use `StandardCharsets.UTF_8.name()` or create `CHARSET_UTF8 =
"UTF-8"` constant. Better yet, use `StandardCharsets.UTF_8` directly if
possible.
+
+### Category 12: AppliedAnnotationObject
+**File**:
`/juneau-commons/src/main/java/org/apache/juneau/commons/annotation/AppliedAnnotationObject.java`
+
+- `"value"` (20 times)
+
+**Suggestion**: This is a very common property name in annotations. Consider
creating `PROP_value = "value"` constant, or suppress the warning if it's used
in a context where a constant wouldn't improve readability.
+
+## Recommended Action Plan
+
+### Phase 1: Remove False Positives (High Priority)
+1. Remove all SchemaInfo.java issues (both versions) - these are false
positives
+2. Remove HeaderInfo.java, Items.java, ParameterInfo.java issues - already
fixed
+3. Remove Response.java, ResponseInfo.java issues - already fixed
+4. Remove Server.java, SecurityRequirement.java, MediaType.java issues -
already fixed
+
+### Phase 2: Fix HttpPartSchema.java (High Priority)
+- Verify constants exist (they do, lines 92-107)
+- Check `apply(JsonMap m)` method around lines 2655-2680
+- Replace all string literals with existing constants
+
+### Phase 3: Fix UI Files (Medium Priority)
+- Create CSS class name constants for OpenApiUI.java and SwaggerUI.java
+- Use consistent naming convention (e.g., `UI_CLASS_*`)
+
+### Phase 4: Fix HTML Files (Medium Priority)
+- Create HTML tag name constants
+- Consider a shared `HtmlTags` class for reusability
+
+### Phase 5: Fix Error Messages (Low-Medium Priority)
+- Create error message constants
+- Consider moving to resource bundle if internationalization is needed
+
+### Phase 6: Fix Remaining Issues (Low Priority)
+- Script files (Python)
+- Example/test data
+- Reflection property names
+- Other miscellaneous issues
+
+## Notes
+
+- Many issues are false positives because SonarQube line numbers may be
outdated after our refactoring
+- The `"value"` literal appears 20+ times in AppliedAnnotationObject.java -
this is very common in Java annotations and may be acceptable to suppress
+- Some literals (like `"UTF-8"`) should use `StandardCharsets.UTF_8` instead
of string constants
+- UI and HTML-related constants might benefit from shared constant classes for
better organization
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SchemaAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SchemaAnnotation.java
index 8cc5e45566..2ba5defdda 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SchemaAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SchemaAnnotation.java
@@ -40,6 +40,55 @@ import org.apache.juneau.svl.*;
*/
public class SchemaAnnotation {
+ // Property name constants
+ private static final String PROP_additionalProperties =
"additionalProperties";
+ private static final String PROP_allOf = "allOf";
+ private static final String PROP_collectionFormat = "collectionFormat";
+ private static final String PROP_const = "const";
+ private static final String PROP_contentEncoding = "contentEncoding";
+ private static final String PROP_contentMediaType = "contentMediaType";
+ private static final String PROP_default = "default";
+ private static final String PROP_deprecated = "deprecated";
+ private static final String PROP_dependentRequired =
"dependentRequired";
+ private static final String PROP_dependentSchemas = "dependentSchemas";
+ private static final String PROP_description = "description";
+ private static final String PROP_discriminator = "discriminator";
+ private static final String PROP_else = "else";
+ private static final String PROP_enum = "enum";
+ private static final String PROP_examples = "examples";
+ private static final String PROP_exclusiveMaximum = "exclusiveMaximum";
+ private static final String PROP_exclusiveMinimum = "exclusiveMinimum";
+ private static final String PROP_externalDocs = "externalDocs";
+ private static final String PROP_format = "format";
+ private static final String PROP_id = "$id";
+ private static final String PROP_if = "if";
+ private static final String PROP_ignore = "ignore";
+ private static final String PROP_items = "items";
+ private static final String PROP_maximum = "maximum";
+ private static final String PROP_maxItems = "maxItems";
+ private static final String PROP_maxLength = "maxLength";
+ private static final String PROP_maxProperties = "maxProperties";
+ private static final String PROP_minimum = "minimum";
+ private static final String PROP_minItems = "minItems";
+ private static final String PROP_minLength = "minLength";
+ private static final String PROP_minProperties = "minProperties";
+ private static final String PROP_multipleOf = "multipleOf";
+ private static final String PROP_pattern = "pattern";
+ private static final String PROP_prefixItems = "prefixItems";
+ private static final String PROP_properties = "properties";
+ private static final String PROP_readOnly = "readOnly";
+ private static final String PROP_ref = "$ref";
+ private static final String PROP_required = "required";
+ private static final String PROP_then = "then";
+ private static final String PROP_title = "title";
+ private static final String PROP_type = "type";
+ private static final String PROP_unevaluatedItems = "unevaluatedItems";
+ private static final String PROP_unevaluatedProperties =
"unevaluatedProperties";
+ private static final String PROP_uniqueItems = "uniqueItems";
+ private static final String PROP_xml = "xml";
+ private static final String PROP_comment = "$comment";
+ private static final String PROP_defs = "$defs";
+
/**
* Prevents instantiation.
*/
@@ -1636,54 +1685,54 @@ public class SchemaAnnotation {
// @formatter:off
return m
- .appendIf(nem, "additionalProperties",
parseMap(a.additionalProperties()))
- .appendIf(ne, "allOf", joinnl(a.allOf()))
- .appendFirst(ne, "collectionFormat",
a.collectionFormat(), a.cf())
- .appendIf(ne, "default", joinnl(a.default_(), a.df()))
- .appendIf(ne, "discriminator", a.discriminator())
- .appendIf(ne, "description", joinnl(a.description(),
a.d()))
- .appendFirst(nec, "enum", parseSet(a.enum_()),
parseSet(a.e()))
- .appendIf(ne, "exclusiveMaximum", exclusiveMaximumValue)
- .appendIf(ne, "exclusiveMinimum", exclusiveMinimumValue)
- .appendIf(nem, "externalDocs",
ExternalDocsAnnotation.merge(m.getMap("externalDocs"), a.externalDocs()))
- .appendFirst(ne, "format", a.format(), a.f())
- .appendIf(ne, "ignore", a.ignore() ? "true" : null)
- .appendIf(nem, "items", merge(m.getMap("items"),
a.items()))
- .appendFirst(ne, "maximum", a.maximum(), a.max())
- .appendFirst(nm1, "maxItems", a.maxItems(), a.maxi())
- .appendFirst(nm1, "maxLength", a.maxLength(), a.maxl())
- .appendFirst(nm1, "maxProperties", a.maxProperties(),
a.maxp())
- .appendFirst(ne, "minimum", a.minimum(), a.min())
- .appendFirst(nm1, "minItems", a.minItems(), a.mini())
- .appendFirst(nm1, "minLength", a.minLength(), a.minl())
- .appendFirst(nm1, "minProperties", a.minProperties(),
a.minp())
- .appendFirst(ne, "multipleOf", a.multipleOf(), a.mo())
- .appendFirst(ne, "pattern", a.pattern(), a.p())
- .appendIf(nem, "properties", parseMap(a.properties()))
- .appendIf(nf, "readOnly", a.readOnly() || a.ro())
- .appendIf(nf, "required", a.required() || a.r())
- .appendIf(ne, "title", a.title())
- .appendFirst(ne, "type", a.type(), a.t())
- .appendIf(nf, "uniqueItems", a.uniqueItems() || a.ui())
- .appendIf(ne, "xml", joinnl(a.xml()))
- .appendIf(ne, "$ref", a.$ref())
+ .appendIf(nem, PROP_additionalProperties,
parseMap(a.additionalProperties()))
+ .appendIf(ne, PROP_allOf, joinnl(a.allOf()))
+ .appendFirst(ne, PROP_collectionFormat,
a.collectionFormat(), a.cf())
+ .appendIf(ne, PROP_default, joinnl(a.default_(),
a.df()))
+ .appendIf(ne, PROP_discriminator, a.discriminator())
+ .appendIf(ne, PROP_description, joinnl(a.description(),
a.d()))
+ .appendFirst(nec, PROP_enum, parseSet(a.enum_()),
parseSet(a.e()))
+ .appendIf(ne, PROP_exclusiveMaximum,
exclusiveMaximumValue)
+ .appendIf(ne, PROP_exclusiveMinimum,
exclusiveMinimumValue)
+ .appendIf(nem, PROP_externalDocs,
ExternalDocsAnnotation.merge(m.getMap(PROP_externalDocs), a.externalDocs()))
+ .appendFirst(ne, PROP_format, a.format(), a.f())
+ .appendIf(ne, PROP_ignore, a.ignore() ? "true" : null)
+ .appendIf(nem, PROP_items, merge(m.getMap(PROP_items),
a.items()))
+ .appendFirst(ne, PROP_maximum, a.maximum(), a.max())
+ .appendFirst(nm1, PROP_maxItems, a.maxItems(), a.maxi())
+ .appendFirst(nm1, PROP_maxLength, a.maxLength(),
a.maxl())
+ .appendFirst(nm1, PROP_maxProperties,
a.maxProperties(), a.maxp())
+ .appendFirst(ne, PROP_minimum, a.minimum(), a.min())
+ .appendFirst(nm1, PROP_minItems, a.minItems(), a.mini())
+ .appendFirst(nm1, PROP_minLength, a.minLength(),
a.minl())
+ .appendFirst(nm1, PROP_minProperties,
a.minProperties(), a.minp())
+ .appendFirst(ne, PROP_multipleOf, a.multipleOf(),
a.mo())
+ .appendFirst(ne, PROP_pattern, a.pattern(), a.p())
+ .appendIf(nem, PROP_properties,
parseMap(a.properties()))
+ .appendIf(nf, PROP_readOnly, a.readOnly() || a.ro())
+ .appendIf(nf, PROP_required, a.required() || a.r())
+ .appendIf(ne, PROP_title, a.title())
+ .appendFirst(ne, PROP_type, a.type(), a.t())
+ .appendIf(nf, PROP_uniqueItems, a.uniqueItems() ||
a.ui())
+ .appendIf(ne, PROP_xml, joinnl(a.xml()))
+ .appendIf(ne, PROP_ref, a.$ref())
// JSON Schema Draft 2020-12 properties
- .appendIf(ne, "const", joinnl(a.const_()))
- .appendIf(nec, "examples", a.examples().length == 0 ?
null : l(a.examples()))
- .appendIf(ne, "$comment", joinnl(a.$comment()))
- .appendIf(nf, "deprecated", a.deprecatedProperty())
- .appendIf(ne, "contentMediaType", a.contentMediaType())
- .appendIf(ne, "contentEncoding", a.contentEncoding())
- .appendIf(ne, "prefixItems", joinnl(a.prefixItems()))
- .appendIf(ne, "unevaluatedItems",
joinnl(a.unevaluatedItems()))
- .appendIf(ne, "unevaluatedProperties",
joinnl(a.unevaluatedProperties()))
- .appendIf(ne, "dependentSchemas",
joinnl(a.dependentSchemas()))
- .appendIf(ne, "dependentRequired",
joinnl(a.dependentRequired()))
- .appendIf(ne, "if", joinnl(a.if_()))
- .appendIf(ne, "then", joinnl(a.then_()))
- .appendIf(ne, "else", joinnl(a.else_()))
- .appendIf(ne, "$defs", joinnl(a.$defs()))
- .appendIf(ne, "$id", a.$id())
+ .appendIf(ne, PROP_const, joinnl(a.const_()))
+ .appendIf(nec, PROP_examples, a.examples().length == 0
? null : l(a.examples()))
+ .appendIf(ne, PROP_comment, joinnl(a.$comment()))
+ .appendIf(nf, PROP_deprecated, a.deprecatedProperty())
+ .appendIf(ne, PROP_contentMediaType,
a.contentMediaType())
+ .appendIf(ne, PROP_contentEncoding, a.contentEncoding())
+ .appendIf(ne, PROP_prefixItems, joinnl(a.prefixItems()))
+ .appendIf(ne, PROP_unevaluatedItems,
joinnl(a.unevaluatedItems()))
+ .appendIf(ne, PROP_unevaluatedProperties,
joinnl(a.unevaluatedProperties()))
+ .appendIf(ne, PROP_dependentSchemas,
joinnl(a.dependentSchemas()))
+ .appendIf(ne, PROP_dependentRequired,
joinnl(a.dependentRequired()))
+ .appendIf(ne, PROP_if, joinnl(a.if_()))
+ .appendIf(ne, PROP_then, joinnl(a.then_()))
+ .appendIf(ne, PROP_else, joinnl(a.else_()))
+ .appendIf(ne, PROP_defs, joinnl(a.$defs()))
+ .appendIf(ne, PROP_id, a.$id())
;
// @formatter:on
}
@@ -1735,11 +1784,11 @@ public class SchemaAnnotation {
Predicate<Map<?,?>> nem = Utils::ne;
Predicate<Boolean> nf = Utils::isTrue;
Predicate<Long> nm1 = Utils::nm1;
- return m.appendFirst(ne, "collectionFormat",
a.collectionFormat(), a.cf()).appendIf(ne, "default", joinnl(a.default_(),
a.df())).appendFirst(nec, "enum", parseSet(a.enum_()), parseSet(a.e()))
- .appendFirst(ne, "format", a.format(),
a.f()).appendIf(nf, "exclusiveMaximum", a.exclusiveMaximum() ||
a.emax()).appendIf(nf, "exclusiveMinimum", a.exclusiveMinimum() || a.emin())
- .appendIf(nem, "items",
SubItemsAnnotation.merge(m.getMap("items"), a.items())).appendFirst(ne,
"maximum", a.maximum(), a.max()).appendFirst(nm1, "maxItems", a.maxItems(),
a.maxi())
- .appendFirst(nm1, "maxLength", a.maxLength(),
a.maxl()).appendFirst(ne, "minimum", a.minimum(), a.min()).appendFirst(nm1,
"minItems", a.minItems(), a.mini())
- .appendFirst(nm1, "minLength", a.minLength(),
a.minl()).appendFirst(ne, "multipleOf", a.multipleOf(), a.mo()).appendFirst(ne,
"pattern", a.pattern(), a.p())
- .appendIf(nf, "uniqueItems", a.uniqueItems() ||
a.ui()).appendFirst(ne, "type", a.type(), a.t()).appendIf(ne, "$ref", a.$ref());
+ return m.appendFirst(ne, PROP_collectionFormat,
a.collectionFormat(), a.cf()).appendIf(ne, PROP_default, joinnl(a.default_(),
a.df())).appendFirst(nec, PROP_enum, parseSet(a.enum_()), parseSet(a.e()))
+ .appendFirst(ne, PROP_format, a.format(),
a.f()).appendIf(nf, PROP_exclusiveMaximum, a.exclusiveMaximum() ||
a.emax()).appendIf(nf, PROP_exclusiveMinimum, a.exclusiveMinimum() || a.emin())
+ .appendIf(nem, PROP_items,
SubItemsAnnotation.merge(m.getMap(PROP_items), a.items())).appendFirst(ne,
PROP_maximum, a.maximum(), a.max()).appendFirst(nm1, PROP_maxItems,
a.maxItems(), a.maxi())
+ .appendFirst(nm1, PROP_maxLength, a.maxLength(),
a.maxl()).appendFirst(ne, PROP_minimum, a.minimum(), a.min()).appendFirst(nm1,
PROP_minItems, a.minItems(), a.mini())
+ .appendFirst(nm1, PROP_minLength, a.minLength(),
a.minl()).appendFirst(ne, PROP_multipleOf, a.multipleOf(),
a.mo()).appendFirst(ne, PROP_pattern, a.pattern(), a.p())
+ .appendIf(nf, PROP_uniqueItems, a.uniqueItems() ||
a.ui()).appendFirst(ne, PROP_type, a.type(), a.t()).appendIf(ne, PROP_ref,
a.$ref());
}
}
\ No newline at end of file
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SubItemsAnnotation.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SubItemsAnnotation.java
index 8acbd6b7bc..f291456aa8 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SubItemsAnnotation.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/annotation/SubItemsAnnotation.java
@@ -34,6 +34,26 @@ import org.apache.juneau.parser.*;
*/
public class SubItemsAnnotation {
+ // Property name constants
+ private static final String PROP_collectionFormat = "collectionFormat";
+ private static final String PROP_default = "default";
+ private static final String PROP_enum = "enum";
+ private static final String PROP_exclusiveMaximum = "exclusiveMaximum";
+ private static final String PROP_exclusiveMinimum = "exclusiveMinimum";
+ private static final String PROP_format = "format";
+ private static final String PROP_items = "items";
+ private static final String PROP_maximum = "maximum";
+ private static final String PROP_maxItems = "maxItems";
+ private static final String PROP_maxLength = "maxLength";
+ private static final String PROP_minimum = "minimum";
+ private static final String PROP_minItems = "minItems";
+ private static final String PROP_minLength = "minLength";
+ private static final String PROP_multipleOf = "multipleOf";
+ private static final String PROP_pattern = "pattern";
+ private static final String PROP_ref = "$ref";
+ private static final String PROP_type = "type";
+ private static final String PROP_uniqueItems = "uniqueItems";
+
/**
* Prevents instantiation.
*/
@@ -782,24 +802,24 @@ public class SubItemsAnnotation {
Predicate<Long> nm1 = Utils::nm1;
// @formatter:off
return om
- .appendFirst(ne, "collectionFormat",
a.collectionFormat(), a.cf())
- .appendIf(ne, "default", joinnl(a.default_(), a.df()))
- .appendFirst(nec, "enum", parseSet(a.enum_()),
parseSet(a.e()))
- .appendIf(nf, "exclusiveMaximum", a.exclusiveMaximum()
|| a.emax())
- .appendIf(nf, "exclusiveMinimum", a.exclusiveMinimum()
|| a.emin())
- .appendFirst(ne, "format", a.format(), a.f())
- .appendIf(nem, "items", parseMap(a.items()))
- .appendFirst(ne, "maximum", a.maximum(), a.max())
- .appendFirst(nm1, "maxItems", a.maxItems(), a.maxi())
- .appendFirst(nm1, "maxLength", a.maxLength(), a.maxl())
- .appendFirst(ne, "minimum", a.minimum(), a.min())
- .appendFirst(nm1, "minItems", a.minItems(), a.mini())
- .appendFirst(nm1, "minLength", a.minLength(), a.minl())
- .appendFirst(ne, "multipleOf", a.multipleOf(), a.mo())
- .appendFirst(ne, "pattern", a.pattern(), a.p())
- .appendFirst(ne, "type", a.type(), a.t())
- .appendIf(nf, "uniqueItems", a.uniqueItems() || a.ui())
- .appendIf(ne, "$ref", a.$ref())
+ .appendFirst(ne, PROP_collectionFormat,
a.collectionFormat(), a.cf())
+ .appendIf(ne, PROP_default, joinnl(a.default_(),
a.df()))
+ .appendFirst(nec, PROP_enum, parseSet(a.enum_()),
parseSet(a.e()))
+ .appendIf(nf, PROP_exclusiveMaximum,
a.exclusiveMaximum() || a.emax())
+ .appendIf(nf, PROP_exclusiveMinimum,
a.exclusiveMinimum() || a.emin())
+ .appendFirst(ne, PROP_format, a.format(), a.f())
+ .appendIf(nem, PROP_items, parseMap(a.items()))
+ .appendFirst(ne, PROP_maximum, a.maximum(), a.max())
+ .appendFirst(nm1, PROP_maxItems, a.maxItems(), a.maxi())
+ .appendFirst(nm1, PROP_maxLength, a.maxLength(),
a.maxl())
+ .appendFirst(ne, PROP_minimum, a.minimum(), a.min())
+ .appendFirst(nm1, PROP_minItems, a.minItems(), a.mini())
+ .appendFirst(nm1, PROP_minLength, a.minLength(),
a.minl())
+ .appendFirst(ne, PROP_multipleOf, a.multipleOf(),
a.mo())
+ .appendFirst(ne, PROP_pattern, a.pattern(), a.p())
+ .appendFirst(ne, PROP_type, a.type(), a.t())
+ .appendIf(nf, PROP_uniqueItems, a.uniqueItems() ||
a.ui())
+ .appendIf(ne, PROP_ref, a.$ref())
;
// @formatter:on
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
index bf2434a147..43300afcbe 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/httppart/HttpPartSchema.java
@@ -90,9 +90,13 @@ public class HttpPartSchema {
// Property name constants
private static final String PROP_additionalProperties =
"additionalProperties";
+ private static final String PROP_allowEmptyValue = "allowEmptyValue";
private static final String PROP_collectionFormat = "collectionFormat";
+ private static final String PROP_default = "default";
+ private static final String PROP_enum = "enum";
private static final String PROP_exclusiveMaximum = "exclusiveMaximum";
private static final String PROP_exclusiveMinimum = "exclusiveMinimum";
+ private static final String PROP_format = "format";
private static final String PROP_items = "items";
private static final String PROP_maximum = "maximum";
private static final String PROP_maxItems = "maxItems";
@@ -103,8 +107,14 @@ public class HttpPartSchema {
private static final String PROP_minLength = "minLength";
private static final String PROP_minProperties = "minProperties";
private static final String PROP_multipleOf = "multipleOf";
+ private static final String PROP_name = "name";
+ private static final String PROP_parsedType = "parsedType";
private static final String PROP_pattern = "pattern";
private static final String PROP_properties = "properties";
+ private static final String PROP_required = "required";
+ private static final String PROP_skipIfEmpty = "skipIfEmpty";
+ private static final String PROP_type = "type";
+ private static final String PROP_uniqueItems = "uniqueItems";
// Jakarta validation annotation class name constants
private static final String CLASSNAME_NotNull = "NotNull";
@@ -2687,16 +2697,16 @@ public class HttpPartSchema {
Builder apply(JsonMap m) {
if (nn(m) && ! m.isEmpty()) {
- default_(m.getString("default"));
-
enum_(HttpPartSchema.toSet(m.getString("enum")));
-
allowEmptyValue(m.getBoolean("allowEmptyValue"));
+ default_(m.getString(PROP_default));
+
enum_(HttpPartSchema.toSet(m.getString(PROP_enum)));
+
allowEmptyValue(m.getBoolean(PROP_allowEmptyValue));
exclusiveMaximum(m.getBoolean(PROP_exclusiveMaximum));
exclusiveMinimum(m.getBoolean(PROP_exclusiveMinimum));
- required(m.getBoolean("required"));
- uniqueItems(m.getBoolean("uniqueItems"));
+ required(m.getBoolean(PROP_required));
+ uniqueItems(m.getBoolean(PROP_uniqueItems));
collectionFormat(m.getString(PROP_collectionFormat));
- type(m.getString("type"));
- format(m.getString("format"));
+ type(m.getString(PROP_type));
+ format(m.getString(PROP_format));
pattern(m.getString(PROP_pattern));
maximum(m.get(PROP_maximum, Number.class));
minimum(m.get(PROP_minimum, Number.class));
@@ -3755,57 +3765,57 @@ public class HttpPartSchema {
switch (type) {
case STRING: {
notAllowed
- .addIf(nn(properties), "properties")
- .addIf(nn(additionalProperties),
"additionalProperties")
- .addIf(exclusiveMaximum,
"exclusiveMaximum")
- .addIf(exclusiveMinimum,
"exclusiveMinimum")
- .addIf(uniqueItems, "uniqueItems")
- .addIf(collectionFormat !=
HttpPartCollectionFormat.NO_COLLECTION_FORMAT, "collectionFormat")
- .addIf(nn(items), "items")
- .addIf(nn(maximum), "maximum")
- .addIf(nn(minimum), "minimum")
- .addIf(nn(multipleOf), "multipleOf")
- .addIf(nn(maxItems), "maxItems")
- .addIf(nn(minItems), "minItems")
- .addIf(nn(minProperties),
"minProperties");
+ .addIf(nn(properties), PROP_properties)
+ .addIf(nn(additionalProperties),
PROP_additionalProperties)
+ .addIf(exclusiveMaximum,
PROP_exclusiveMaximum)
+ .addIf(exclusiveMinimum,
PROP_exclusiveMinimum)
+ .addIf(uniqueItems, PROP_uniqueItems)
+ .addIf(collectionFormat !=
HttpPartCollectionFormat.NO_COLLECTION_FORMAT, PROP_collectionFormat)
+ .addIf(nn(items), PROP_items)
+ .addIf(nn(maximum), PROP_maximum)
+ .addIf(nn(minimum), PROP_minimum)
+ .addIf(nn(multipleOf), PROP_multipleOf)
+ .addIf(nn(maxItems), PROP_maxItems)
+ .addIf(nn(minItems), PROP_minItems)
+ .addIf(nn(minProperties),
PROP_minProperties);
invalidFormat = !
format.isOneOf(HttpPartFormat.BYTE, HttpPartFormat.BINARY,
HttpPartFormat.BINARY_SPACED, HttpPartFormat.DATE, HttpPartFormat.DATE_TIME,
HttpPartFormat.PASSWORD, HttpPartFormat.UON, HttpPartFormat.NO_FORMAT);
break;
}
case ARRAY: {
- notAllowed.addIf(nn(properties), "properties")
- .addIf(nn(additionalProperties),
"additionalProperties")
- .addIf(exclusiveMaximum,
"exclusiveMaximum")
- .addIf(exclusiveMinimum,
"exclusiveMinimum")
- .addIf(nn(pattern), "pattern")
- .addIf(nn(maximum), "maximum")
- .addIf(nn(minimum), "minimum")
- .addIf(nn(multipleOf), "multipleOf")
- .addIf(nn(maxLength), "maxLength")
- .addIf(nn(minLength), "minLength")
- .addIf(nn(maxProperties),
"maxProperties")
- .addIf(nn(minProperties),
"minProperties");
+ notAllowed.addIf(nn(properties),
PROP_properties)
+ .addIf(nn(additionalProperties),
PROP_additionalProperties)
+ .addIf(exclusiveMaximum,
PROP_exclusiveMaximum)
+ .addIf(exclusiveMinimum,
PROP_exclusiveMinimum)
+ .addIf(nn(pattern), PROP_pattern)
+ .addIf(nn(maximum), PROP_maximum)
+ .addIf(nn(minimum), PROP_minimum)
+ .addIf(nn(multipleOf), PROP_multipleOf)
+ .addIf(nn(maxLength), PROP_maxLength)
+ .addIf(nn(minLength), PROP_minLength)
+ .addIf(nn(maxProperties),
PROP_maxProperties)
+ .addIf(nn(minProperties),
PROP_minProperties);
invalidFormat = !
format.isOneOf(HttpPartFormat.NO_FORMAT, HttpPartFormat.UON);
break;
}
case BOOLEAN: {
- notAllowed.addIf(! enum_.isEmpty(), "enum")
- .addIf(nn(properties), "properties")
- .addIf(nn(additionalProperties),
"additionalProperties")
- .addIf(exclusiveMaximum,
"exclusiveMaximum")
- .addIf(exclusiveMinimum,
"exclusiveMinimum")
- .addIf(uniqueItems, "uniqueItems")
- .addIf(collectionFormat !=
HttpPartCollectionFormat.NO_COLLECTION_FORMAT, "collectionFormat")
- .addIf(nn(pattern), "pattern")
- .addIf(nn(items), "items")
- .addIf(nn(maximum), "maximum")
- .addIf(nn(minimum), "minimum")
- .addIf(nn(multipleOf), "multipleOf")
- .addIf(nn(maxItems), "maxItems")
- .addIf(nn(maxLength), "maxLength")
- .addIf(nn(maxProperties),
"maxProperties")
- .addIf(nn(minItems), "minItems")
- .addIf(nn(minLength), "minLength")
- .addIf(nn(minProperties),
"minProperties");
+ notAllowed.addIf(! enum_.isEmpty(), PROP_enum)
+ .addIf(nn(properties), PROP_properties)
+ .addIf(nn(additionalProperties),
PROP_additionalProperties)
+ .addIf(exclusiveMaximum,
PROP_exclusiveMaximum)
+ .addIf(exclusiveMinimum,
PROP_exclusiveMinimum)
+ .addIf(uniqueItems, PROP_uniqueItems)
+ .addIf(collectionFormat !=
HttpPartCollectionFormat.NO_COLLECTION_FORMAT, PROP_collectionFormat)
+ .addIf(nn(pattern), PROP_pattern)
+ .addIf(nn(items), PROP_items)
+ .addIf(nn(maximum), PROP_maximum)
+ .addIf(nn(minimum), PROP_minimum)
+ .addIf(nn(multipleOf), PROP_multipleOf)
+ .addIf(nn(maxItems), PROP_maxItems)
+ .addIf(nn(maxLength), PROP_maxLength)
+ .addIf(nn(maxProperties),
PROP_maxProperties)
+ .addIf(nn(minItems), PROP_minItems)
+ .addIf(nn(minLength), PROP_minLength)
+ .addIf(nn(minProperties),
PROP_minProperties);
invalidFormat = !
format.isOneOf(HttpPartFormat.NO_FORMAT, HttpPartFormat.UON);
break;
}
@@ -3813,50 +3823,50 @@ public class HttpPartSchema {
break;
}
case INTEGER: {
- notAllowed.addIf(nn(properties), "properties")
- .addIf(nn(additionalProperties),
"additionalProperties")
- .addIf(uniqueItems, "uniqueItems")
- .addIf(collectionFormat !=
HttpPartCollectionFormat.NO_COLLECTION_FORMAT, "collectionFormat")
- .addIf(nn(pattern), "pattern")
- .addIf(nn(items), "items")
- .addIf(nn(maxItems), "maxItems")
- .addIf(nn(maxLength), "maxLength")
- .addIf(nn(maxProperties),
"maxProperties")
- .addIf(nn(minItems), "minItems")
- .addIf(nn(minLength), "minLength")
- .addIf(nn(minProperties),
"minProperties");
+ notAllowed.addIf(nn(properties),
PROP_properties)
+ .addIf(nn(additionalProperties),
PROP_additionalProperties)
+ .addIf(uniqueItems, PROP_uniqueItems)
+ .addIf(collectionFormat !=
HttpPartCollectionFormat.NO_COLLECTION_FORMAT, PROP_collectionFormat)
+ .addIf(nn(pattern), PROP_pattern)
+ .addIf(nn(items), PROP_items)
+ .addIf(nn(maxItems), PROP_maxItems)
+ .addIf(nn(maxLength), PROP_maxLength)
+ .addIf(nn(maxProperties),
PROP_maxProperties)
+ .addIf(nn(minItems), PROP_minItems)
+ .addIf(nn(minLength), PROP_minLength)
+ .addIf(nn(minProperties),
PROP_minProperties);
invalidFormat = !
format.isOneOf(HttpPartFormat.NO_FORMAT, HttpPartFormat.UON,
HttpPartFormat.INT32, HttpPartFormat.INT64);
break;
}
case NUMBER: {
- notAllowed.addIf(nn(properties), "properties")
- .addIf(nn(additionalProperties),
"additionalProperties")
- .addIf(uniqueItems, "uniqueItems")
- .addIf(collectionFormat !=
HttpPartCollectionFormat.NO_COLLECTION_FORMAT, "collectionFormat")
- .addIf(nn(pattern), "pattern")
- .addIf(nn(items), "items")
- .addIf(nn(maxItems), "maxItems")
- .addIf(nn(maxLength), "maxLength")
- .addIf(nn(maxProperties),
"maxProperties")
- .addIf(nn(minItems), "minItems")
- .addIf(nn(minLength), "minLength")
- .addIf(nn(minProperties),
"minProperties");
+ notAllowed.addIf(nn(properties),
PROP_properties)
+ .addIf(nn(additionalProperties),
PROP_additionalProperties)
+ .addIf(uniqueItems, PROP_uniqueItems)
+ .addIf(collectionFormat !=
HttpPartCollectionFormat.NO_COLLECTION_FORMAT, PROP_collectionFormat)
+ .addIf(nn(pattern), PROP_pattern)
+ .addIf(nn(items), PROP_items)
+ .addIf(nn(maxItems), PROP_maxItems)
+ .addIf(nn(maxLength), PROP_maxLength)
+ .addIf(nn(maxProperties),
PROP_maxProperties)
+ .addIf(nn(minItems), PROP_minItems)
+ .addIf(nn(minLength), PROP_minLength)
+ .addIf(nn(minProperties),
PROP_minProperties);
invalidFormat = !
format.isOneOf(HttpPartFormat.NO_FORMAT, HttpPartFormat.UON,
HttpPartFormat.FLOAT, HttpPartFormat.DOUBLE);
break;
}
case OBJECT: {
- notAllowed.addIf(exclusiveMaximum,
"exclusiveMaximum")
- .addIf(exclusiveMinimum,
"exclusiveMinimum")
- .addIf(uniqueItems, "uniqueItems")
- .addIf(nn(pattern), "pattern")
- .addIf(nn(items), "items")
- .addIf(nn(maximum), "maximum")
- .addIf(nn(minimum), "minimum")
- .addIf(nn(multipleOf), "multipleOf")
- .addIf(nn(maxItems), "maxItems")
- .addIf(nn(maxLength), "maxLength")
- .addIf(nn(minItems), "minItems")
- .addIf(nn(minLength), "minLength");
+ notAllowed.addIf(exclusiveMaximum,
PROP_exclusiveMaximum)
+ .addIf(exclusiveMinimum,
PROP_exclusiveMinimum)
+ .addIf(uniqueItems, PROP_uniqueItems)
+ .addIf(nn(pattern), PROP_pattern)
+ .addIf(nn(items), PROP_items)
+ .addIf(nn(maximum), PROP_maximum)
+ .addIf(nn(minimum), PROP_minimum)
+ .addIf(nn(multipleOf), PROP_multipleOf)
+ .addIf(nn(maxItems), PROP_maxItems)
+ .addIf(nn(maxLength), PROP_maxLength)
+ .addIf(nn(minItems), PROP_minItems)
+ .addIf(nn(minLength), PROP_minLength);
invalidFormat = !
format.isOneOf(HttpPartFormat.NO_FORMAT);
break;
}
@@ -4194,32 +4204,32 @@ public class HttpPartSchema {
Predicate<Object> nm1 = x -> x instanceof Number x2 &&
x2.intValue() != -1;
Predicate<Object> nn = Utils::nn;
return mapb_so().sorted().buildFluent()
- .ai(ne, "name", name)
- .ai(ne, "type", type)
- .ai(ne, "format", format)
- .ai(ne, "default", default_)
- .ai(ne, "enum", enum_)
- .ai(ne, "properties", properties)
- .ai(nf, "allowEmptyValue", allowEmptyValue)
- .ai(nf, "exclusiveMaximum", exclusiveMaximum)
- .ai(nf, "exclusiveMinimum", exclusiveMinimum)
- .ai(nf, "required", required)
- .ai(nf, "uniqueItems", uniqueItems)
- .ai(nf, "skipIfEmpty", skipIfEmpty)
- .ai(x -> x !=
HttpPartCollectionFormat.NO_COLLECTION_FORMAT, "collectionFormat",
collectionFormat)
- .ai(ne, "pattern", pattern)
- .ai(nn, "items", items)
- .ai(nn, "additionalProperties", additionalProperties)
- .ai(nm1, "maximum", maximum)
- .ai(nm1, "minimum", minimum)
- .ai(nm1, "multipleOf", multipleOf)
- .ai(nm1, "maxLength", maxLength)
- .ai(nm1, "minLength", minLength)
- .ai(nm1, "maxItems", maxItems)
- .ai(nm1, "minItems", minItems)
- .ai(nm1, "maxProperties", maxProperties)
- .ai(nm1, "minProperties", minProperties)
- .a("parsedType", parsedType);
+ .ai(ne, PROP_name, name)
+ .ai(ne, PROP_type, type)
+ .ai(ne, PROP_format, format)
+ .ai(ne, PROP_default, default_)
+ .ai(ne, PROP_enum, enum_)
+ .ai(ne, PROP_properties, properties)
+ .ai(nf, PROP_allowEmptyValue, allowEmptyValue)
+ .ai(nf, PROP_exclusiveMaximum, exclusiveMaximum)
+ .ai(nf, PROP_exclusiveMinimum, exclusiveMinimum)
+ .ai(nf, PROP_required, required)
+ .ai(nf, PROP_uniqueItems, uniqueItems)
+ .ai(nf, PROP_skipIfEmpty, skipIfEmpty)
+ .ai(x -> x !=
HttpPartCollectionFormat.NO_COLLECTION_FORMAT, PROP_collectionFormat,
collectionFormat)
+ .ai(ne, PROP_pattern, pattern)
+ .ai(nn, PROP_items, items)
+ .ai(nn, PROP_additionalProperties, additionalProperties)
+ .ai(nm1, PROP_maximum, maximum)
+ .ai(nm1, PROP_minimum, minimum)
+ .ai(nm1, PROP_multipleOf, multipleOf)
+ .ai(nm1, PROP_maxLength, maxLength)
+ .ai(nm1, PROP_minLength, minLength)
+ .ai(nm1, PROP_maxItems, maxItems)
+ .ai(nm1, PROP_minItems, minItems)
+ .ai(nm1, PROP_maxProperties, maxProperties)
+ .ai(nm1, PROP_minProperties, minProperties)
+ .a(PROP_parsedType, parsedType);
// @formatter:on
}
diff --git
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/JsonSchemaGeneratorSession.java
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/JsonSchemaGeneratorSession.java
index b5ef3f2ecc..8f6d68270b 100644
---
a/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/JsonSchemaGeneratorSession.java
+++
b/juneau-core/juneau-marshall/src/main/java/org/apache/juneau/jsonschema/JsonSchemaGeneratorSession.java
@@ -53,6 +53,19 @@ public class JsonSchemaGeneratorSession extends
BeanTraverseSession {
private static final String ARG_id = "id";
private static final String ARG_def = "def";
+ // JSON Schema property name constants
+ private static final String PROP_additionalProperties =
"additionalProperties";
+ private static final String PROP_enum = "enum";
+ private static final String PROP_format = "format";
+ private static final String PROP_items = "items";
+ private static final String PROP_properties = "properties";
+ private static final String PROP_type = "type";
+ private static final String PROP_uniqueItems = "uniqueItems";
+
+ // JSON Schema type and format constants
+ private static final String TYPE_string = "string";
+ private static final String FORMAT_uri = "uri";
+
/**
* Builder class.
*/
@@ -390,17 +403,17 @@ public class JsonSchemaGeneratorSession extends
BeanTraverseSession {
type = "array";
} else if (sType.isEnum()) {
tc = ENUM;
- type = "string";
+ type = TYPE_string;
} else if (sType.isCharSequence() || sType.isChar()) {
tc = STRING;
- type = "string";
+ type = TYPE_string;
} else if (sType.isUri()) {
tc = STRING;
- type = "string";
- format = "uri";
+ type = TYPE_string;
+ format = FORMAT_uri;
} else {
tc = STRING;
- type = "string";
+ type = TYPE_string;
}
// Add info from @Schema on bean property.
@@ -411,8 +424,8 @@ public class JsonSchemaGeneratorSession extends
BeanTraverseSession {
out.append(jscm.getSchema());
Predicate<String> ne = Utils::ne;
- out.appendIfAbsentIf(ne, "type", type);
- out.appendIfAbsentIf(ne, "format", format);
+ out.appendIfAbsentIf(ne, PROP_type, type);
+ out.appendIfAbsentIf(ne, PROP_format, format);
if (nn(aType)) {
@@ -433,27 +446,27 @@ public class JsonSchemaGeneratorSession extends
BeanTraverseSession {
properties.put(p.getName(),
getSchema(p.getClassMeta(), p.getName(), pProps, exampleAdded,
descriptionAdded, getJsonSchemaBeanPropertyMeta(p)));
}
}
- out.put("properties", properties);
+ out.put(PROP_properties, properties);
} else if (tc == COLLECTION) {
ClassMeta et = sType.getElementType();
if (sType.isCollection() &&
sType.isAssignableTo(Set.class))
- out.put("uniqueItems", true);
- out.put("items", getSchema(et, "items", pNames,
exampleAdded, descriptionAdded, null));
+ out.put(PROP_uniqueItems, true);
+ out.put(PROP_items, getSchema(et, PROP_items,
pNames, exampleAdded, descriptionAdded, null));
} else if (tc == ARRAY) {
ClassMeta et = sType.getElementType();
if (sType.isCollection() &&
sType.isAssignableTo(Set.class))
- out.put("uniqueItems", true);
- out.put("items", getSchema(et, "items", pNames,
exampleAdded, descriptionAdded, null));
+ out.put(PROP_uniqueItems, true);
+ out.put(PROP_items, getSchema(et, PROP_items,
pNames, exampleAdded, descriptionAdded, null));
} else if (tc == ENUM) {
- out.put("enum", getEnums(sType));
+ out.put(PROP_enum, getEnums(sType));
} else if (tc == MAP) {
- var om = getSchema(sType.getValueType(),
"additionalProperties", null, exampleAdded, descriptionAdded, null);
+ var om = getSchema(sType.getValueType(),
PROP_additionalProperties, null, exampleAdded, descriptionAdded, null);
if (! om.isEmpty())
- out.put("additionalProperties", om);
+ out.put(PROP_additionalProperties, om);
}
}