MOCK data generation method and device, computer equipment and storage medium
By receiving data defined by the interface and standardizing it using a deep learning model, MOCK data is automatically generated, solving the problems of cumbersome processes and errors caused by manual coding, and achieving efficient and accurate MOCK data generation.
Patent Information
- Application Number
- CN202511049185.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-28
- Publication Date
- 2025-11-07
AI Technical Summary
In existing technologies, MOCK data generation relies on manual coding, which leads to cumbersome processes, high time costs, and a high risk of errors, affecting the accuracy of test results and the quality of software development.
By receiving data defined through an interface, and using a deep learning-based data generation model for standardization, MOCK data is automatically generated, reducing manual operations.
It improves the efficiency and accuracy of MOCK data generation, reduces costs, and ensures data consistency and seamless interaction between systems.
Smart Images

Figure CN120910139A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computers, and is applied to the fields of intelligent medical treatment and finance, and in particular relates to a MOCK data generation method and device, a computer device and a storage medium. BACKGROUND
[0002] In the development and testing process of intelligent customer service or intelligent assistant software in the fields of medical health and pension, financial technology and the like, the generation of MOCK data is a key link for ensuring the effectiveness of testing. Such MOCK data needs to simulate user interaction information and business process data in a real business scenario, and is used to verify the compatibility of interfaces, the integrity of functions and the stability of systems.
[0003] At present, the generation of MOCK data generally relies on manual writing. Test personnel need to first deeply understand the parameter types, format requirements and business logic of interface definitions, and then manually create data meeting the requirements and enter the data into the system one by one according to these rules. Since different test scenarios need to correspond to different business data, such as patient medical record data and examination report data in the medical health and pension scenario, and account information and transaction flow data in the financial scenario, interface definition interpretation and data creation need to be performed again for each test.
[0004] This manual operation mode not only has a complicated process, but also has significant efficiency problems: on the one hand, repeated interface definition analysis and data entry work occupies a large amount of time cost, prolonging the software development and testing period; on the other hand, manually created data is prone to format errors, logical contradictions and the like due to negligence, affecting the accuracy of test results and causing potential risks to the quality of subsequent software development. SUMMARY
[0005] The embodiments of the present application provide a MOCK data generation method, device, computer device and storage medium, to solve the technical problems of complicated MOCK data generation process, high time cost and errors.
[0006] In a first aspect, the embodiments of the present application provide a MOCK data generation method applied to a MOCK platform, which includes: receiving interface definition data from a client and inputting the interface definition data into a preset data generation model; performing standardized processing on the interface definition data according to a preset prompt project and the data generation model and generating standardized interface definition data; receiving MOCK request information, generating corresponding MOCK data according to the data generation model and the standardized interface definition data, and returning the MOCK data to the client.
[0007] In a second aspect, the embodiments of the present application further provide a MOCK data generation apparatus applied to a MOCK platform, which comprises units for executing the above method.
[0008] In a third aspect, the embodiments of the present application further provide a computer device comprising a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the above method.
[0009] In a fourth aspect, the embodiments of the present application further provide a computer readable storage medium, which stores a computer program, and the computer program comprises program instructions, which, when executed by a processor, can implement the above method.
[0010] The present application provides a MOCK data generation method and device, a computer device and a storage medium. The interface definition data is input by a user, and the interface definition data is standardized by a data generation model to obtain standardized interface definition data. Then, the data generation model is used again to automatically generate MOCK data according to the MOCK request information of the user and the standardized interface definition data, without manual repeated construction. In addition, the interface definition data can be repeatedly used only by inputting the interface definition data once. The user can obtain the required MOCK data in different scenarios, thereby reducing the cost and improving the generation efficiency and accuracy of the generated data. BRIEF DESCRIPTION OF DRAWINGS
[0011] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed in the embodiment description. Obviously, the drawings in the following description are some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative labor.
[0012] Figure 1 The schematic flow chart of the MOCK data generation method provided by the embodiments of the present application is shown in the figure.
[0013] Figure 2 The sub-flow schematic diagram of the MOCK data generation method provided by the embodiments of the present application is shown in the figure.
[0014] Figure 3 The sub-flow schematic diagram of the MOCK data generation method provided by the embodiments of the present application is shown in the figure.
[0015] Figure 4 The sub-flow schematic diagram of the MOCK data generation method provided by the embodiments of the present application is shown in the figure.
[0016] Figure 5A sub-flow schematic diagram of the MOCK data generation method provided by the embodiment of the present application is shown in FIG. 1.
[0017] Figure 6 A sub-flow schematic diagram of the MOCK data generation method provided by the embodiment of the present application is shown in FIG. 1.
[0018] Figure 7 A schematic block diagram of the MOCK data generation device provided by the embodiment of the present application is shown in FIG. 2.
[0019] Figure 8 A schematic block diagram of the computer device provided by the embodiment of the present application is shown in FIG. 3. DETAILED DESCRIPTION
[0020] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of the present application.
[0021] It should be understood that, when used in the specification and the appended claims, the terms "comprise" and "include" indicate the presence of the described features, integers, steps, operations, elements, and / or components, but do not exclude one or more other features, integers, steps, operations, elements, components, and / or groups thereof.
[0022] It should also be understood that the terms used in the present application specification are only for the purpose of describing specific embodiments and are not intended to limit the present application. As used in the present application specification and the appended claims, the singular forms "a", "an" and "the" are intended to include the plural forms unless the context clearly indicates otherwise.
[0023] It should be further understood that the term "and / or" used in the present application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes these combinations.
[0024] Please refer to Figure 1is a schematic flowchart of a MOCK data generation method provided by an embodiment of the present application. In the present application, the MOCK data generation method is applied in a MOCK platform, and in particular in business fields such as medical health and the elderly, and financial technology. The data generation model can automatically generate MOCK data that meets the requirements. For example, for a health monitoring platform of an elderly care institution, daily health data of the elderly need to be simulated, and the generated MOCK data can include "heart rate: 75 times / minute (normal range 60-100 times / minute)", "oxygen saturation: 96% (normal range 95%-100%)", "daily activity steps: 2300 steps", and the like, which are used to debug the data acquisition module and the abnormal warning function (such as automatically reminding nursing staff when the heart rate is too high) of the platform. For example, in testing the transaction process and security mechanism of mobile payment, MOCK transaction data is generated, including "payment amount: 356.80 yuan, payment method: bank card payment", "transaction time: 2024-07-09 15:30:22", "device information: iPhone 13, operating system: iOS 16.5", and the like.
[0025] Therefore, the MOCK data can be quickly generated by the MOCK generation method, thereby improving the response speed of the health monitoring platform, the testable payment interface, the accuracy of transaction records, and the processing capability of abnormal scenarios.
[0026] The present application provides a MOCK data generation method, device, computer equipment and storage medium. The MOCK data generation method comprises: receiving interface definition data from a client and inputting the interface definition data into a preset data generation model; performing standardized processing on the interface definition data according to a preset prompt project and the data generation model and generating standardized interface definition data; receiving MOCK request information, generating corresponding MOCK data according to the data generation model and the standardized interface definition data, and returning the MOCK data to the client.
[0027] The present application inputs interface definition data by a user, and utilizes the data generation model to perform standardized processing on the interface definition data to obtain the standardized interface definition data. Then, the data generation model is utilized again to automatically generate MOCK data according to the MOCK request information of the user in combination with the standardized interface definition data, without manual repeated construction by the user. Meanwhile, the interface definition data can be repeatedly used only by inputting the interface definition data once, and the user can obtain required MOCK data in different scenarios, thereby reducing cost and improving generation efficiency and accuracy of generated data.
[0028] Figure 1 is a flowchart of a MOCK data generation method provided by an embodiment of the present application. As shown in the figure, Figure 1As shown, the method comprises steps S110-S130.
[0029] S110, receiving interface definition data from the client and inputting the interface definition data into a preset data generation model;
[0030] MOCK data (also known as simulation data) is virtual data artificially or automatically generated to simulate data interaction in real business scenarios during software development, testing or interface debugging. It does not depend on real databases or business systems, but can meet the requirements of data format, structure and constraints in interface calling, function testing, process verification and other scenarios.
[0031] The MOCK data generation method in the present application is used to automatically build the MOCK data required by the user by computer, without the need for the user to manually build, thereby improving work efficiency and reducing errors.
[0032] First, the user enters interface definition data on the client side. The interface definition data is a structured information set used to describe the interface (such as API interface, service interface, etc.) in the software system, which clearly specifies the communication rules, data format, interaction mode and constraint conditions of the interface, and is the "contract" for data interaction between the client and the server (or different system components). Interface definition data is the basis for the MOCK platform to generate simulation data - the MOCK platform can generate MOCK data that meets the interface format and constraints by analyzing these definitions to ensure that interface calling can be performed as expected during development and testing. At the same time, it is also an important basis for unified interface understanding and reduced communication costs in team collaboration. The interface definition data in the present embodiment includes interface address, request type, entry parameter, exit parameter, exception condition, etc.
[0033] Therefore, after the user enters the interface definition data on the client side, the client transmits the interface definition data to the MOCK platform; after the MOCK platform receives the interface definition data from the client, the interface definition data is input into a preset data generation model; the data generation model is a large model pre-set in the MOCK platform for generating MOCK data, and the data generation model is a natural language processing model based on deep learning, and its construction process includes the following steps:
[0034] 1. Data collection: collect a large amount of text data from the Internet, books, papers and other sources to build a training data set;
[0035] 2. Model architecture design: adopt the Transformer architecture, which includes multiple layers of self-attention mechanism and feedforward neural network;
[0036] 3. Pre-training: Unsupervised pre-training on large-scale text data to learn the basic rules and knowledge of language;
[0037] 4. Fine-tuning: Supervised fine-tuning on specific tasks (such as text generation, question answering, etc.) to improve the model's performance in specific domains;
[0038] 5. Inference: In actual applications, generate output that meets requirements through input prompts.
[0039] The principle of the data generation model is based on the self-attention mechanism, which can capture long-distance dependencies in text and understand and generate the MOCK data through multi-layer stacking.
[0040] Therefore, in this embodiment, after the MOCK platform receives the interface definition data from the client, it analyzes the interface definition data through the preset data generation model, providing an important basis for subsequent generation of MOCK data that meets the interface format and constraints.
[0041] For example, in the development and testing of medical and health care intelligent customer service software, testers need to simulate user interaction data with customer service to verify the response logic of intelligent customer service to medical consultation, chronic disease management, and other businesses. At this time, the client sends interface definition data to the MOCK platform, which includes business scenario identification (such as "old age chronic disease medication consultation"), data field requirements (patient age, disease type, medication history, consultation time, etc.), and field constraint conditions (age must be in the 60-90 age range, disease type limited to chronic diseases such as hypertension and diabetes).
[0042] After the receiving module of the MOCK platform receives the above interface definition data through the HTTPS protocol, it verifies the data format and confirms that there is no logical conflict in the field constraint conditions (such as the matching of the age range and the disease type), and then inputs the interface definition data that passes the verification to the preset data generation model. The data generation model is a generative neural network model trained based on medical domain corpus, which has been trained through massive real medical consultation data (such as patient inquiry records, electronic medical record fragments) and has the ability to identify business scenario features and generate data that meets medical standards.
[0043] After the model receives the interface definition data, it generates MOCK data that meets the constraint conditions: for example, generating MOCK data with a patient age of 72, a disease type of type 2 diabetes, a medication history of "metformin twice a day", and a consultation time of "2024-06-15 09:30".
[0044] In the intelligent assistant software development test scene in the financial technology field, the interface definition data sent by the client contains the business identifier of "financial product recommendation", and the fields require user asset size, risk preference, investment period, etc. The constraint condition is that the asset size matches the risk level of the recommended product (such as assets below 100,000 yuan preferentially recommend low-risk financial products). After the MOCK platform receives the data, it is input into the preset data generation model adapted to the financial field to generate MOCK data of user assets of 80,000 yuan, risk preference "stable type", and investment period "1 year".
[0045] In an embodiment, as shown in Figure 2 Step S110 can include steps S111-S112.
[0046] S111, filling the visual form according to the interface definition document to generate form data;
[0047] S112, generating the interface definition data according to the form data through a preset interface definition description generator.
[0048] Specifically, the interface definition document refers to a technical document describing interface specifications, which usually contains interface URL, request method, parameter list, return value structure, error code, etc. Common formats include OpenAPI Specification (OAS), Swagger document, Postman Collection, etc. The interface definition document in this embodiment is maintained in the project management document, so the acquisition method of the interface definition document is simple, the cost is low, and there is no need for users to manually fill in the interface definition content.
[0049] The visual form refers to an interactive form interface for receiving the description content of the interface definition, which includes function description, microservice name, URL, Method, parameter description, etc. The visual form can clearly describe the entire definition content of the interface, so that the interface definition data can be more accurately obtained.
[0050] The user enters the interface definition document into the system on the client, and the system parses the content of the interface definition document, extracts the key information and fills it into the visual form, thereby generating form data, which refers to form data filled with interface definition content.
[0051] Therefore, the content of the form data can be obtained from the interface definition document maintained in the project management document, the acquisition method is simple, there is no need for users to enter the form data content one by one, the work efficiency is high, and the data is more accurate.
[0052] After obtaining the form data, the system generates the interface definition data of the text mode for the content of the form data by using an interface definition description generator, which is used to convert data in a form format into data in a text format, thereby facilitating the analysis and processing of the interface definition data by the data generation model.
[0053] S120, standardizing the interface definition data according to the preset prompt engineering and the data generation model and generating standardized interface definition data;
[0054] Specifically, because the habits of different developers or the interface definition rules used by teams are different, it is necessary to formulate standard interface definition rules according to the preset prompt engineering and the data generation model, and to standardize the interface definition data by the prompt engineering and the data generation model, thereby generating standardized interface definition data.
[0055] The prompt engineering refers to guiding the model to generate expected output by designing specific text prompts (Prompts). In the present scenario, the prompt engineering is used to guide the data generation model on how to standardize the interface definition data.
[0056] The data generation model is a large language model (LLM) or a special generation model (such as T5, GPT series) based on deep learning, which can understand the semantics of the interface definition data after training, and can standardize the interface definition data according to the guidance of the prompt engineering, and can also generate a large model of MOCK data.
[0057] The standardized interface definition data refers to the interface description format conforming to a specific specification (such as OpenAPI, JSON Schema), which has a unified structure and semantics.
[0058] Therefore, in the present embodiment, the interface definition data is standardized by the prompt engineering and the data generation model, thereby generating standardized interface definition data, thereby unifying the interface definition data in different formats, and improving the efficiency and accuracy of the data generation model in generating MOCK data subsequently.
[0059] In an embodiment, as shown in Figure 3 The step S120 includes steps S121-S123.
[0060] S121, extracting key information of the interface definition data;
[0061] S122, structuring the key information and outputting the standardized interface definition data in combination with a preset standardized interface definition rule;
[0062] S123, archive the standardized interface definition data.
[0063] Specifically, the data generation model can understand the natural language description input by the user, so that the key information in the interface definition data is extracted through the data generation model, and the key information refers to the information in the interface definition data that determines the core function and interaction rules of the interface, such as interface name, parameter type, field constraint, data format, etc., which includes GET, POST, query, parameters, etc. in API design.
[0064] The key information is then structured, which means that the key information is organized according to a preset logic into a data form with fixed format and hierarchical relationship, facilitating subsequent processing and reuse; the preset standardized interface definition rule refers to the interface definition criterion formulated according to industry general standards or enterprise internal specifications, including field naming specification, data type mapping rule, constraint condition format, etc. The standardized interface definition data is output by structuring the key information and combining the preset standardized interface definition rule, which refers to the interface definition data that meets the preset rule after standardization processing, and can realize seamless interaction between different systems.
[0065] Finally, the standardized interface definition data is archived to facilitate subsequent generation of the MOCK data by the data generation model according to the standardized interface definition data, improve the generation efficiency, and ensure the accuracy of the generated data.
[0066] Exemplarily, taking the "patient medication record query interface" in the medical and health care field as an example, first, the key information is extracted from the original interface definition data, including the interface name "patient medication record query", the request parameter "patient ID" (string type, required), the query date (date format), the response field "drug name", "medication dose", "medication frequency", etc., and the constraint conditions of each field (such as the medication dose must be a positive number); then, according to the preset standard interface definition rules of the medical industry (such as using the HL7FHIR specification related field naming), the extracted key information is structured. The "patient ID" is standardized as "PatientID", the "query date" is unified as "YYYY-MM-DD" format, and the "medication dose" is clearly marked with a unit field. After processing, the standardized interface definition data is generated, including interface basic information, request parameter list (including name, type, constraint), response field list, etc. hierarchical structure; finally, the generated standardized interface definition data is stored in the database of the MOCK platform, and is indexed according to the field classification. The "patient medication record query interface" standardized data in the medical field is associated with other interface data in this field. At the same time, the metadata such as data generation time and version information is recorded, which is convenient for subsequent query, update and reuse, and provides reliable standardized data support for interface testing, system integration, etc.
[0067] Through the above process, the standardization of interface definition data in different fields is realized, the consistency and universality of the data are improved, and the system integration cost is reduced.
[0068] In an embodiment, as shown in Figure 4 S122 includes steps S1221-S1222.
[0069] S1221, according to the preset JSON data structure rule, the field of the key information is mapped to the corresponding key value of the JSON structure, so as to generate the standardized interface definition data;
[0070] S1222, the standardized interface definition data is format checked, and if the checking is passed, the standardized interface definition data in JSON format is output.
[0071] Specifically, the JSON data structure rule refers to a predefined JSONschema used to standardize the interface definition data format, including field naming conventions, data type mapping relationships, hierarchical structure requirements, etc.; the fields of the key information are mapped to the corresponding key values of the JSON structure according to the JSON data structure rule, for example, the fields of the key information (such as "patient_id") are mapped to the key (such as "patientId") and its value type (such as "string") of the standard JSON structure according to the JSON data structure rule. The mapping relationship can be automatically matched based on a preset rule or manually specified through a configuration file. Thus, the standardized interface definition data is generated.
[0072] Then, the standardized interface definition data is subjected to format verification, which refers to verifying whether the generated standardized interface definition data conforms to the preset rule using JSONschema, including whether the field types match (such as whether the string conforms to the regular expression), whether the required fields exist, whether the nested structure is correct, etc.
[0073] If the verification of the standardized interface definition data passes, it is proved that the standardized interface definition data conforms to the JSON data structure rule, and the standardized interface definition data in JSON format is obtained, thereby improving the utilization efficiency of the data generation model for the standardized interface definition data.
[0074] In an embodiment, as shown in FIG. 12, steps S1231-S1233 are included before step S123. Figure 5
[0075] S1231, returning the standardized interface definition data to the client;
[0076] S1232, receiving the confirmation information of the user and judging the type of the confirmation information;
[0077] S1233, if the type is correct information, archiving the standardized interface definition data.
[0078] Specifically, to further ensure the accuracy of the data, after the interface definition data is standardized, the standardized interface definition data after the standardization needs to be confirmed. Only when the standardized interface definition data is of the correct type, it is archived and saved, thereby ensuring the accuracy of the data generation model when generating the MOCK data according to the standardized interface definition data.
[0079] The standardized interface definition data is returned to the client, so that a user checks and confirms whether the standardized interface definition data is correct; the user views the standardized interface definition data in the client and inputs confirmation information indicating whether the standardized interface definition data is correct or incorrect; after the MOCK platform receives the confirmation information, the type of the confirmation information is judged, the type including correct information and incorrect information; if the type is correct information, it indicates that the standardized interface definition data is correct and has no problem in format and definition, and the standardized interface definition data is archived and saved to facilitate the data generation model to generate the MOCK data through the standardized interface definition data.
[0080] In an embodiment, step S1232 is followed by step S12321.
[0081] S12321, if the type is incorrect information, the standardized interface definition data is modified and adjusted and then archived.
[0082] Specifically, when the user checks the standardized interface definition data, it is found that the standardized interface definition data has errors, and the system needs to modify and adjust the standardized interface definition data, for example, the standardized interface definition data has field errors, such as the user points out that the "patient age" field should be limited to 0-150 years old, and the system should adjust the constraint condition; if there is a rule error, such as the user requires the financial interface to use ISO 4217 currency code instead of custom abbreviation, the system updates the mapping rule; if there is a structure error, such as the user requires the "address" field to be split into a three-level structure of "province / city / district", the system reconstructs the data model. Until the standardized interface definition data is adjusted to correct information, it is archived and saved.
[0083] S130, receiving the MOCK request information, generating corresponding MOCK data according to the data generation model and the standardized interface definition data, and returning the MOCK data to the client.
[0084] Specifically, when a user needs MOCK data, the user sends MOCK request information to the MOCK platform through a client, the MOCK request information indicating information for requesting generation of MOCK data, the MOCK request information generally including interface identification (such as an interface name, a path), request parameters (such as query conditions, paging information), an expected response format (such as JSON, XML), special constraints (such as error code simulation, delayed response), and other data requirements; after the MOCK platform receives the MOCK request information, the data generation model generates corresponding MOCK data according to the standardized interface definition data, the MOCK data meeting the conditions in the MOCK request information, and returns the MOCK data to the client for use by the user.
[0085] In this embodiment, the MOCK data corresponding to the MOCK request information is generated by using the data generation model and the standardized interface definition data through the MOCK request information of the user, the operation is simple, the generation efficiency is high, and the technical problems that the MOCK data is tedious, time-consuming, and prone to errors in the generation process are solved.
[0086] In an embodiment, as shown in FIG. 13, Figure 6 Steps S130 can include steps S131-S132.
[0087] S131, parse the MOCK request information to obtain interface definition of corresponding standardized interface definition data, and extract main information;
[0088] S132, generate the MOCK data by prompting engineering combined with the main information limited data specification.
[0089] Specifically, the MOCK request information contains interface identification, required data range, special format requirements, and other contents, by parsing the MOCK request information, the interface definition content of the standardized interface definition data corresponding to the MOCK request information is obtained, the interface definition of the standardized interface definition data indicating an interface description conforming to an industry or enterprise standard, and the fields, data types, constraint conditions, structure levels, and other information of the interface required in the request are clear, and main information is extracted, the main information indicating core content extracted from the interface definition of the standardized interface definition data, such as key fields, data type restrictions, business logic constraints, and the like.
[0090] The MOCK data is then generated by the prompting engineering combined with the main information limited data specification. The prompting engineering indicates that by designing specific prompt texts, the data generation model is guided to generate MOCK data meeting expectations according to preset rules and requirements and the main information.
[0091] For example, take the "Electronic Medical Record Query Interface" in the medical health field as an example:
[0092] 1. After receiving the MOCK request information of the "Electronic Medical Record Query Interface", parse its standardized interface definition. This definition clearly defines the interface to contain "patient ID" (string type, 32-bit UUID format), "treatment date" (date type, format YYYY-MM-DD), "diagnosis result" (string type, which needs to comply with ICD-10 disease coding), "medication list" (array type, containing drug name, dosage, frequency, etc. Sub-field) and other content. Extract the main information: the UUID format constraint of the patient ID, the time range of the treatment date, the coding rules of the diagnosis result, the sub-field structure and logical relationship of the medication list;
[0093] 2. Based on the extracted main information, design a prompt text to guide the data generation model. The prompt content includes "generate MOCK data that meets the requirements of the Electronic Medical Record Query Interface, patient ID is 32-bit UUID, treatment date is between 2023-01-01 and 2024-06-30, diagnosis result needs to be the disease name corresponding to ICD-10 coding, and the dosage of each drug in the medication list needs to be a positive number and the frequency needs to comply with clinical conventions". The data generation model generates MOCK data that meets the data specification based on this prompt, such as patient ID "0012", treatment date "2023-05-12", diagnosis result "J06.9 (acute upper respiratory tract infection, not specified)", and medication list containing "amoxicillin, 0.5g / each, 3 times / day" and other content.
[0094] For example, take the "Credit Card Transaction Record Interface" in the financial technology field as an example:
[0095] 1. For the MOCK request of the "Credit Card Transaction Record Interface", parse its standardized interface definition. This definition contains "card number" (string type, 16-digit number), "transaction amount" (numeric type, with two decimal places, greater than 0), "transaction time" (timestamp type), "transaction type" (enumeration type, including consumption, cash, and repayment) and other fields. The main information extracted includes: the number of digits of the card number, the numerical range and precision of the transaction amount, the enumeration values of the transaction type, and the association between the transaction time and the transaction type (such as the repayment transaction time needs to be after the billing date);
[0096] 2. Construct a prompt according to the main information, such as "generate MOCK data of credit card transaction record, card number is 16 digits, transaction amount is greater than 0 and reserves two decimal places, transaction type is selected from consumption, cash, and repayment, transaction time needs to be within 2024-01-01 to 2024-06-30, if the transaction type is repayment, the amount needs to be less than or equal to the current bill amount". The data generation model generates MOCK data according to the prompt, for example, card number "6228481234567890", transaction amount "356.80", transaction type "consumption", transaction time "2024-03-15 14:30:25", etc., and all data conforms to the set data specification.
[0097] Through the above process, the generated MOCK data can meet the technical requirements of the interface and also meet the actual needs of the business scenario, which can be effectively used for client development and testing work.
[0098] The present application defines data through a user input interface, and standardizes the interface definition data using the data generation model to obtain the standardized interface definition data, and then uses the data generation model to automatically generate MOCK data according to the user's MOCK request information, combined with the standardized interface definition data, without the need for the user to manually and repeatedly construct; at the same time, only one input of the interface definition data is required, and the interface definition data can be repeatedly used, and the user can obtain the required MOCK data in different scenarios, thereby reducing costs and improving generation efficiency and data accuracy.
[0099] Figure 7 is a schematic block diagram of a MOCK data generation device 300 provided by an embodiment of the present application. As shown in Figure 7 Corresponding to the above MOCK data generation method, the present application also provides a MOCK data generation device 300. The MOCK data generation device 300 includes units for executing the above MOCK data generation method, and the device can be configured in a computer device. Specifically, please refer to Figure 7 The MOCK data generation device 300 includes a receiving unit 301 and a generating unit 302.
[0100] The receiving unit 301 receives interface definition data from the client and inputs the interface definition data into a preset data generation model;
[0101] The generating unit 302 performs standardization processing on the interface definition data according to a preset prompting project and the data generation model, and generates standardized interface definition data; receives the MOCK request information, generates corresponding MOCK data according to the data generation model and the standardized interface definition data, and returns the MOCK data to the client; fills the visual form according to the interface definition document to generate form data; and generates the interface definition data through a preset interface definition description generator according to the form data.
[0102] In an embodiment, the generating unit 302 includes a processing unit and an archiving unit.
[0103] The processing unit extracts key information of the interface definition data, performs structural processing on the key information, and outputs the standardized interface definition data in combination with a preset standardized interface definition rule; maps fields of the key information to corresponding key values in a JSON structure according to a preset JSON data structure rule, to generate the standardized interface definition data; performs format checking on the standardized interface definition data, and if the checking is passed, outputs the standardized interface definition data in a JSON format; returns the standardized interface definition data to the client; receives confirmation information of a user, and judges a type of the confirmation information; parses an interface definition of the standardized data corresponding to the MOCK request information, extracts main information, generates the MOCK data through the prompting project in combination with the main information limited data specification.
[0104] The archiving unit archives and saves the standardized interface definition data; if the type is correct information, archives the standardized interface definition data; if the type is error information, modifies and adjusts the standardized interface definition data, and then archives.
[0105] It should be noted that a person skilled in the art can clearly understand the specific implementation process of the above-described MOCK data generation device and each unit, which can refer to the corresponding description in the foregoing method embodiments. For the convenience and brevity of description, it will not be repeated here.
[0106] The above-described MOCK data generation device 300 can be realized in the form of a computer program, which can run on a computer device as shown in Figure 8 .
[0107] Please refer to Figure 8 , Figure 8is a schematic block diagram of a computer device provided by an embodiment of the present application. The computer device 500 can be a terminal or a server, wherein the terminal can be a smart phone, a tablet computer, a notebook computer, a desktop computer, a personal digital assistant, a wearable device, and the like electronic device having a communication function. The server can be a standalone server or a server cluster composed of multiple servers.
[0108] Referring to Figure 8 The computer device 500 includes a processor 502, a memory, and a network interface 505 connected through a system bus 501, wherein the memory can include a non-volatile storage medium 503 and an internal memory 504.
[0109] The non-volatile storage medium 503 can store an operating system 5031 and a computer program 5032. The computer program 5032 includes program instructions which, when executed, can cause the processor 502 to perform a MOCK data generation method.
[0110] The processor 502 is configured to provide computing and control capabilities to support the operation of the entire computer device 500.
[0111] The internal memory 504 provides an environment for the running of the computer program 5032 in the non-volatile storage medium 503, which, when executed by the processor 502, can cause the processor 502 to perform a MOCK data generation method.
[0112] The network interface 505 is configured to perform network communication with other devices. Those skilled in the art can understand that Figure 8 The structure shown in the figure is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device 500 to which the scheme of the present application is applied. The specific computer device 500 can include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0113] The processor 502 is configured to run the computer program 5032 stored in the memory to implement the steps of the above-mentioned MOCK data generation method.
[0114] It should be understood that, in the embodiments of the present application, the processor 502 can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.
[0115] It can be understood by those skilled in the art that all or part of the processes in the above-mentioned embodiments can be completed by a computer program instructing related hardware. The computer program includes program instructions, and the computer program can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the above-mentioned embodiments.
[0116] Therefore, the present application also provides a storage medium. The storage medium can be a computer-readable storage medium. The storage medium stores a computer program, wherein the computer program includes program instructions. The program instructions are executed by a processor to make the processor execute the steps of the above-mentioned MOCK data generation method.
[0117] The storage medium can be a U disk, a mobile hard disk, a read-only memory (ROM), a magnetic disk or an optical disk, and various computer-readable storage media that can store program codes.
[0118] Those skilled in the art can realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be realized in electronic hardware, computer software or a combination of both. In order to clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been described in the above description in general terms. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. The skilled person can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0119] In several embodiments provided by the present application, it should be understood that the disclosed apparatus and method can be implemented in other manners. For example, the embodiments of the apparatus described above are merely schematic. For example, the division of the units is merely a logical function division. For example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In this way, the inventive idea can be implemented.
[0120] The steps in the method embodiments of the present application can be adjusted, combined and deleted in sequence according to actual needs. The units in the apparatus embodiments of the present application can be combined, divided and deleted according to actual needs. In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit.
[0121] The integrated unit, if realized in the form of a software functional unit and sold or used as an independent product, can be stored in a storage medium. Based on such understanding, the technical solutions of the present application essentially or the part that contributes to the prior art, or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes a plurality of instructions for causing a computer device (which can be a personal computer, a terminal, or a network device, etc.) to execute all or part of the steps of the methods described in the embodiments of the present application.
[0122] The above describes only specific embodiments of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of various equivalent modifications or replacements within the technical range disclosed by the present application, and these modifications or replacements should be covered in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
Claims
1. A method for generating MOCK data, characterized in that, The method applied to a MOCK platform comprises: receiving interface definition data from a client and inputting the interface definition data into a preset data generation model; standardizing the interface definition data according to a preset prompt project and the data generation model and generating standardized interface definition data; receiving MOCK request information, generating corresponding MOCK data according to the data generation model and the standardized interface definition data, and returning the MOCK data to the client.
2. The method of claim 1, wherein, The step of receiving interface definition data from a client comprises: filling a visual form according to an interface definition document to generate form data; generating the interface definition data through a preset interface definition description generator according to the form data.
3. The method of claim 1, wherein, The step of standardizing the interface definition data according to a preset prompt project and the data generation model and generating standardized interface definition data comprises: extracting key information of the interface definition data; structuring the key information and outputting the standardized interface definition data in combination with a preset standardized interface definition rule; archiving and saving the standardized interface definition data.
4. The method of claim 3, wherein, The step of structuring the key information and outputting the standardized interface definition data in combination with a preset standardized interface definition rule comprises: mapping fields of the key information to corresponding key values of a JSON structure according to a preset JSON data structure rule to generate the standardized interface definition data; performing format verification on the standardized interface definition data, and if the verification is passed, outputting the standardized interface definition data in JSON format.
5. The method of claim 3, wherein, The step of archiving and saving the standardized interface definition data comprises: returning the standardized interface definition data to the client; receiving confirmation information of a user and judging a type of the confirmation information; if the type is correct information, archiving the standardized interface definition data.
6. The method of claim 5, wherein, The step of receiving confirmation information of a user and judging a type of the confirmation information further comprises: if the type is incorrect information, modifying and adjusting the standardized interface definition data and then archiving the standardized interface definition data.
7. The method of claim 1, wherein, The step of generating corresponding MOCK data according to the data generation model and the standardized data comprises: analyzing interface definition of the standardized data corresponding to the MOCK request information and extracting main information; generating the MOCK data through a prompt project in combination with data specification defined by the main information. 8.A MOCK data generation apparatus, applied to a MOCK platform, and characterized in that, The computer device comprises a memory and a processor, the memory stores a computer program, and the processor implements the method when executing the computer program.
9. A computer device, comprising: The storage medium stores a computer program, the computer program comprises program instructions, and the program instructions can implement the method when being executed by a processor.
10. A storage medium, characterized by