Releases: openapi-processor/openapi-processor-base
2021.2
copied from openapi-processor-core
openapi-processor/openapi-processor-core#45, support for mapping OpenAPI nullable
properties to jackson-databind-nullable.
This is useful to implement a json merge patch api that needs to know if a property was not set at all or explicitly set to "null" ("null" means to clear the property value).
For example, the /foo
api endpoint uses the following schema as request body
...
components:
schemas:
Foo:
description: a Foo
type: object
properties:
bar:
nullable: true
type: string
Normally the processor would generate a simple pojo with a String
property. By adding a null
mapping for the /foo
endpoint (this does work only on the endpoint level, a global null mapping gets ignored):
openapi-processor-mapping: v2
map:
paths:
/foo:
null: org.openapitools.jackson.nullable.JsonNullable
# with initialization:
# null: org.openapitools.jackson.nullable.JsonNullable = JsonNullable.undefined()
it will generate the following code:
import com.fasterxml.jackson.annotation.JsonProperty;
import org.openapitools.jackson.nullable.JsonNullable;
public class Foo {
@JsonProperty("bar")
private JsonNullable<String> bar;
// with initialization:
// private JsonNullable<String> bar = JsonNullable.undefined();
public JsonNullable<String> getBar() {
return bar;
}
public void setBar(JsonNullable<String> bar) {
this.bar = bar;
}
}
openapi-processor/openapi-processor-core#55, endpoint mapping by http method.
It is now possible to add mappings that apply only to a specific http method. Motivation for this is to limit the mapping only to the place where it is needed. Http method mappings have priority over other mappings. In general, the most specific mapping is used.
Here are a few examples of possible http endpoint mappings:
openapi-processor-mapping: v2
map:
paths:
/foo:
# normal endpoint mappings apply to all http methods (behaves exactly as before)
types:
- type: Foo => java.util.Collection
# endpoint http method mappings apply only the specified http method
get:
result: org.springframework.http.ResponseEntity
post:
parameters:
- add: request => javax.servlet.http.HttpServletRequest
patch:
null: org.openapitools.jackson.nullable.JsonNullable = JsonNullable.undefined()
The structure follows the OpenAPI, i.e. the http methods (or OpenAPI operations) are properties of the endpoint path.
An http method mapping allows the same mappings as the endpoint mapping without http method, i.e. exclude
, result
, single
, multi
, null
, types
, parameters
and responses
(see the mapping json schema).
The last example is using the new null
mapping that may only be interesting for the PATCH
http method because there is no need for nullable
properties for GET
or PUT
. Note that it is not possible to use different null
mappings (or one http mapping with null
and one without) on the same model schema. The processor generates only a single class for model schemas and with two different and ambiguous mappings the result is (currently) undefined. It is recommended to use two different schemas if the null
mapping should only apply to a single method.
openapi-processor/openapi-processor-core#58, endpoint parameters with openapi4j parser
Parameters at the endpoint/path level (which are used for all operations) were ignored with the openapi4j parser.
2021.1
copied from openapi-processor-core
-
jars are published on maven central (was jcenter).
-
(beta) generation of javadoc from OpenAPI
description
s. It is off by default, to enable set thejavadoc
option totrue
:openapi-processor-mapping: v2 options: javadoc: true
-
(experimental) additional add parameter annotation. It is possible to add one additional annotation to a parameter add mapping.
Motivation is the micronaut @RequestAttribute annotation. It is required to bind a parameter to an attribute of the request which is typically created in a filter:
openapi-processor-mapping: v2 map: paths: /api/process: parameters: - add: requestId => io.micronaut.http.annotation.RequestAttribute("requestId") java.lang.String
The parameters of the annotation are "passed through" as string.
-
openapi-processor/openapi-processor-core#50, improved detection of used schemas for model class generation. It now detects schemas that are only use by a type mapping:
openapi-processor-mapping: v2 map: types: - type: FooPage => org.springframework.data.domain.Page<generated.model.Foo>
Because of the mapping the processor didn't look at anything that was part (property of) of
FooPage
. IfFoo
was only referenced byFooPage
no model class was generated forFoo
. -
openapi-processor/openapi-processor-core#51, handle schemas without properties (i.e. do not crash), e.g.
type: object additionalProperties: { }
-
openapi-processor/openapi-processor-core#1, better error reporting if the
openapi.yaml
does not exist -
updated swagger parser to 2.0.24 (was 2.0.23)
2020.4 (1.4.0)
copied from openapi-processor-core
-
openapi-processor/openapi-processor-core#34, report a formatting error including the failing source code
-
openapi-processor/openapi-processor-core#35, using tags like
test_api
&test-api
at the same time would override one interface. Both tags result in the same java interface nameTestApi
( '_' is (usually) not used in interface names and-
is not a valid java identifier char).The processor will now merge endpoints with tags like this into the same interface
-
#39, added json schema for the mapping.yaml. Some IDEs (e.g. Intellij IDEA) use it to provide editing support. Thanks to @schlagi123 for providing the initial version
-
openapi-processor/openapi-processor-core#41, the
_
character was lost when converting enum value names to valid java identifiers. For example an enum valueFOO_FOO
was converted toFOOFOO
. The underscore is now preserved for enum values. -
openapi-processor/openapi-processor-core#43, first step of
allOf
support.allOf
of multiple object schemas will create a model class with all properties of the individual items. -
openapi-processor/openapi-processor-core#44, fixed generation of
@NotNull
bean validation annotation. It is now based on therequired
property instead of thenullable
property -
#48, a type-less schema would crash the processor. It has now minimal handling (more or less ignoring it) so it does not crash anymore.
allOf: - readOnly: true # type-less schema - $ref: '#/components/schemas/Foo' # does not matter if it is $ref
-
updated swagger parser to 2.0.23 (was 2.0.21)
1.3.0
copied from openapi-processor-core
-
openapi-processor/openapi-processor-core#30, preserve the "?" generic parameter of a mapping and pass it on to the generated api, e.g. a mapping like
map: paths: /foo: parameters: - add: foo => io.openapiprocessor.Foo<?>
does now generate
void foo(Foo<?> foo);
instead of
void foo(Foo foo);
-
openapi-processor/openapi-processor-spring#119, primitive type could match a primitive type with format mapping, e.g. with the mapping
openapi-processor-spring: v2 map: types: - type: string:binary => io.openapiprocessor.Foo
it was possible that a primitive string was mapped to
io.openapiprocessor.Foo
instead ofjava.lang.String
-
a ref loop with array
items
caused aNullPointerException
1.2.1
copied from openapi-processor-core
- the internal representation of an empty response (ie. without any response data) leaked to the generated code. Visible by a
produces = {"?"}
in the mapping annotation and anObject
return type of the endpoint.
1.2.0
copied from openapi-processor-core
-
add
@NotNull
ifnullable
is default (i.e. true) and bean validation is enabled. -
openapi-processor/openapi-processor-core#20, the type mapping (v2 only) configuration allows to reference the target
package-name
in generic parameters using the{package-name}
expression. This makes it possible to adjust thepackage-name
without touching the mapping and it can reduce duplication if the mapping contains many generic parameters.openapi-processor-mapping: v2 options: package-name: io.openapiprocessor.generated.model map: types: - type: FooPage => org.springframework.data.domain.Page<{package-name}.Foo>
-
openapi-processor/openapi-processor-core#21, a primitive type with a custom format (not defined by the OpenAPI specification) did break processing. The processor does now ignore unknown custom formats. For example the following definition
type: string format: unknown-custom-format
will be processed as if it has no format at all:
type: string
-
openapi-processor/openapi-processor-core#22, mapping of primitive schemas did not work. It is now possible to have a primitive schema
components: schemas: Foo: type: string
and map this to a specific target java type:
openapi-processor-spring: v2 map: types: - type: Foo => io.openapiprocessor.sample.Foo
-
openapi-processor/openapi-processor-core#23, parameter $ref's were not resolved when processing with the openapi4j parser.
-
updated openapi4j parser to 1.0.4 (was 1.0.3)
1.1.1
1.1.0
copied from openapi-processor-core
- openapi-processor/openapi-processor-core#10, support for OpenAPI
deprecated
property at endpoint, parameter, schema and schema property level. It translates to@Deprecated
annotations - openapi-processor/openapi-processor-core#12, fix windows path/url handling, i.e.
unknown protocol: c
- fix build on windows
- new model
Endpoint
methodList<String> getConsumesContentTypes()
that provides the list of consumeable media types. Helps to fix openapi-processor/openapi-processor-micronaut#1 - support path $ref (openapi4j)
- more tolerant mapping parser
- updated openapi4j parser to 1.0.3 (was 1.0.0)
- updated swagger parse to 2.0.21 (was 2.0.20)
1.0.0
copied from openapi-processor-core
- improved obsolete mapping/mapping key check
- updated openapi-processor-test
1.0.0.M2
copied from openapi-processor-core
- (openapi-processor/openapi-processor-core#2) renamed mapping.yaml version identifier from
openapi-processor-spring
toopenapi-processor-mapping
- (openapi-processor/openapi-processor-core#4) updated openapi4j parser to 1.0.0
- (openapi-processor/openapi-processor-core#8) new group id:
io.openapiprocessor
- new repository: https://dl.bintray.com/openapi-processor/primary