Comments (3)
Your request is described very clearly, thanks for that.
Unfortunately, we are far from validation processing here.
This would require assignements (which are seriously avoided when possible) during validation process for obvious overhead regarding performance.
This could be only useful when a discrimator is setup.
If I understand well, your final goal is to know how deserialize your input content in such case. Discriminator propertyName
is key here.
Here're a sample approach which should do it nicely (untested):
@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY,
property="YOUR_DISCRIMINATOR_PROPERTY_NAME",
visible = true /* important if you need to keep the property */)
@JsonSubTypes({
@JsonSubTypes.Type(value = Dog.class, name = "Dog"),
@JsonSubTypes.Type(value = Cat.class, name = "Cat")})
class Animal {
public String name;
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy_MM_dd")
public LocalDate birthDay;
public String YOUR_DISCRIMINATOR_PROPERTY_NAME; // may be optional
protected Animal() { }
}
class Dog extends Animal {
public double bark;
public Dog() { }
}
class Cat extends Animal {
public int lives;
public Cat() { }
}
For booleans, you can use setters or custom deserializer and/or Boolean object (0 and 1 recognized).
All in all, this much more deserialization coding than schema need in my opinion.
from openapi4j.
Unfortunately I am working with generic objects against generic schemas - they are not known ahead of time. It is essentially a 'proxy' that sits between the raw http requests and the resulting end points. The system marshals requests to the APIs, with the intent to use openapi spec to convert data types as needed.
The proposal wouldn't need to create a full schema or modify it on the fly. It could simply record the outcome of all 'decision points', such that the schema can be iterated correctly with respect to the data by using this 'decision point' structure.
One workaround could be to support adding a customer validator of "*.*" that is called for every keyword of every node (or possibly only the 'anyOf', 'oneOf' etc nodes).
I could then exploit this to store INFO validation results using the 'crumbs' + type info then delegate to the next/core validator. These hooks are quite powerful and can be exploited. I could then reconstruct the decision points by iterating the info validation results . Although I won't necessarily need the entire schema of the data - I only need a record of where certain data types and formats are.
from openapi4j.
Related to #79
from openapi4j.
Related Issues (20)
- int64 or int32 format not identified by openapi4j tool HOT 3
- Mandatory element missing is not throwing error HOT 3
- Some of the optional fields when using oneOf are not being validated HOT 1
- Convenience methods to support easy response validation HOT 3
- Spring Adapter
- Validating data against schema with $ref HOT 2
- Incorrect path pattern for path parameter HOT 2
- Creating schema references programatically HOT 7
- OpenApi3Parser - add ability to provide spec string/stream to parse method HOT 2
- Integer formats not identified in 1.0.5 version openapi4j tool HOT 1
- Scheme that contains path parameters with minus sign in name fails validation HOT 1
- Throw ValidationException on path pattern collision
- Give the option to throw a validation error with no response validator is found
- RequestValidator fails when path params contains minus char HOT 1
- Get the path of an operation HOT 2
- ADDITIONAL_PROPS_RESTRICT = true rejects all attributes HOT 1
- Duplicate properties, Duplicate Headers are not being validated HOT 2
- Remove toString() call to replace NPE with more meaningful message
- Validation of callback URLs can't handle allOf/oneOf/... HOT 3
- Path pattern collision leads to incorrect Path selection
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openapi4j.