Fix Jspecify nullable issue with spring boot 4#23649
Conversation
|
@JFCote pathParams are always required in Spring. The build succeeds. It means that no Spring sample is impacted. |
|
Hay I think you just solve my problem #23653 |
|
@jpfinne See below for my spec but you can also check the @raichuchuchu bugs he just shared, this is exactly the issue! Here is the openapi spec I used for my tests: openapi: 3.0.0
info:
title: API - Address
version: 1.0.0
tags:
- name: Address
description: Address calls
paths:
/api/addresses/{addressId}:
put:
summary: Updates an address by ID
operationId: updateAddress
tags:
- Address
parameters:
- $ref: '#/components/parameters/addressId'
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/AddressCore'
responses:
'200':
description: Ok
content:
application/json:
schema:
$ref: '#/components/schemas/Address'
'404':
description: Not Found
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
delete:
summary: Deletes an address by ID
operationId: deleteAddress
tags:
- Address
parameters:
- $ref: '#/components/parameters/addressId'
responses:
'204':
description: No Content
components:
parameters:
addressId:
name: addressId
in: path
required: true
description: The ID of the address
schema:
type: integer
format: int64
example: 12345
schemas:
AddressCore:
type: object
properties:
friendlyName:
type: string
example: "Headquarters"
addressLine1:
type: string
example: "123 Main St"
addressLine2:
type: string
example: "Suite 456"
city:
type: string
example: "Sherbrooke"
province:
type: string
example: "Quebec"
postalCode:
type: string
example: "J1H 5N4"
country:
type: string
example: "Canada"
required:
- friendlyName
- addressLine1
- city
- province
- postalCode
- country
Address:
allOf:
- $ref: '#/components/schemas/AddressCore'
- type: object
properties:
id:
type: integer
format: int64
example: 12345
updatedAt:
type: string
format: date-time
example: "2025-08-05T18:48:59.149Z"
required:
- id
- updatedAt
Error:
type: object
properties:
timestamp:
type: string
format: date-time
example: "2025-08-05T18:48:59.149Z"
status:
type: integer
format: int32
example: 404
message:
type: string
example: "Resource not found"
path:
type: string
example: "/api/addresses/12345"And I generate with this command: Without my fix, the first method |
@cachescrubber (2022/02) @welshm (2022/02) @MelleD (2022/02) @atextor (2022/02) @manedev79 (2022/02) @javisst (2022/02) @borsch (2022/02) @banlevente (2022/02) @Zomzog (2022/09) @martin-mfg (2023/08)
Very small fix to the Spring Generator. The path parameter was the only one that did not add
nullableAnnotationwhich did not reset the internal state.PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)Summary by cubic
Fixes missing nullability on Spring path parameters for Spring Boot 4 by adding the
nullableAnnotation. This makes JSpecify handling consistent and prevents state leakage during generation.{{>nullableAnnotation}}before{{>optionalDataType}}inJavaSpring/pathParams.mustacheso path params reset nullability state and get the correct annotation.Written for commit 8284110. Summary will update on new commits. Review in cubic