* Check references in additionalProperties correctly
Handle references in additionalProperties correctly when determining free-form status
* Update samples
With:
```
sampleObject:
type: object
additionalProperties:
$ref: '#/components/schemas/SampleData'
minProperties: 1
description: Map of Charging data policy decisions.
```
and
```
SampleData:
type: object
...
nullable: true
```
We currently generate: HashMap<String, SampleData>, which doesn't allow
null charging data entries. This MR changes this to be
`HashMap<String, swagger::Nullable<SampleData>>`, which thus will allow null data entries.
We do this by moving null-handling to the Java code - primarily `getTypeDeclaration()`.
Note, to some extent this is wrong. In this MR (and previously) we are treating
`nullable: true` as an extrinsic property (like required), whereas it should be an
intrinsic property (and thus `HashMap<String, SampleData>` is correct, but `SampleData`
absorbs the nullability.
This would be possible with this code:
```
enum ChargingData = {
Null,
Present {
...
}
}
```
Which would remove the usage of https://docs.rs/swagger/2.0.2/swagger/nullable_format/enum.Nullable.html.
I haven't resolved this - and have instead done a more targeted fix.
This, along with some other crude code, creates a scenario where we need to
unpick whether something is null. I've left that, though flagged a TODO to tidy it up at some point.
* [Rust Server] Convert Rust comment to Mustache
The comment about auth types supported by the generator shouldn't be
included in the generated code as it's confusing when the API doesn't
support the same auth types.
As such, we convert it from a Rust comment to a Mustache comment
* Update samples
* [Rust Server] Add auto-generated CLI tool
* [Rust Server] Test multiple path parameters
* [Rust Server] Test boolean parameters and apostrophes
* [Rust Server] Test operation with two boolean parameters with same first letter
* [Rust Server] Test apostrophes in operation summary
* Update samples
* [Rust Server] Fix build errors with OpenSSL
* Update samples
* Update samples
* [Rust Server] Fix up model generation
- Correctly generate anyOf/oneOf models
- Fix up ToString / FromStr support
- Disable PartialOrd generation for anyOf/oneOf models
- Generate models for inline enums
- Support enums in headers, and vectors of models in headers
* [Rust Server] Add test for anyOf with additional properties
* Update samples
* [Rust Server] Tidy up logging
* [Rust Server] Sort operations so that the ones with fewest params come first
This resolves things correctly per
https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#pathsObject
- "When matching URLs, concrete (non-templated) paths would be matched
before their templated counterparts."
* Update samples
* [Rust Server] Fix tabs vs spaces
---------
Co-authored-by: Rob Day <Robert.Day@metaswitch.com>
* [Rust Server] Allow configuration of multipart/form attachment size limit
multipart 0.14+ imposes a 8MB size limit on multipart/form bodies.
This allows that limit to be configured. The default is left as is.
This also improves error messages produced when handling multipart/form bodies.
* Update samples
* Fix server-writing docs for rust-server
Fix broken link in generated README for rust-server.
* Update samples
---------
Co-authored-by: Keith Wansbrough <Keith.Wansbrough@metaswitch.com>
* [Rust Server] Fix code so examples compile
Zero length arrays don't correctly type infer, so if we have no scopes, we need to not create a empty array
We need an authentication middleware - without it the code doesn't compile.
* Update samples
* [Rust Server] Remove trailing whitespace
* Update samples
* [Rust Server] [CI] Build all targets
* [Rust] Fix reqwest test
* Added authentication via Bearer-token api_key and basic for server and client
* Improved errorhandling
* Added check on oAuth audience to example
* Updates of the petstore files for Rust-server
* Moved module import to prevent issue in callbacks
* updated samples
* Fix for unused-qualifications issue
* updated sampmles
* refactor: move closure definition to own statement
A clippy lint recommends not using a closure inside of a statement.
The code generation used to produce code that triggered this warning,
which caused the rust-server integration test to fail because clippy is
configured to return lint violations as errors.
For details for the lint see:
https://rust-lang.github.io/rust-clippy/master/index.html#blocks_in_conditions
* refactor: Remove unnecessary qualification
A GitHub action test used to fail because of a clippy warning that was
emitted due to not using an imported symbol but qualifying its use.
A failed test can be seen here:
https://github.com/OpenAPITools/openapi-generator/actions/runs/8958257509/job/24603984954?pr=18563
With the relevant error being:
error: unnecessary qualification
--> output/openapi-v3/src/client/callbacks.rs:88:9
|
88 | futures::future::ok(Service::new(
This commit simply removes the qualification.
* test: Update examples and run integration test.
Updated examples by running
`./bin/generate-samples.sh ./bin/configs/rust-server-*`
The integration test with the following command passes:
`mvn integration-test -f samples/server/petstore/rust-server/pom.xml`
* add initial openapi config and java generated files
* add java implementation for adding generator version
* regenerate sample client files
* remove tabs
* only show generated version if build info exists
* set build info for batch generation
* update generator doc for new global flag
* use existing property for generator version
* update templates to include generator version
* update templates for better generator version syntax
* revert undesired changes
* regenerate samples for openapi client
* update templates to correct formatting/newlines
* correct description text and add to usage doc
* add generator cli option for all codegen types
* use more concise version info; update existing codegens to support new prop
* correct wrong prop reference
* add initial test coverage for new prop
* update last (scala) templates with new prop
* update samples after upstream merge
* use consistent version output
* use better sample project id/name
* revert using option for generator version in templates
The EOL is missing so let's add it in order to comply with POSIX standard:
Line
> A sequence of zero or more non- <newline> characters plus a terminating <newline> character.
* Fix clippy errors (rustc 1.73.0)
* Add feature docker-in-docker
* Fix mapping of "date"
See issue #9769
The type
type: string
format: date
was mapped to DateTime<Utc> which violates the OpenAPI spec
see https://swagger.io/docs/specification/data-models/data-types/
The generated example code would clone the context. However as context
is a generic type and is not declared to implement Clone, a clone of a
reference is just a copy of the reference and therefore unnecessary.
This change removes the redundant call and therefore avoids the `cargo
clippy` warning.