This repository was archived by the owner on Dec 25, 2024. It is now read-only.
File tree Expand file tree Collapse file tree
src/main/java/packagename Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ /*
2+ {{ #if appName }}
3+ {{{ appName }}}
4+ {{ /if }}
5+ {{ #if appDescription }}
6+ {{{ appDescription.original }}}
7+ {{ /if }}
8+ {{ #if version }}
9+ The version of the OpenAPI document: {{{ version }}}
10+ {{ /if }}
11+ {{ #if infoEmail }}
12+ Contact: {{{ infoEmail }}}
13+ {{ /if }}
14+ Generated by: https://github.com/openapi-json-schema-tools/openapi-json-schema-generator
15+ */
Original file line number Diff line number Diff line change 1+ # coding: utf-8
2+
3+ {{> _helper_header }}
4+
5+ {{ #with requestBody }}
6+ {{ #if refInfo }}
7+ {{ #if imports }}
8+
9+ {{ /if }}
10+ {{> _helper_imports }}
11+ {{ jsonPathPiece.pascalCase }} = {{ refInfo.refModule }} .{{ refInfo.refClass }}
12+ {{ else }}
13+ from {{ packageName }} .shared_imports.header_imports import * # pyright: ignore [reportWildcardImportFromLibrary]
14+
15+ {{ #each content }}
16+ {{ #with schema }}
17+ from .content.{{ ../@key.snakeCase }} import {{ jsonPathPiece.snakeCase }} as {{ ../@key.snakeCase }} _{{ jsonPathPiece.snakeCase }}
18+ {{ /with }}
19+ {{ /each }}
20+
21+
22+ class {{ jsonPathPiece.pascalCase }} (api_client.RequestBody):
23+ {{ #each content }}
24+
25+
26+ class {{ @key.pascalCase }} MediaType(api_client.MediaType):
27+ {{ #with this }}
28+ {{ #with schema }}
29+ {{> components/_helper_content_schema_type paramName =" schema" contentTypeModule = ../@key.snakeCase }}
30+ {{ /with }}
31+ {{ /with }}
32+ {{ /each }}
33+ content = {
34+ {{ #each content }}
35+ '{{{ @key.original }}} ': {{ @key.pascalCase }} MediaType,
36+ {{ /each }}
37+ }
38+ {{ #if required }}
39+ required = True
40+ {{ /if }}
41+ {{ /if }}
42+ {{ /with }}
Original file line number Diff line number Diff line change 1+ package {{{ packageName }}} .mediatype;
2+
3+ import org.checkerframework.checker.nullness.qual.Nullable;
4+ package {{{ packageName }}} .parameter.ParameterStyle;
5+
6+ import java.util.Map;
7+
8+ public class Encoding {
9+ public final String contentType;
10+ public final @Nullable Map<String , String> headers; // todo change value to HeaderParameter
11+ public final @Nullable ParameterStyle style;
12+ public final boolean explode;
13+ public final boolean allowReserved;
14+
15+ public Encoding(String contentType) {
16+ this.contentType = contentType;
17+ headers = null;
18+ style = null;
19+ explode = false;
20+ allowReserved = false;
21+ }
22+ public Encoding(String contentType, @Nullable Map<String , String> headers) {
23+ this.contentType = contentType;
24+ this.headers = headers;
25+ style = null;
26+ explode = false;
27+ allowReserved = false;
28+ }
29+ }
Original file line number Diff line number Diff line change 1+ package {{{ packageName }}} .mediatype;
2+
3+ import package {{{ packageName }}} .schemas.validation.JsonSchema;
4+ import org.checkerframework.checker.nullness.qual.Nullable;
5+
6+ import java.util.Map;
7+
8+ public class MediaType<T extends JsonSchema> {
9+ /*
10+ * Used to store request and response body schema information
11+ * encoding:
12+ * A map between a property name and its encoding information.
13+ * The key, being the property name, MUST exist in the schema as a property.
14+ * The encoding object SHALL only apply to requestBody objects when the media type is
15+ * multipart or application/x-www-form-urlencoded.
16+ */
17+ public final Class<T > schema;
18+ public final @Nullable Map<String , Encoding> encoding;
19+
20+ public MediaTypeWithoutEncoding(Class<T > schema, @Nullable Map<String , Encoding> encoding) {
21+ this.schema = schema;
22+ this.encoding = encoding;
23+ }
24+
25+ public MediaTypeWithoutEncoding(Class<T > schema) {
26+ this.schema = schema;
27+ this.encoding = null;
28+ }
29+ }
Original file line number Diff line number Diff line change 1+ package {{{ packageName }}} .parameter;
2+
3+ public enum ParameterStyle {
4+ MATRIX,
5+ LABEL,
6+ FORM,
7+ SIMPLE,
8+ SPACE_DELIMITED,
9+ PIPE_DELIMITED,
10+ DEEP_OBJECT
11+ }
Original file line number Diff line number Diff line change 1+ package {{{ packageName }}} .requestbody;
2+
3+ import java.net.http.HttpRequest;
4+
5+ public class RequestBody {
6+ public final String contentType;
7+ public final HttpRequest.BodyPublisher bodyPublisher;
8+
9+ protected RequestBody(String contentType, HttpRequest.BodyPublisher bodyPublisher) {
10+ this.contentType = contentType;
11+ this.bodyPublisher = bodyPublisher;
12+ }
13+ }
Original file line number Diff line number Diff line change 1+ package {{{ packageName }}} .requestbody;
2+
3+ import {{{ packageName }}} .mediatype.MediaType;
4+
5+ import java.util.Map;
6+
7+ public class RequestBodyMaker {
8+ /*
9+ * Describes a single request body
10+ * content: content_type to MediaType schema info
11+ * each implementing class must implement RequestBody makeForApplicationJson(SealedOutput)
12+ * each the returned RequestBody must have a protected constructor to insure that
13+ * it is created by makeForApplicationJson
14+ * or make one enum for each content type, then implement make(SpecificContentType, SealedOutput)
15+ * requires one enum per contentType
16+ * abstract T make(String contentType, @Nullable Object body)
17+ * logic: MediaType< ?> get(ContentTypeEnum contentType)
18+ * .makeRequestBody(SealedOutput)
19+ */
20+ public final Map<String , MediaType<?>> content;
21+ public final boolean required;
22+
23+ public RequestBodyMaker(Map<String , MediaType<?>> content, boolean required) {
24+ this.content = content;
25+ this.required = required;
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments